|
6 | 6 | from pathlib import Path |
7 | 7 | import enum |
8 | 8 |
|
9 | | -from testmatrix.HTMLScoreboard import write_html_matrix |
10 | | -from testmatrix.matrix import Builds, Matrix |
| 9 | +from testmatrix import Matrix, write_html_files |
| 10 | + |
| 11 | + |
| 12 | +def opt_or_prop(matrix, args, name): |
| 13 | + opt = getattr(args, name) |
| 14 | + if opt is not None: |
| 15 | + return opt |
| 16 | + prop_name = f'matrix_{name}' |
| 17 | + if prop_name in matrix.props: |
| 18 | + return matrix.props[prop_name] |
| 19 | + sys.exit(f'Need to either pass --{name} VALUE or define <prop {prop_name}="VALUE"/> in the ' |
| 20 | + 'scoreboard XML file.') |
11 | 21 |
|
12 | 22 |
|
13 | 23 | if __name__ == '__main__': |
14 | 24 | arg_parser = argparse.ArgumentParser( |
15 | | - description='Generate a test status matrix from autobuild output') |
| 25 | + description='Generates a test status matrix from autobuild output.') |
16 | 26 | arg_parser.add_argument('builds_dir', type=Path, |
17 | | - help='Directory with autobuild/scoreboard build contents') |
18 | | - arg_parser.add_argument('prefix') |
| 27 | + help='Directory with the autobuild/scoreboard build contents') |
| 28 | + arg_parser.add_argument('--title', |
| 29 | + help='Title of the main matrix HTML page. Overrides <prop matrix_title="VALUE"/> in the ' |
| 30 | + 'scoreboard XML files.') |
| 31 | + arg_parser.add_argument('--basename', |
| 32 | + help='Prefix of all created files. Overrides <prop matrix_basename="VALUE"/> in the ' |
| 33 | + 'scoreboard XML files.') |
| 34 | + arg_parser.add_argument('--dump-only', action='store_true', |
| 35 | + help='Don\'t create any files, only dump the matrix in the CLI.') |
19 | 36 | args = arg_parser.parse_args() |
20 | 37 |
|
21 | | - builds = Builds(args.builds_dir) |
22 | | - matrix = Matrix(builds) |
| 38 | + matrix = Matrix(args.builds_dir) |
23 | 39 | matrix.dump() |
24 | 40 |
|
25 | | - write_html_matrix(matrix, args.prefix) |
| 41 | + if not args.dump_only: |
| 42 | + write_html_files(matrix, |
| 43 | + opt_or_prop(matrix, args, 'title'), |
| 44 | + opt_or_prop(matrix, args, 'basename')) |
0 commit comments