summaryrefslogtreecommitdiff
path: root/rust/coverage_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-02-11 14:58:07 -0800
committer Colin Cross <ccross@android.com> 2025-02-12 10:36:48 -0800
commit90607e9056f6ff4cec2447fdd7a8b252d67ffde7 (patch)
treed4e244bc76e8e13a8438bcd921fd9003bce46730 /rust/coverage_test.go
parentd8db8faba62a3cb77f75294e96deda9e53c15786 (diff)
Don't panic in ModuleForTests and friends
Panicking in ModuleForTests and similar test helper functions was a mistake. Go's test runner stops running tests as soon as any test panics, which means debugging multiple tests panicking requires rerunning all the tests after fixing each panic to find the next one. Pass the *testing.T into ModuleForTests and friends so that it can call t.Fatalf instead. Test: all soong tests pass Change-Id: I5d0f2424eaf04fb795079e6d1e4b9469d8c7033c
Diffstat (limited to 'rust/coverage_test.go')
-rw-r--r--rust/coverage_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/rust/coverage_test.go b/rust/coverage_test.go
index 0f599d745..f9198f1f0 100644
--- a/rust/coverage_test.go
+++ b/rust/coverage_test.go
@@ -51,10 +51,10 @@ func TestCoverageFlags(t *testing.T) {
}
// Just test the dylib variants unless the library coverage logic changes to distinguish between the types.
- libfooCov := ctx.ModuleForTests("libfoo_cov", "android_arm64_armv8-a_dylib_cov").Rule("rustc")
- libbarNoCov := ctx.ModuleForTests("libbar_nocov", "android_arm64_armv8-a_dylib").Rule("rustc")
- fizzCov := ctx.ModuleForTests("fizz_cov", "android_arm64_armv8-a_cov").Rule("rustc")
- buzzNoCov := ctx.ModuleForTests("buzzNoCov", "android_arm64_armv8-a").Rule("rustc")
+ libfooCov := ctx.ModuleForTests(t, "libfoo_cov", "android_arm64_armv8-a_dylib_cov").Rule("rustc")
+ libbarNoCov := ctx.ModuleForTests(t, "libbar_nocov", "android_arm64_armv8-a_dylib").Rule("rustc")
+ fizzCov := ctx.ModuleForTests(t, "fizz_cov", "android_arm64_armv8-a_cov").Rule("rustc")
+ buzzNoCov := ctx.ModuleForTests(t, "buzzNoCov", "android_arm64_armv8-a").Rule("rustc")
rustcCoverageFlags := []string{"-C instrument-coverage", " -g "}
for _, flag := range rustcCoverageFlags {
@@ -103,7 +103,7 @@ func TestCoverageDeps(t *testing.T) {
srcs: ["foo.rs"],
}`)
- fizz := ctx.ModuleForTests("fizz", "android_arm64_armv8-a_cov").Rule("rustc")
+ fizz := ctx.ModuleForTests(t, "fizz", "android_arm64_armv8-a_cov").Rule("rustc")
if !strings.Contains(fizz.Args["linkFlags"], "libprofile-clang-extras.a") {
t.Fatalf("missing expected coverage 'libprofile-clang-extras' dependency in linkFlags: %#v", fizz.Args["linkFlags"])
}