| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2013 Google Inc. All rights reserved. | 3 # Copyright (c) 2013 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 Test that the generator output can be written to a different drive on Windows. | 8 Test that the generator output can be written to a different drive on Windows. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import os | 11 import os |
| 12 import TestGyp | 12 import TestGyp |
| 13 import string | 13 import string |
| 14 import subprocess | 14 import subprocess |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 | 17 |
| 18 if sys.platform == 'win32': | 18 if sys.platform == 'win32': |
| 19 import win32api | 19 import win32api |
| 20 | 20 |
| 21 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) | 21 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) |
| 22 | 22 |
| 23 def GetFirstFreeDriveLetter(): | 23 def GetFirstFreeDriveLetter(): |
| 24 """ Returns the first unused Windows drive letter in [A, Z] """ | 24 """ Returns the first unused Windows drive letter in [A, Z] """ |
| 25 all_letters = [c for c in string.uppercase] | 25 all_letters = [c for c in string.ascii_uppercase] |
| 26 in_use = win32api.GetLogicalDriveStrings() | 26 in_use = win32api.GetLogicalDriveStrings() |
| 27 free = list(set(all_letters) - set(in_use)) | 27 free = list(set(all_letters) - set(in_use)) |
| 28 return free[0] | 28 return free[0] |
| 29 | 29 |
| 30 output_dir = os.path.join('different-drive', 'output') | 30 output_dir = os.path.join('different-drive', 'output') |
| 31 if not os.path.isdir(os.path.abspath(output_dir)): | 31 if not os.path.isdir(os.path.abspath(output_dir)): |
| 32 os.makedirs(os.path.abspath(output_dir)) | 32 os.makedirs(os.path.abspath(output_dir)) |
| 33 output_drive = GetFirstFreeDriveLetter() | 33 output_drive = GetFirstFreeDriveLetter() |
| 34 subprocess.call(['subst', '%c:' % output_drive, os.path.abspath(output_dir)]) | 34 subprocess.call(['subst', '%c:' % output_drive, os.path.abspath(output_dir)]) |
| 35 try: | 35 try: |
| 36 test.run_gyp('prog.gyp', '--generator-output=%s' % ( | 36 test.run_gyp('prog.gyp', '--generator-output=%s' % ( |
| 37 os.path.join(output_drive, 'output'))) | 37 os.path.join(output_drive, 'output'))) |
| 38 test.build('prog.gyp', test.ALL, chdir=os.path.join(output_drive, 'output')) | 38 test.build('prog.gyp', test.ALL, chdir=os.path.join(output_drive, 'output')) |
| 39 test.built_file_must_exist('program', chdir=os.path.join(output_drive, | 39 test.built_file_must_exist('program', chdir=os.path.join(output_drive, |
| 40 'output'), | 40 'output'), |
| 41 type=test.EXECUTABLE) | 41 type=test.EXECUTABLE) |
| 42 test.pass_test() | 42 test.pass_test() |
| 43 finally: | 43 finally: |
| 44 subprocess.call(['subst', '%c:' % output_drive, '/D']) | 44 subprocess.call(['subst', '%c:' % output_drive, '/D']) |
| OLD | NEW |