Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cibuildwheel/platforms/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ def test_wheel(state: BuildState, wheel: Path) -> None:

# Parse test-command.
test_args = shlex.split(test_command)
if test_args[:2] in [["python", "-c"], ["python", "-m"]]:
test_args[:3] = [test_args[1], test_args[2], "--"]
if test_args[0] == "python" and any(arg in test_args for arg in ["-c", "-m"]):
del test_args[0]
elif test_args[0] in ["pytest"]:
# We transform some commands into the `python -m` form, but this is deprecated.
msg = (
Expand All @@ -623,7 +623,7 @@ def test_wheel(state: BuildState, wheel: Path) -> None:
"If this works, all you need to do is add that to your test command."
)
log.warning(msg)
test_args[:1] = ["-m", test_args[0], "--"]
test_args[:1] = ["-m", test_args[0]]
else:
msg = (
f"Test command {test_command!r} is not supported on Android. "
Expand All @@ -642,6 +642,7 @@ def test_wheel(state: BuildState, wheel: Path) -> None:
"--cwd",
cwd_dir,
*(["-v"] if state.options.build_verbosity > 0 else []),
"--",
*test_args,
env=state.build_env,
)
Expand Down
28 changes: 28 additions & 0 deletions test/test_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ def test_test_command_good(command, expected_output, tmp_path, spam_env, capfd):
"Test command './test_spam.py' is not supported on Android. "
"Supported commands are 'python -m' and 'python -c'.",
),
(
"python test_spam.py",
"Test command 'python test_spam.py' is not supported on Android. "
"Supported commands are 'python -m' and 'python -c'.",
),
# Build-time failure: unrecognized placeholder
(
"pytest {project}",
Expand All @@ -283,6 +288,29 @@ def test_test_command_bad(command, expected_output, tmp_path, spam_env, capfd):
assert expected_output in capfd.readouterr().err


@needs_emulator
@pytest.mark.parametrize(
("options", "expected"),
[
("", 0),
("-E", 1),
],
)
def test_test_command_python_options(options, expected, tmp_path, capfd):
project = new_c_project()
project.generate(tmp_path)

command = 'import sys; print(f"{sys.flags.ignore_environment=}")'
cibuildwheel_run(
tmp_path,
add_env={
**cp313_env,
"CIBW_TEST_COMMAND": f"python {options} -c '{command}'",
},
)
assert f"sys.flags.ignore_environment={expected}" in capfd.readouterr().out


@needs_emulator
def test_package_subdir(tmp_path, spam_env, capfd):
spam_paths = list(tmp_path.iterdir())
Expand Down
Loading