diff --git a/bin/dev_run_test b/bin/dev_run_test index 6515c6b3..85a0d81c 100755 --- a/bin/dev_run_test +++ b/bin/dev_run_test @@ -1,3 +1,3 @@ #!/bin/bash -CIBW_PLATFORM=linux pytest $1 +CIBW_PLATFORM=linux pytest "$@" diff --git a/bin/run_tests.py b/bin/run_tests.py index e3275f3f..93c23e88 100755 --- a/bin/run_tests.py +++ b/bin/run_tests.py @@ -12,4 +12,4 @@ if __name__ == '__main__': subprocess.check_call([sys.executable, '-m', 'pytest', 'unit_test']) # run the integration tests - subprocess.check_call([sys.executable, '-m', 'pytest', '--durations', '0', 'test']) + subprocess.check_call([sys.executable, '-m', 'pytest', '-x', '--durations', '0', 'test']) diff --git a/test/template_projects/base.py b/test/template_projects/base.py index 2daf53a8..66e7acbc 100644 --- a/test/template_projects/base.py +++ b/test/template_projects/base.py @@ -21,7 +21,7 @@ class TemplateProject: file_path = os.path.join(path, filename) os.makedirs(os.path.dirname(file_path), exist_ok=True) - with io.open(file_path, 'w', encoding='utf8') as f: + with open(file_path, 'w', encoding='utf8') as f: if isinstance(content, jinja2.Template): content = content.render(self.template_context) diff --git a/test/test_0_basic.py b/test/test_0_basic.py index 5bf16822..a38c1180 100644 --- a/test/test_0_basic.py +++ b/test/test_0_basic.py @@ -21,7 +21,7 @@ def test(tmp_path): actual_wheels = utils.cibuildwheel_run(project_dir) # check that the expected wheels are produced - expected_wheels = utils.expected_wheels("spam", "0.1.0") + expected_wheels = utils.expected_wheels('spam', '0.1.0') assert set(actual_wheels) == set(expected_wheels) diff --git a/test/test_cpp_standards.py b/test/test_cpp_standards.py index b930acee..7dbca41a 100644 --- a/test/test_cpp_standards.py +++ b/test/test_cpp_standards.py @@ -72,15 +72,18 @@ MOD_INIT(spam) ''') +cpp11_project = cpp_template_project.copy() +cpp11_project.template_context['extra_compile_args'] = ( + ['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11'] +) +cpp11_project.template_context['spam_cpp_top_level_add'] = '#include ' + + def test_cpp11(tmp_path): # This test checks that the C++11 standard is supported project_dir = tmp_path / 'project' - project = cpp_template_project.copy() - extra_compile_args = ['/std:c++11'] if utils.platform == 'windows' else ['-std=c++11'] - project.template_context['extra_compile_args'] = extra_compile_args - project.template_context['spam_cpp_top_level_add'] = '#include ' - project.generate(project_dir) + cpp11_project.generate(project_dir) # VC++ for Python 2.7 does not support modern standards add_env = {'CIBW_SKIP': 'cp27-win* pp27-win32'} @@ -92,15 +95,18 @@ def test_cpp11(tmp_path): assert set(actual_wheels) == set(expected_wheels) +cpp14_project = cpp_template_project.copy() +cpp14_project.template_context['extra_compile_args'] = ( + ['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14'] +) +cpp14_project.template_context['spam_cpp_top_level_add'] = "int a = 100'000;" + + def test_cpp14(tmp_path): # This test checks that the C++14 standard is supported project_dir = tmp_path / 'project' - project = cpp_template_project.copy() - extra_compile_args = ['/std:c++14'] if utils.platform == 'windows' else ['-std=c++14'] - project.template_context['extra_compile_args'] = extra_compile_args - project.template_context['spam_cpp_top_level_add'] = "int a = 100'000;" - project.generate(project_dir) + cpp14_project.generate(project_dir) # VC++ for Python 2.7 does not support modern standards # The manylinux1 docker image does not have a compiler which supports C++11 @@ -115,12 +121,9 @@ def test_cpp14(tmp_path): cpp17_project = cpp_template_project.copy() - -if utils.platform == 'windows': - cpp17_project.template_context['extra_compile_args'] = ['/std:c++17', '/wd5033'] -else: - cpp17_project.template_context['extra_compile_args'] = ['-std=c++17', '-Wno-register'] - +cpp17_project.template_context['extra_compile_args'] = ( + ['/std:c++17', '/wd5033'] if utils.platform == 'windows' else ['-std=c++17', '-Wno-register'] +) cpp17_project.template_context['spam_cpp_top_level_add'] = r''' #include auto a = std::pair(5.0, false); diff --git a/test/test_ssl.py b/test/test_ssl.py index eddb4074..18b9ebb6 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -28,4 +28,7 @@ def test(tmp_path): project_dir = tmp_path / 'project' project_with_ssl_tests.generate(project_dir) - utils.cibuildwheel_run(project_dir) + actual_wheels = utils.cibuildwheel_run(project_dir) + + expected_wheels = utils.expected_wheels('spam', '0.1.0') + assert set(actual_wheels) == set(expected_wheels) diff --git a/test/utils.py b/test/utils.py index 1c2733c6..609ab9d7 100644 --- a/test/utils.py +++ b/test/utils.py @@ -33,7 +33,7 @@ def cibuildwheel_get_build_identifiers(project_path, env=None): for the current platform. ''' cmd_output = subprocess.check_output( - [sys.executable, '-m', 'cibuildwheel', '--print-build-identifiers', str(project_path)], + [sys.executable, '-m', 'cibuildwheel', '--print-build-identifiers', project_path], universal_newlines=True, env=env, )