|
12 | 12 | import os
|
13 | 13 | import sys
|
14 | 14 |
|
15 |
| -# FIXME #12303 these tests are broken on windows |
16 |
| -if os.name == 'nt': |
17 |
| - print 'ignoring make tests on windows' |
18 |
| - sys.exit(0) |
| 15 | +# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into |
| 16 | +# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks |
| 17 | +# the value is list of paths. |
| 18 | +# this causes great confusion and error: shell and Makefile doesn't like |
| 19 | +# windows paths so it is really error-prone. revert it for peace. |
| 20 | +def normalize_path(v): |
| 21 | + # c:\path -> /c/path |
| 22 | + if ':\\' in v: |
| 23 | + v = '/' + v.replace(':\\', '/') |
| 24 | + v = v.replace('\\', '/') |
| 25 | + return v |
| 26 | + |
| 27 | + |
| 28 | +def putenv(name, value): |
| 29 | + if os.name == 'nt': |
| 30 | + value = normalize_path(value) |
| 31 | + os.putenv(name, value) |
| 32 | + |
19 | 33 |
|
20 | 34 | make = sys.argv[2]
|
21 |
| -os.putenv('RUSTC', os.path.abspath(sys.argv[3])) |
22 |
| -os.putenv('TMPDIR', os.path.abspath(sys.argv[4])) |
23 |
| -os.putenv('CC', sys.argv[5]) |
24 |
| -os.putenv('RUSTDOC', os.path.abspath(sys.argv[6])) |
| 35 | +putenv('RUSTC', os.path.abspath(sys.argv[3])) |
| 36 | +putenv('TMPDIR', os.path.abspath(sys.argv[4])) |
| 37 | +putenv('CC', sys.argv[5]) |
| 38 | +putenv('RUSTDOC', os.path.abspath(sys.argv[6])) |
25 | 39 | filt = sys.argv[7]
|
26 | 40 | ldpath = sys.argv[8]
|
27 | 41 | if ldpath != '':
|
28 |
| - os.putenv(ldpath.split('=')[0], ldpath.split('=')[1]) |
| 42 | + name = ldpath.split('=')[0] |
| 43 | + value = ldpath.split('=')[1] |
| 44 | + if os.name == 'nt' and name != 'PATH': |
| 45 | + value = ":".join(normalize_path(v) for v in value.split(";")) |
| 46 | + os.putenv(name, value) |
29 | 47 |
|
30 | 48 | if not filt in sys.argv[1]:
|
31 | 49 | sys.exit(0)
|
32 | 50 | print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))
|
33 | 51 |
|
34 |
| -proc = subprocess.Popen([make, '-C', sys.argv[1]], |
| 52 | +path = sys.argv[1] |
| 53 | +if path[-1] == '/': |
| 54 | + # msys1 has a bug that `make` fails to include `../tools.mk` (parent dir) |
| 55 | + # if `-C path` option is given and `path` is absolute directory with |
| 56 | + # trailing slash (`c:/path/to/test/`). |
| 57 | + # the easist workaround is to remove the slash (`c:/path/to/test`). |
| 58 | + # msys2 seems to fix this problem. |
| 59 | + path = path[:-1] |
| 60 | + |
| 61 | +proc = subprocess.Popen([make, '-C', path], |
35 | 62 | stdout = subprocess.PIPE,
|
36 | 63 | stderr = subprocess.PIPE)
|
37 | 64 | out, err = proc.communicate()
|
|
0 commit comments