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/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 60d111f..97644e6 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -330,7 +330,7 @@
// Make sure that the source bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
- module := result.ModuleForTests("dex_bootjars", "android_common")
+ module := result.ModuleForTests(t, "dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
@@ -438,7 +438,7 @@
// Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
- module := result.ModuleForTests("dex_bootjars", "android_common")
+ module := result.ModuleForTests(t, "dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
@@ -604,7 +604,7 @@
`prebuilt_foo`,
})
- module := result.ModuleForTests("dex_bootjars", "android_common")
+ module := result.ModuleForTests(t, "dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
}
@@ -709,7 +709,7 @@
`mybootclasspathfragment`,
})
- apex := result.ModuleForTests("myapex", "android_common_myapex")
+ apex := result.ModuleForTests(t, "myapex", "android_common_myapex")
apexRule := apex.Rule("apexRule")
copyCommands := apexRule.Args["copy_commands"]
@@ -877,7 +877,7 @@
quuzModuleLibStubs := getDexJarPath(result, "quuz.stubs.exportable.module_lib")
// Make sure that the fragment uses the quuz stub dex jars when generating the hidden API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
+ fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1054,7 +1054,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
+ fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1225,7 +1225,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
+ fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1383,7 +1383,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
+ fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1466,7 +1466,7 @@
}
`)
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
+ fragment := result.ModuleForTests(t, "mybootclasspathfragment", "android_common_myapex")
classPathProtoContent := android.ContentFromFileRuleForTests(t, result.TestContext, fragment.Output("bootclasspath.pb.textproto"))
// foo
ensureContains(t, classPathProtoContent, `jars {