|
7 | 7 | python3 test_matrix.py |
8 | 8 | python3 test_matrix.py -v # verbose mode |
9 | 9 | """ |
| 10 | +import argparse |
10 | 11 | import os.path |
| 12 | +import shutil |
11 | 13 | import subprocess |
12 | 14 | import sys |
13 | | -import shutil |
14 | 15 |
|
15 | 16 |
|
16 | 17 | TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests') |
@@ -56,21 +57,35 @@ def run_tests(python, verbose, tested): |
56 | 57 | run_tests_exe(executable, verbose, tested) |
57 | 58 |
|
58 | 59 |
|
| 60 | +def parse_args(): |
| 61 | + parser = argparse.ArgumentParser() |
| 62 | + parser.add_argument('-v', '--verbose', action="store_true", |
| 63 | + help='Verbose mode') |
| 64 | + parser.add_argument('-c', '--current', action="store_true", |
| 65 | + help="Only test the current Python executable " |
| 66 | + "(don't test multiple Python versions)") |
| 67 | + return parser.parse_args() |
| 68 | + |
| 69 | + |
59 | 70 | def main(): |
60 | | - verbose = "-v" in sys.argv[1:] |
| 71 | + args = parse_args() |
61 | 72 |
|
62 | 73 | cmd = [sys.executable, TEST_UPGRADE] |
63 | | - if verbose: |
| 74 | + if args.verbose: |
64 | 75 | cmd.append('-v') |
65 | 76 | run_command(cmd) |
| 77 | + print() |
66 | 78 |
|
67 | 79 | tested = set() |
68 | | - for python in PYTHONS: |
69 | | - run_tests(python, verbose, tested) |
70 | | - run_tests_exe(sys.executable, verbose, tested) |
71 | | - |
72 | | - print() |
73 | | - print(f"Tested: {len(tested)} Python executables") |
| 80 | + if not args.current: |
| 81 | + for python in PYTHONS: |
| 82 | + run_tests(python, args.verbose, tested) |
| 83 | + run_tests_exe(sys.executable, args.verbose, tested) |
| 84 | + |
| 85 | + print() |
| 86 | + print(f"Tested: {len(tested)} Python executables") |
| 87 | + else: |
| 88 | + run_tests_exe(sys.executable, args.verbose, tested) |
74 | 89 |
|
75 | 90 |
|
76 | 91 | if __name__ == "__main__": |
|
0 commit comments