Skip to content

Commit 522ac1c

Browse files
adamreicholdmessense
authored andcommitted
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 <[email protected]>
1 parent 47540b8 commit 522ac1c

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,58 @@ jobs:
318318
# 1.49.
319319
CARGO_PRIMARY_PACKAGE: 1
320320

321+
valgrind:
322+
needs: [fmt]
323+
runs-on: ubuntu-latest
324+
steps:
325+
- uses: actions/checkout@v3
326+
- uses: actions/setup-python@v4
327+
with:
328+
python-version: "3.10"
329+
- uses: Swatinem/rust-cache@v1
330+
with:
331+
key: cargo-valgrind
332+
continue-on-error: true
333+
- uses: actions-rs/toolchain@v1
334+
with:
335+
# FIXME(adamreichold): Switch to stable when Valgrind understands DWARF5 as generated by LLVM 14,
336+
# c.f. https://bugs.kde.org/show_bug.cgi?id=452758#c35
337+
toolchain: 1.61.0
338+
override: true
339+
profile: minimal
340+
- uses: taiki-e/install-action@valgrind
341+
- run: python -m pip install -U pip nox
342+
- run: nox -s test-rust -- release skip-full
343+
env:
344+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --leak-check=no --error-exitcode=1
345+
RUST_BACKTRACE: 1
346+
TRYBUILD: overwrite
347+
348+
careful:
349+
needs: [fmt]
350+
runs-on: ubuntu-latest
351+
steps:
352+
- uses: actions/checkout@v3
353+
- uses: actions/setup-python@v4
354+
with:
355+
python-version: "3.10"
356+
- uses: Swatinem/rust-cache@v1
357+
with:
358+
key: cargo-careful
359+
continue-on-error: true
360+
- uses: actions-rs/toolchain@v1
361+
with:
362+
toolchain: nightly
363+
override: true
364+
profile: minimal
365+
components: rust-src
366+
- run: cargo install cargo-careful
367+
- run: python -m pip install -U pip nox
368+
- run: nox -s test-rust -- careful skip-full
369+
env:
370+
RUST_BACKTRACE: 1
371+
TRYBUILD: overwrite
372+
321373
coverage:
322374
needs: [fmt]
323375
name: coverage-${{ matrix.os }}

noxfile.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def test_rust(session: nox.Session):
2727

2828
_run_cargo_test(session)
2929
_run_cargo_test(session, features="abi3")
30-
_run_cargo_test(session, features="full")
31-
_run_cargo_test(session, features="abi3 full")
30+
if not "skip-full" in session.posargs:
31+
_run_cargo_test(session, features="full")
32+
_run_cargo_test(session, features="abi3 full")
3233

3334

3435
@nox.session(name="test-py", venv_backend="none")
@@ -235,6 +236,7 @@ def address_sanitizer(session: nox.Session):
235236
"cargo",
236237
"+nightly",
237238
"test",
239+
"-Zbuild-std",
238240
f"--target={_get_rust_target()}",
239241
"--",
240242
"--test-threads=1",
@@ -289,7 +291,12 @@ def _run_cargo_test(
289291
package: Optional[str] = None,
290292
features: Optional[str] = None,
291293
) -> None:
292-
command = ["cargo", "test"]
294+
command = ["cargo"]
295+
if "careful" in session.posargs:
296+
command.append("careful")
297+
command.append("test")
298+
if "release" in session.posargs:
299+
command.append("--release")
293300
if package:
294301
command.append(f"--package={package}")
295302
if features:

0 commit comments

Comments
 (0)