Skip to content
Open
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
3 changes: 2 additions & 1 deletion cibuildwheel/platforms/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def test_wheel(state: BuildState, wheel: Path) -> None:
site_packages_dir,
f"{wheel}{state.options.test_extras}",
*state.options.test_requires,
env=state.build_env,
env=state.android_env,
)

# Copy test-sources.
Expand Down Expand Up @@ -630,6 +630,7 @@ def test_wheel(state: BuildState, wheel: Path) -> None:
site_packages_dir,
"--cwd",
cwd_dir,
*(["-v"] if state.options.build_verbosity > 0 else []),
*test_args,
env=state.build_env,
)
Expand Down
3 changes: 3 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,9 @@ Settings that are not supported for a specific frontend will log a warning.
The default build frontend is `build`, which does show build backend output by
default.

On Android and iOS, a positive verbosity level will also show more detailed logs from
the test harness.

Platform-specific environment variables are also available:<br/>
`CIBW_BUILD_VERBOSITY_MACOS` | `CIBW_BUILD_VERBOSITY_WINDOWS` | `CIBW_BUILD_VERBOSITY_LINUX` | `CIBW_BUILD_VERBOSITY_ANDROID` | `CIBW_BUILD_VERBOSITY_IOS` | `CIBW_BUILD_VERBOSITY_PYODIDE`

Expand Down
65 changes: 65 additions & 0 deletions test/test_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,71 @@ def test_no_test_sources(tmp_path, capfd):
) in capfd.readouterr().err


@needs_emulator
def test_environment_markers(tmp_path):
project = new_c_project()
test_filename = "test_environment_markers.py"
project.files[test_filename] = dedent(
"""\
import pytest

def test_android():
import certifi

def test_not_android():
try:
import platformdirs
except ImportError:
pass
else:
pytest.fail("`platformdirs` should not have been installed")
"""
)
project.generate(tmp_path)

cibuildwheel_run(
tmp_path,
add_env={
**cp313_env,
"CIBW_TEST_COMMAND": f"python -m pytest {test_filename}",
"CIBW_TEST_SOURCES": test_filename,
"CIBW_TEST_REQUIRES": " ".join(
[
"pytest",
"certifi;sys_platform=='android'",
"platformdirs;sys_platform!='android'",
]
),
},
)


@needs_emulator
def test_verbosity(tmp_path, capfd):
new_c_project().generate(tmp_path)
test_env = {
**cp313_env,
"CIBW_TEST_COMMAND": """python -c 'print("Hello world")'""",
}
verbose_lines = [
"> Task :app:packageDebug", # Gradle
"I/TestRunner: run started: 1 tests", # Logcat
]

cibuildwheel_run(tmp_path, add_env=test_env)
stdout = capfd.readouterr().out
for line in verbose_lines:
assert line not in stdout

cibuildwheel_run(
tmp_path,
add_env={**test_env, "CIBW_BUILD_VERBOSITY": "1"},
)
stdout = capfd.readouterr().out
for line in verbose_lines:
assert line in stdout


@needs_emulator
def test_api_level(tmp_path, capfd):
project = new_c_project()
Expand Down
Loading