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
diff --git a/rust/benchmark_test.go b/rust/benchmark_test.go
index 734dda7..c239a09 100644
--- a/rust/benchmark_test.go
+++ b/rust/benchmark_test.go
@@ -28,7 +28,7 @@
srcs: ["foo.rs"],
}`)
- testingModule := ctx.ModuleForTests("my_bench", "linux_glibc_x86_64")
+ testingModule := ctx.ModuleForTests(t, "my_bench", "linux_glibc_x86_64")
expectedOut := "my_bench/linux_glibc_x86_64/my_bench"
outPath := testingModule.Output("my_bench").Output.String()
if !strings.Contains(outPath, expectedOut) {
@@ -43,7 +43,7 @@
srcs: ["foo.rs"],
}`)
- testingModule := ctx.ModuleForTests("my_bench", "android_arm64_armv8-a").Module().(*Module)
+ testingModule := ctx.ModuleForTests(t, "my_bench", "android_arm64_armv8-a").Module().(*Module)
if !android.InList("libcriterion.rlib-std", testingModule.Properties.AndroidMkRlibs) {
t.Errorf("rlib-std variant for libcriterion not detected as a rustlib-defined rlib dependency for device rust_benchmark module")