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/system_modules_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'java/system_modules_test.go') diff --git a/java/system_modules_test.go b/java/system_modules_test.go index b7a99b51a..99301bc52 100644 --- a/java/system_modules_test.go +++ b/java/system_modules_test.go @@ -55,7 +55,7 @@ func TestJavaSystemModules(t *testing.T) { result := android.GroupFixturePreparers(prepareForJavaTest, addSourceSystemModules).RunTest(t) // check the existence of the source module - sourceSystemModules := result.ModuleForTests("system-modules", "android_common") + sourceSystemModules := result.ModuleForTests(t, "system-modules", "android_common") sourceInputs := sourceSystemModules.Rule("jarsTosystemModules").Inputs // The expected paths are the header jars from the source input modules. @@ -83,7 +83,7 @@ func TestJavaSystemModulesImport(t *testing.T) { result := android.GroupFixturePreparers(prepareForJavaTest, addPrebuiltSystemModules).RunTest(t) // check the existence of the renamed prebuilt module - prebuiltSystemModules := result.ModuleForTests("system-modules", "android_common") + prebuiltSystemModules := result.ModuleForTests(t, "system-modules", "android_common") prebuiltInputs := prebuiltSystemModules.Rule("jarsTosystemModules").Inputs // The expected paths are the header jars from the renamed prebuilt input modules. @@ -100,7 +100,7 @@ func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) { ).RunTest(t) // check the existence of the source module - sourceSystemModules := result.ModuleForTests("system-modules", "android_common") + sourceSystemModules := result.ModuleForTests(t, "system-modules", "android_common") sourceInputs := sourceSystemModules.Rule("jarsTosystemModules").Inputs // The expected paths are the header jars from the source input modules. @@ -108,7 +108,7 @@ func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) { android.AssertArrayString(t, "source system modules inputs", expectedSourcePaths, sourceInputs.RelativeToTop().Strings()) // check the existence of the renamed prebuilt module - prebuiltSystemModules := result.ModuleForTests("prebuilt_system-modules", "android_common") + prebuiltSystemModules := result.ModuleForTests(t, "prebuilt_system-modules", "android_common") prebuiltInputs := prebuiltSystemModules.Rule("jarsTosystemModules").Inputs // The expected paths are the header jars from the renamed prebuilt input modules. -- cgit v1.2.3-59-g8ed1b