1
1
#!/usr/bin/env python3
2
2
3
3
import argparse
4
- import logging
5
4
import os
5
+ import pathlib
6
6
import subprocess
7
7
import sys
8
8
import tempfile
9
9
10
- PARENT_DIR = os .path .dirname (os .path .abspath (__file__ ))
10
+ PARENT_DIR = pathlib . Path ( os .path .dirname (os .path .abspath (__file__ ) ))
11
11
12
12
LIT_CONFIG_FILE = """
13
13
#
@@ -37,7 +37,7 @@ libcxx.test.config.configure(
37
37
38
38
def directory_path (string ):
39
39
if os .path .isdir (string ):
40
- return string
40
+ return pathlib . Path ( string )
41
41
else :
42
42
raise NotADirectoryError (string )
43
43
@@ -50,14 +50,14 @@ def main(argv):
50
50
'performance data, bisect issues, and so on. '
51
51
'A current limitation of this script is that it assumes the arguments passed to CMake when '
52
52
'building the library.' )
53
- parser .add_argument ('--build' , '-B' , type = str , required = True ,
53
+ parser .add_argument ('--build' , '-B' , type = pathlib . Path , required = True ,
54
54
help = 'Path to create the build directory for running the test suite at.' )
55
55
parser .add_argument ('--commit' , type = str , required = True ,
56
56
help = 'Commit to build libc++ at.' )
57
57
parser .add_argument ('lit_options' , nargs = argparse .REMAINDER ,
58
58
help = 'Optional arguments passed to lit when running the tests. Should be provided last and '
59
59
'separated from other arguments with a `--`.' )
60
- parser .add_argument ('--git-repo' , type = directory_path , default = os .getcwd (),
60
+ parser .add_argument ('--git-repo' , type = directory_path , default = pathlib . Path ( os .getcwd () ),
61
61
help = 'Optional path to the Git repository to use. By default, the current working directory is used.' )
62
62
args = parser .parse_args (argv )
63
63
@@ -70,26 +70,26 @@ def main(argv):
70
70
71
71
with tempfile .TemporaryDirectory () as install_dir :
72
72
# Build the library at the baseline
73
- build_cmd = [os . path . join ( PARENT_DIR , 'build-at-commit' ) , '--git-repo' , args .git_repo ,
74
- '--install-dir' , install_dir ,
75
- '--commit' , args .commit ]
73
+ build_cmd = [PARENT_DIR / 'build-at-commit' , '--git-repo' , args .git_repo ,
74
+ '--install-dir' , install_dir ,
75
+ '--commit' , args .commit ]
76
76
build_cmd += ['--' , '-DCMAKE_BUILD_TYPE=RelWithDebInfo' ]
77
77
subprocess .check_call (build_cmd )
78
78
79
79
# Configure the test suite in the specified build directory
80
- os . makedirs ( args .build )
81
- lit_cfg = os . path . abspath ( os . path . join ( args .build , 'temp_lit_cfg.cfg.in' ))
80
+ args .build . mkdir ( parents = True , exist_ok = True )
81
+ lit_cfg = ( args .build / 'temp_lit_cfg.cfg.in' ). absolute ( )
82
82
with open (lit_cfg , 'w' ) as f :
83
83
f .write (LIT_CONFIG_FILE .format (INSTALL_ROOT = install_dir ))
84
84
85
- test_suite_cmd = ['cmake' , '-B' , args .build , '-S' , os . path . join ( args .git_repo , 'runtimes' ) , '-G' , 'Ninja' ]
85
+ test_suite_cmd = ['cmake' , '-B' , args .build , '-S' , args .git_repo / 'runtimes' , '-G' , 'Ninja' ]
86
86
test_suite_cmd += ['-D' , 'LLVM_ENABLE_RUNTIMES=libcxx;libcxxabi' ]
87
87
test_suite_cmd += ['-D' , 'LIBCXXABI_USE_LLVM_UNWINDER=OFF' ]
88
88
test_suite_cmd += ['-D' , f'LIBCXX_TEST_CONFIG={ lit_cfg } ' ]
89
89
subprocess .check_call (test_suite_cmd )
90
90
91
91
# Run the specified tests against the produced baseline installation
92
- lit_cmd = [os . path . join ( PARENT_DIR , 'libcxx-lit' ) , args .build ] + lit_options
92
+ lit_cmd = [PARENT_DIR / 'libcxx-lit' , args .build ] + lit_options
93
93
subprocess .check_call (lit_cmd )
94
94
95
95
if __name__ == '__main__' :
0 commit comments