1#!/usr/bin/env python 2 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 5# found in the LICENSE file. 6 7""" 8Tests that filenames that contain colons are handled correctly. 9(This is important for absolute paths on Windows.) 10""" 11 12import os 13import sys 14import TestGyp 15 16# TODO: Make colons in filenames work with make, if required. 17test = TestGyp.TestGyp(formats=['!make', '!android']) 18CHDIR = 'colon' 19 20source_name = 'colon/a:b.c' 21copies_name = 'colon/a:b.c-d' 22if sys.platform == 'win32': 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. 25 abs_source = os.path.abspath('colon/file.c') 26 test.write('colon/test.gyp', 27 test.read('colon/test.gyp').replace("'a:b.c'", repr(abs_source))) 28 source_name = abs_source 29 30 abs_copies = os.path.abspath('colon/file.txt') 31 test.write('colon/test.gyp', 32 test.read('colon/test.gyp').replace("'a:b.c-d'", repr(abs_copies))) 33 copies_name = abs_copies 34 35# Create the file dynamically, Windows is unhappy if a file with a colon in 36# its name is checked in. 37test.write(source_name, 'int main() {}') 38test.write(copies_name, 'foo') 39 40test.run_gyp('test.gyp', chdir=CHDIR) 41test.build('test.gyp', test.ALL, chdir=CHDIR) 42test.built_file_must_exist(os.path.basename(copies_name), chdir=CHDIR) 43test.pass_test() 44