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