Android test updates (#2575)
* Install the test environment while simulating Android * Pass build-verbosity setting through to the test runner
This commit is contained in:
@@ -589,7 +589,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.
|
||||
@@ -641,6 +641,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,
|
||||
)
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -318,6 +318,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()
|
||||
|
||||
Reference in New Issue
Block a user