Skip to content

Commit

Permalink
Run Rust tests using Valgrind and cargo-careful.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Oct 24, 2022
1 parent 9203ac5 commit 99eeac3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,56 @@ jobs:
# 1.49.
CARGO_PRIMARY_PACKAGE: 1

valgrind:
needs: [fmt]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: Swatinem/rust-cache@v1
with:
key: valgrind-cargo
continue-on-error: true
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- uses: taiki-e/install-action@valgrind
- run: python -m pip install -U pip nox
# FIXME(adamreichold): Drop skip-macros when Valgrind understands DWARF5 as generated by LLVM 14,
# c.f. https://bugs.kde.org/show_bug.cgi?id=452758#c35
- run: nox -s test-rust -- release skip-full skip-macros
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1
RUST_BACKTRACE: 1

careful:
needs: [fmt]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: Swatinem/rust-cache@v1
with:
key: careful-cargo
continue-on-error: true
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: rust-src
- run: cargo install cargo-careful
- run: python -m pip install -U pip nox
- run: nox -s test-rust -- careful skip-full
env:
RUST_BACKTRACE: 1

coverage:
needs: [fmt]
name: coverage-${{ matrix.os }}
Expand Down
17 changes: 12 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ def test(session: nox.Session) -> None:
@nox.session(name="test-rust", venv_backend="none")
def test_rust(session: nox.Session):
_run_cargo_test(session, package="pyo3-build-config")
_run_cargo_test(session, package="pyo3-macros-backend")
_run_cargo_test(session, package="pyo3-macros")
if not "skip-macros" in session.posargs:
_run_cargo_test(session, package="pyo3-macros-backend")
_run_cargo_test(session, package="pyo3-macros")
_run_cargo_test(session, package="pyo3-ffi")

_run_cargo_test(session)
_run_cargo_test(session, features="abi3")
_run_cargo_test(session, features="full")
_run_cargo_test(session, features="abi3 full")
if not "skip-full" in session.posargs:
_run_cargo_test(session, features="full")
_run_cargo_test(session, features="abi3 full")


@nox.session(name="test-py", venv_backend="none")
Expand Down Expand Up @@ -290,7 +292,12 @@ def _run_cargo_test(
package: Optional[str] = None,
features: Optional[str] = None,
) -> None:
command = ["cargo", "test"]
command = ["cargo"]
if "careful" in session.posargs:
command.append("careful")
command.append("test")
if "release" in session.posargs:
command.append("--release")
if package:
command.append(f"--package={package}")
if features:
Expand Down

0 comments on commit 99eeac3

Please sign in to comment.