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

RFC: Run Rust tests using Valgrind and cargo-careful #2706

Merged
merged 4 commits into from
Oct 28, 2022
Merged
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
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,58 @@ 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: cargo-valgrind
continue-on-error: true
- uses: actions-rs/toolchain@v1
with:
# FIXME(adamreichold): Switch to stable when Valgrind understands DWARF5 as generated by LLVM 14,
# c.f. https://bugs.kde.org/show_bug.cgi?id=452758#c35
toolchain: 1.61.0
override: true
profile: minimal
- uses: taiki-e/install-action@valgrind
- run: python -m pip install -U pip nox
- run: nox -s test-rust -- release skip-full
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1
RUST_BACKTRACE: 1
TRYBUILD: overwrite

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: cargo-careful
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
TRYBUILD: overwrite

coverage:
needs: [fmt]
name: coverage-${{ matrix.os }}
Expand Down
13 changes: 10 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ def test_rust(session: nox.Session):

_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 @@ -235,6 +236,7 @@ def address_sanitizer(session: nox.Session):
"cargo",
"+nightly",
"test",
"-Zbuild-std",
f"--target={_get_rust_target()}",
"--",
"--test-threads=1",
Expand Down Expand Up @@ -289,7 +291,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