Skip to content

Commit

Permalink
Run Rust tests using Valgrind and cargo-careful (#2706)
Browse files Browse the repository at this point in the history
* Run asan with `-Zbuild-std`

* Run Rust tests using Valgrind and cargo-careful.

* Pin Valgrind task to 1.61.0 to avoid the DWARF5 issues until fixed upstream.

* Override output checking of compilation UI tests as using different Rust versions might break that.

Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
2 people authored and davidhewitt committed Oct 30, 2022
1 parent 47540b8 commit 522ac1c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
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

0 comments on commit 522ac1c

Please sign in to comment.