gyptest-colon.py 1.4 KB

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