Skip to content

Commit 993d1e1

Browse files
committed
chore(tests): limit number of builds in test_before_all
1 parent 29e56b5 commit 993d1e1

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

test/test_before_all.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,22 @@
1010
project_with_before_build_asserts = test_projects.new_c_project(
1111
setup_py_add=textwrap.dedent(
1212
r"""
13-
# assert that the Python version as written to text_info.txt in the CIBW_BEFORE_ALL step
14-
# is the same one as is currently running.
13+
import os
14+
1515
with open("text_info.txt") as f:
1616
stored_text = f.read()
17-
1817
print("## stored text: " + stored_text)
1918
assert stored_text == "sample text 123"
19+
20+
# assert that the Python version as written to python_prefix.txt in the CIBW_BEFORE_ALL step
21+
# is not the same one as is currently running.
22+
with open('python_prefix.txt') as f:
23+
stored_prefix = f.read()
24+
print('stored_prefix', stored_prefix)
25+
print('sys.prefix', sys.prefix)
26+
# Works around path-comparison bugs caused by short-paths on Windows e.g.
27+
# vssadm~1 instead of vssadministrator
28+
assert os.stat(stored_prefix) != os.stat(sys.prefix)
2029
"""
2130
)
2231
)
@@ -30,21 +39,24 @@ def test(tmp_path):
3039
print("dummy text", file=ff)
3140

3241
# build the wheels
33-
before_all_command = '''python -c "import os;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))"'''
42+
before_all_command = (
43+
"""python -c "import os, sys;open('{project}/text_info.txt', 'w').write('sample text '+os.environ.get('TEST_VAL', ''))" && """
44+
'''python -c "import sys; open('{project}/python_prefix.txt', 'w').write(sys.prefix)"'''
45+
)
3446
actual_wheels = utils.cibuildwheel_run(
3547
project_dir,
3648
add_env={
3749
# write python version information to a temporary file, this is
3850
# checked in setup.py
3951
"CIBW_BEFORE_ALL": before_all_command,
40-
"CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 6)"',
52+
"CIBW_BEFORE_ALL_LINUX": f'{before_all_command} && python -c "import sys; assert sys.version_info >= (3, 8)"',
4153
"CIBW_ENVIRONMENT": "TEST_VAL='123'",
4254
},
55+
single_python=True,
4356
)
4457

4558
# also check that we got the right wheels
46-
(project_dir / "text_info.txt").unlink()
47-
expected_wheels = utils.expected_wheels("spam", "0.1.0")
59+
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
4860
assert set(actual_wheels) == set(expected_wheels)
4961

5062

0 commit comments

Comments
 (0)