From 522ac1c1583e366b42afc0c78c331d3aa91f4763 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Fri, 28 Oct 2022 22:04:11 +0200 Subject: [PATCH] Run Rust tests using Valgrind and cargo-careful (#2706) * 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 --- .github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++ noxfile.py | 13 +++++++--- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b611a26c197..1ea3043c8c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/noxfile.py b/noxfile.py index 7fd157ac6e1..9f37de47879 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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") @@ -235,6 +236,7 @@ def address_sanitizer(session: nox.Session): "cargo", "+nightly", "test", + "-Zbuild-std", f"--target={_get_rust_target()}", "--", "--test-threads=1", @@ -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: