Merge branch 'environment' of github.com:joerick/cibuildwheel into environment
* 'environment' of github.com:joerick/cibuildwheel: Making call from run_tests to run_test subprocess.check_call Fixing 'ValueError: Attempted relative import in non-package' Reducing code duplication in bin/run_test.py and bin/run_tests.py
This commit is contained in:
+17
-17
@@ -1,23 +1,10 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os, sys, subprocess, shutil, json, argparse
|
import os, sys, subprocess, shutil, json
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
def main():
|
def single_run(test_project):
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("test_project_dir")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
test_project = os.path.abspath(args.test_project_dir)
|
|
||||||
|
|
||||||
# move cwd to the project root
|
|
||||||
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
||||||
|
|
||||||
if not os.path.exists(test_project):
|
|
||||||
print('No test project not found.', file=sys.stderr)
|
|
||||||
exit(2)
|
|
||||||
|
|
||||||
# load project settings into environment
|
# load project settings into environment
|
||||||
env_file = os.path.join(test_project, 'environment.json')
|
env_file = os.path.join(test_project, 'environment.json')
|
||||||
project_env = {}
|
project_env = {}
|
||||||
@@ -40,6 +27,19 @@ def main():
|
|||||||
# clean up
|
# clean up
|
||||||
shutil.rmtree('wheelhouse')
|
shutil.rmtree('wheelhouse')
|
||||||
|
|
||||||
print('Project built successfully.')
|
if __name__ == '__main__':
|
||||||
|
import argparse
|
||||||
|
|
||||||
main()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("test_project_dir")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
project_path = os.path.abspath(args.test_project_dir)
|
||||||
|
|
||||||
|
if not os.path.exists(project_path):
|
||||||
|
print('No test project not found.', file=sys.stderr)
|
||||||
|
exit(2)
|
||||||
|
|
||||||
|
single_run(project_path)
|
||||||
|
|
||||||
|
print('Project built successfully.')
|
||||||
|
|||||||
+13
-31
@@ -4,44 +4,26 @@ from __future__ import print_function
|
|||||||
import os, sys, subprocess, shutil, json
|
import os, sys, subprocess, shutil, json
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
# move cwd to the project root
|
if __name__ == '__main__':
|
||||||
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
# move cwd to the project root
|
||||||
|
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
### run the unit tests
|
### run the unit tests
|
||||||
|
|
||||||
subprocess.check_call(['python', '-m', 'pytest', 'unit_test'])
|
subprocess.check_call(['python', '-m', 'pytest', 'unit_test'])
|
||||||
|
|
||||||
### run the integration tests
|
### run the integration tests
|
||||||
|
|
||||||
test_projects = glob('test/??_*')
|
test_projects = glob('test/??_*')
|
||||||
|
|
||||||
if len(test_projects) == 0:
|
if len(test_projects) == 0:
|
||||||
print('No test projects found. Aborting.', file=sys.stderr)
|
print('No test projects found. Aborting.', file=sys.stderr)
|
||||||
exit(2)
|
exit(2)
|
||||||
|
|
||||||
print('Testing projects:', test_projects)
|
print('Testing projects:', test_projects)
|
||||||
|
|
||||||
for project_path in test_projects:
|
run_test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'run_test.py')
|
||||||
# load project settings into environment
|
for project_path in test_projects:
|
||||||
env_file = os.path.join(project_path, 'environment.json')
|
subprocess.check_call([sys.executable, run_test_path, project_path])
|
||||||
project_env = {}
|
|
||||||
if os.path.exists(env_file):
|
|
||||||
with open(env_file) as f:
|
|
||||||
project_env = json.load(f)
|
|
||||||
|
|
||||||
# run the build
|
print('%d projects built successfully.' % len(test_projects))
|
||||||
env = os.environ.copy()
|
|
||||||
project_env = {str(k): str(v) for k, v in project_env.items()} # unicode not allowed in env
|
|
||||||
env.update(project_env)
|
|
||||||
print('Building %s with environment %s' % (project_path, project_env))
|
|
||||||
subprocess.check_call(['cibuildwheel', project_path], env=env)
|
|
||||||
wheels = glob('wheelhouse/*.whl')
|
|
||||||
print('%s built successfully. %i wheels built.' % (project_path, len(wheels)))
|
|
||||||
|
|
||||||
# check some wheels were actually built
|
|
||||||
assert len(wheels) >= 4
|
|
||||||
|
|
||||||
# clean up
|
|
||||||
shutil.rmtree('wheelhouse')
|
|
||||||
|
|
||||||
print('%d projects built successfully.' % len(test_projects))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user