ci: add `update-ui-tests` nox session (#3979)
* ci: add `update-ui-tests` nox session * defer error messages after the group closes * fix syntax warnings
This commit is contained in:
parent
20e477a7cd
commit
9808f7111c
|
@ -101,10 +101,17 @@ Tests run with all supported Python versions with the latest stable Rust compile
|
|||
If you are adding a new feature, you should add it to the `full` feature in our *Cargo.toml** so that it is tested in CI.
|
||||
|
||||
You can run these tests yourself with
|
||||
```nox```
|
||||
and
|
||||
```nox -l```
|
||||
lists further commands you can run.
|
||||
`nox`. Use `nox -l` to list the full set of subcommands you can run.
|
||||
|
||||
#### UI Tests
|
||||
|
||||
PyO3 uses [`trybuild`][trybuild] to develop UI tests to capture error messages from the Rust compiler for some of the macro functionality.
|
||||
|
||||
Because there are several feature combinations for these UI tests, when updating them all (e.g. for a new Rust compiler version) it may be helpful to use the `update-ui-tests` nox session:
|
||||
|
||||
```bash
|
||||
nox -s update-ui-tests
|
||||
```
|
||||
|
||||
### Documenting changes
|
||||
|
||||
|
|
31
noxfile.py
31
noxfile.py
|
@ -395,8 +395,8 @@ def check_guide(session: nox.Session):
|
|||
session.posargs.extend(posargs)
|
||||
|
||||
remaps = {
|
||||
f"file://{PYO3_GUIDE_SRC}/([^/]*/)*?%7B%7B#PYO3_DOCS_URL\}}\}}": f"file://{PYO3_DOCS_TARGET}",
|
||||
"%7B%7B#PYO3_DOCS_VERSION\}\}": "latest",
|
||||
f"file://{PYO3_GUIDE_SRC}/([^/]*/)*?%7B%7B#PYO3_DOCS_URL}}}}": f"file://{PYO3_DOCS_TARGET}",
|
||||
"%7B%7B#PYO3_DOCS_VERSION}}": "latest",
|
||||
}
|
||||
remap_args = []
|
||||
for key, value in remaps.items():
|
||||
|
@ -732,6 +732,16 @@ def check_feature_powerset(session: nox.Session):
|
|||
)
|
||||
|
||||
|
||||
@nox.session(name="update-ui-tests", venv_backend="none")
|
||||
def update_ui_tests(session: nox.Session):
|
||||
env = os.environ.copy()
|
||||
env["TRYBUILD"] = "overwrite"
|
||||
command = ["test", "--test", "test_compile_error"]
|
||||
_run_cargo(session, *command, env=env)
|
||||
_run_cargo(session, *command, "--features=full", env=env)
|
||||
_run_cargo(session, *command, "--features=abi3,full", env=env)
|
||||
|
||||
|
||||
def _build_docs_for_ffi_check(session: nox.Session) -> None:
|
||||
# pyo3-ffi-check needs to scrape docs of pyo3-ffi
|
||||
_run_cargo(session, "doc", _FFI_CHECK, "-p", "pyo3-ffi", "--no-deps")
|
||||
|
@ -813,12 +823,23 @@ def _get_coverage_env() -> Dict[str, str]:
|
|||
def _run(session: nox.Session, *args: str, **kwargs: Any) -> None:
|
||||
"""Wrapper for _run(session, which creates nice groups on GitHub Actions."""
|
||||
is_github_actions = _is_github_actions()
|
||||
failed = False
|
||||
if is_github_actions:
|
||||
# Insert ::group:: at the start of nox's command line output
|
||||
print("::group::", end="", flush=True, file=sys.stderr)
|
||||
session.run(*args, **kwargs)
|
||||
if is_github_actions:
|
||||
print("::endgroup::", file=sys.stderr)
|
||||
try:
|
||||
session.run(*args, **kwargs)
|
||||
except nox.command.CommandFailed:
|
||||
failed = True
|
||||
raise
|
||||
finally:
|
||||
if is_github_actions:
|
||||
print("::endgroup::", file=sys.stderr)
|
||||
# Defer the error message until after the group to make them easier
|
||||
# to find in the log
|
||||
if failed:
|
||||
command = " ".join(args)
|
||||
print(f"::error::`{command}` failed", file=sys.stderr)
|
||||
|
||||
|
||||
def _run_cargo(
|
||||
|
|
Loading…
Reference in New Issue