diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-03 16:28:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-03 16:28:29 (GMT) |
commit | 3c548cfaf6ee1f5bfd20b385868c05b71e27168f (patch) | |
tree | 6cb8fdf74dc15c5259af1f39c013202869e110c0 | |
parent | 2c95cb3c2e99c5a6f58ca30195ac407ac164b336 (diff) | |
parent | 00f25dacc0bcd6defbadd23acb44574a05a7c747 (diff) | |
download | CMake-3c548cfaf6ee1f5bfd20b385868c05b71e27168f.zip CMake-3c548cfaf6ee1f5bfd20b385868c05b71e27168f.tar.gz CMake-3c548cfaf6ee1f5bfd20b385868c05b71e27168f.tar.bz2 |
Merge topic 'trace-test-support-python26-and-older'
00f25dacc0 trace: Directly parse commandline arguments without argparse
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4169
-rwxr-xr-x | Tests/RunCMake/CommandLine/trace-json-v1-check.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py index 69dfc20..14febaf 100755 --- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import argparse import json import os import sys @@ -8,15 +7,21 @@ import sys if sys.version_info[0] >= 3: unicode = str -parser = argparse.ArgumentParser(description='Checks the trace output') -parser.add_argument('-e', '--expand', action='store_true') -parser.add_argument('trace', type=str, help='the trace file to check') +trace_file = None +expand = False -args = parser.parse_args() +for i in sys.argv[1:]: + if trace_file is None and not i.startswith('-'): + trace_file = i + continue -assert os.path.exists(args.trace) + if i in ['-e', '--expand']: + expand = True -if args.expand: +assert trace_file is not None +assert os.path.exists(trace_file) + +if expand: msg_args = ['STATUS', 'fff', 'fff;sss; SPACES !!! ', ' 42 space in string!', ' SPACES !!! '] else: msg_args = ['STATUS', 'fff', '${ASDF}', ' ${FOO} ${BAR}', ' SPACES !!! '] @@ -44,7 +49,7 @@ required_traces = [ }, ] -with open(args.trace, 'r') as fp: +with open(trace_file, 'r') as fp: # Check for version (must be the first document) vers = json.loads(fp.readline()) assert sorted(vers.keys()) == ['version'] |