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""" 8Test that the generator output can be written to a different drive on Windows. 9""" 10 11import os 12import TestGyp 13import string 14import subprocess 15import sys 16 17 18if 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