1 | n/a | #! /usr/bin/env python3 |
---|
2 | n/a | |
---|
3 | n/a | """ |
---|
4 | n/a | Script to run Python regression tests. |
---|
5 | n/a | |
---|
6 | n/a | Run this script with -h or --help for documentation. |
---|
7 | n/a | """ |
---|
8 | n/a | |
---|
9 | n/a | # We import importlib *ASAP* in order to test #15386 |
---|
10 | n/a | import importlib |
---|
11 | n/a | |
---|
12 | n/a | import os |
---|
13 | n/a | import sys |
---|
14 | n/a | from test.libregrtest import main |
---|
15 | n/a | |
---|
16 | n/a | |
---|
17 | n/a | # Alias for backward compatibility (just in case) |
---|
18 | n/a | main_in_temp_cwd = main |
---|
19 | n/a | |
---|
20 | n/a | |
---|
21 | n/a | def _main(): |
---|
22 | n/a | global __file__ |
---|
23 | n/a | |
---|
24 | n/a | # Remove regrtest.py's own directory from the module search path. Despite |
---|
25 | n/a | # the elimination of implicit relative imports, this is still needed to |
---|
26 | n/a | # ensure that submodules of the test package do not inappropriately appear |
---|
27 | n/a | # as top-level modules even when people (or buildbots!) invoke regrtest.py |
---|
28 | n/a | # directly instead of using the -m switch |
---|
29 | n/a | mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) |
---|
30 | n/a | i = len(sys.path) - 1 |
---|
31 | n/a | while i >= 0: |
---|
32 | n/a | if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: |
---|
33 | n/a | del sys.path[i] |
---|
34 | n/a | else: |
---|
35 | n/a | i -= 1 |
---|
36 | n/a | |
---|
37 | n/a | # findtestdir() gets the dirname out of __file__, so we have to make it |
---|
38 | n/a | # absolute before changing the working directory. |
---|
39 | n/a | # For example __file__ may be relative when running trace or profile. |
---|
40 | n/a | # See issue #9323. |
---|
41 | n/a | __file__ = os.path.abspath(__file__) |
---|
42 | n/a | |
---|
43 | n/a | # sanity check |
---|
44 | n/a | assert __file__ == os.path.abspath(sys.argv[0]) |
---|
45 | n/a | |
---|
46 | n/a | main() |
---|
47 | n/a | |
---|
48 | n/a | |
---|
49 | n/a | if __name__ == '__main__': |
---|
50 | n/a | _main() |
---|