From 90607e9056f6ff4cec2447fdd7a8b252d67ffde7 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 11 Feb 2025 14:58:07 -0800 Subject: 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 --- java/bootclasspath_fragment_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java/bootclasspath_fragment_test.go') diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index d181ce060..87b853c56 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -371,7 +371,7 @@ func TestFromTextWidestApiScope(t *testing.T) { } `) - fragment := result.ModuleForTests("myfragment", "android_common") + fragment := result.ModuleForTests(t, "myfragment", "android_common") dependencyStubDexFlag := "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.test_module_lib/android_common/dex/android-non-updatable.stubs.test_module_lib.jar" stubFlagsCommand := fragment.Output("modular-hiddenapi/stub-flags.csv").RuleParams.Command android.AssertStringDoesContain(t, @@ -479,7 +479,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { // Make sure that the signature-patterns.csv is passed all the appropriate package properties // from the bootclasspath_fragment and its contents. - fragment := result.ModuleForTests("mybootclasspathfragment", "android_common") + fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common") rule := fragment.Output("modular-hiddenapi/signature-patterns.csv") expectedCommand := strings.Join([]string{ "--split-package newlibrary", -- cgit v1.2.3-59-g8ed1b