Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add update-ui-tests nox session #3979

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 20 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -816,9 +826,16 @@ def _run(session: nox.Session, *args: str, **kwargs: Any) -> None:
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:
if is_github_actions:
command = " ".join(args)
print(f"::error::`{command}` failed", file=sys.stderr)
raise
finally:
if is_github_actions:
print("::endgroup::", file=sys.stderr)


def _run_cargo(
Expand Down
Loading