OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Tests that filenames that contain colons are handled correctly. | 8 Tests that filenames that contain colons are handled correctly. |
9 (This is important for absolute paths on Windows.) | 9 (This is important for absolute paths on Windows.) |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
13 import sys | 13 import sys |
14 import TestGyp | 14 import TestGyp |
15 | 15 |
16 # TODO: Make colons in filenames work with make, if required. | 16 # TODO: Make colons in filenames work with make, if required. |
17 test = TestGyp.TestGyp(formats=['!make', '!android']) | 17 test = TestGyp.TestGyp(formats=['!make']) |
18 CHDIR = 'colon' | 18 CHDIR = 'colon' |
19 | 19 |
20 source_name = 'colon/a:b.c' | 20 source_name = 'colon/a:b.c' |
21 copies_name = 'colon/a:b.c-d' | 21 copies_name = 'colon/a:b.c-d' |
22 if sys.platform == 'win32': | 22 if sys.platform == 'win32': |
23 # Windows uses : as drive separator and doesn't allow it in regular filenames. | 23 # Windows uses : as drive separator and doesn't allow it in regular filenames. |
24 # Use abspath() to create a path that contains a colon instead. | 24 # Use abspath() to create a path that contains a colon instead. |
25 abs_source = os.path.abspath('colon/file.c') | 25 abs_source = os.path.abspath('colon/file.c') |
26 test.write('colon/test.gyp', | 26 test.write('colon/test.gyp', |
27 test.read('colon/test.gyp').replace("'a:b.c'", repr(abs_source))) | 27 test.read('colon/test.gyp').replace("'a:b.c'", repr(abs_source))) |
28 source_name = abs_source | 28 source_name = abs_source |
29 | 29 |
30 abs_copies = os.path.abspath('colon/file.txt') | 30 abs_copies = os.path.abspath('colon/file.txt') |
31 test.write('colon/test.gyp', | 31 test.write('colon/test.gyp', |
32 test.read('colon/test.gyp').replace("'a:b.c-d'", repr(abs_copies))) | 32 test.read('colon/test.gyp').replace("'a:b.c-d'", repr(abs_copies))) |
33 copies_name = abs_copies | 33 copies_name = abs_copies |
34 | 34 |
35 # Create the file dynamically, Windows is unhappy if a file with a colon in | 35 # Create the file dynamically, Windows is unhappy if a file with a colon in |
36 # its name is checked in. | 36 # its name is checked in. |
37 test.write(source_name, 'int main() {}') | 37 test.write(source_name, 'int main() {}') |
38 test.write(copies_name, 'foo') | 38 test.write(copies_name, 'foo') |
39 | 39 |
40 test.run_gyp('test.gyp', chdir=CHDIR) | 40 test.run_gyp('test.gyp', chdir=CHDIR) |
41 test.build('test.gyp', test.ALL, chdir=CHDIR) | 41 test.build('test.gyp', test.ALL, chdir=CHDIR) |
42 test.built_file_must_exist(os.path.basename(copies_name), chdir=CHDIR) | 42 test.built_file_must_exist(os.path.basename(copies_name), chdir=CHDIR) |
43 test.pass_test() | 43 test.pass_test() |
OLD | NEW |