Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/win/generator-output-different-drive/gyptest-generator-output-different-drive.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698