diff --git a/android/defs.go b/android/defs.go index b28d2fa3d..03968c10d 100644 --- a/android/defs.go +++ b/android/defs.go @@ -232,7 +232,7 @@ func shellUnescape(s string) string { // ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use // in tests. -func ContentFromFileRuleForTests(t *testing.T, params TestingBuildParams) string { +func ContentFromFileRuleForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) string { t.Helper() if g, w := params.Rule, writeFile; g != w { t.Errorf("expected params.Rule to be %q, was %q", w, g) diff --git a/android/rule_builder.go b/android/rule_builder.go index 5c6dffec1..1a491f708 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -1341,9 +1341,9 @@ func (c *RuleBuilderCommand) String() string { // RuleBuilderSboxProtoForTests takes the BuildParams for the manifest passed to RuleBuilder.Sbox() // and returns sbox testproto generated by the RuleBuilder. -func RuleBuilderSboxProtoForTests(t *testing.T, params TestingBuildParams) *sbox_proto.Manifest { +func RuleBuilderSboxProtoForTests(t *testing.T, ctx *TestContext, params TestingBuildParams) *sbox_proto.Manifest { t.Helper() - content := ContentFromFileRuleForTests(t, params) + content := ContentFromFileRuleForTests(t, ctx, params) manifest := sbox_proto.Manifest{} err := prototext.Unmarshal([]byte(content), &manifest) if err != nil { diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go index a6b3a27a1..63c35272a 100644 --- a/android/rule_builder_test.go +++ b/android/rule_builder_test.go @@ -683,7 +683,7 @@ func TestRuleBuilder_Build(t *testing.T) { t.Errorf("want Deps = %q, got %q", blueprint.DepsGCC, params.Deps) } - rspFile2Content := ContentFromFileRuleForTests(t, rspFile2Params) + rspFile2Content := ContentFromFileRuleForTests(t, result.TestContext, rspFile2Params) AssertStringEquals(t, "rspFile2 content", "rsp_in2\n", rspFile2Content) } @@ -797,7 +797,7 @@ func TestRuleBuilderHashInputs(t *testing.T) { t.Run(test.name, func(t *testing.T) { t.Run("sbox", func(t *testing.T) { gen := result.ModuleForTests(test.name+"_sbox", "") - manifest := RuleBuilderSboxProtoForTests(t, gen.Output("sbox.textproto")) + manifest := RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("sbox.textproto")) hash := manifest.Commands[0].GetInputHash() AssertStringEquals(t, "hash", test.expectedHash, hash) diff --git a/apex/apex_test.go b/apex/apex_test.go index ddb9a4051..479bf1ac6 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -595,13 +595,15 @@ func TestBasicApex(t *testing.T) { t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds) } - fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt").Args["content"], "\\n") + fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt")), "\n") ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex") ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib") ensureListContains(t, fullDepsInfo, " myotherjar(minSdkVersion:(no version)) <- myjar") ensureListContains(t, fullDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external) <- myjar") - flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt").Args["content"], "\\n") + flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt")), "\n") ensureListContains(t, flatDepsInfo, "myjar(minSdkVersion:(no version))") ensureListContains(t, flatDepsInfo, "mylib2(minSdkVersion:(no version))") ensureListContains(t, flatDepsInfo, "myotherjar(minSdkVersion:(no version))") @@ -1281,10 +1283,12 @@ func TestApexWithExplicitStubsDependency(t *testing.T) { // Ensure that libfoo stubs is not linking to libbar (since it is a stubs) ensureNotContains(t, libFooStubsLdFlags, "libbar.so") - fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt").Args["content"], "\\n") + fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt")), "\n") ensureListContains(t, fullDepsInfo, " libfoo(minSdkVersion:(no version)) (external) <- mylib") - flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt").Args["content"], "\\n") + flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt")), "\n") ensureListContains(t, flatDepsInfo, "libfoo(minSdkVersion:(no version)) (external)") } @@ -2030,7 +2034,8 @@ func TestTrackAllowedDeps(t *testing.T) { "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt") myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - flatlist := strings.Split(myapex.Output("depsinfo/flatlist.txt").BuildParams.Args["content"], "\\n") + flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + myapex.Output("depsinfo/flatlist.txt")), "\n") android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep", flatlist, "libbar(minSdkVersion:(no version)) (external)") android.AssertStringListDoesNotContain(t, "do not track if not available for platform", @@ -8154,7 +8159,7 @@ func TestAppBundle(t *testing.T) { `, withManifestPackageNameOverrides([]string{"AppFoo:com.android.foo"})) bundleConfigRule := ctx.ModuleForTests("myapex", "android_common_myapex").Output("bundle_config.json") - content := bundleConfigRule.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule) ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`) @@ -8181,7 +8186,7 @@ func TestAppSetBundle(t *testing.T) { }`) mod := ctx.ModuleForTests("myapex", "android_common_myapex") bundleConfigRule := mod.Output("bundle_config.json") - content := bundleConfigRule.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule) ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) @@ -9126,7 +9131,7 @@ func TestApexKeysTxt(t *testing.T) { `) myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - content := myapex.Output("apexkeys.txt").BuildParams.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, myapex.Output("apexkeys.txt")) ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`) } @@ -9166,9 +9171,11 @@ func TestApexKeysTxtOverrides(t *testing.T) { } `) - content := ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt").BuildParams.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt")) ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`) - content = ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt").BuildParams.Args["content"] + content = android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt")) ensureContains(t, content, `name="myapex_set.apex" public_key="PRESIGNED" private_key="PRESIGNED" container_certificate="PRESIGNED" container_private_key="PRESIGNED" partition="system"`) } diff --git a/cc/cc_test.go b/cc/cc_test.go index e2dba9043..6e71f5ed6 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -341,9 +341,9 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string } } -func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) { +func checkWriteFileOutput(t *testing.T, ctx *android.TestContext, params android.TestingBuildParams, expected []string) { t.Helper() - content := android.ContentFromFileRuleForTests(t, params) + content := android.ContentFromFileRuleForTests(t, ctx, params) actual := strings.FieldsFunc(content, func(r rune) bool { return r == '\n' }) assertArrayString(t, actual, expected) } @@ -351,7 +351,7 @@ func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expec func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) { t.Helper() vndkSnapshot := ctx.SingletonForTests("vndk-snapshot") - checkWriteFileOutput(t, vndkSnapshot.Output(output), expected) + checkWriteFileOutput(t, ctx, vndkSnapshot.Output(output), expected) } func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) { @@ -4302,7 +4302,7 @@ func TestAidlLibraryWithHeaders(t *testing.T) { libfoo.Rule("aidl_library").Implicits, ) - manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl_library.sbox.textproto")) + manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl_library.sbox.textproto")) aidlCommand := manifest.Commands[0].GetCommand() expectedAidlFlags := "-Ipackage_foo/a -Ipackage_bar/x" @@ -4337,7 +4337,7 @@ func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) { `) libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static") - manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto")) + manifest := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, libfoo.Output("aidl.sbox.textproto")) aidlCommand := manifest.Commands[0].GetCommand() expectedAidlFlag := "-Werror" if !strings.Contains(aidlCommand, expectedAidlFlag) { @@ -4388,7 +4388,7 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) { } `) libfoo := ctx.ModuleForTests("libfoo", tc.variant) - manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto")) + manifest := android.RuleBuilderSboxProtoForTests(t, ctx, libfoo.Output("aidl.sbox.textproto")) aidlCommand := manifest.Commands[0].GetCommand() expectedAidlFlag := "--min_sdk_version=" + tc.expected if !strings.Contains(aidlCommand, expectedAidlFlag) { diff --git a/cc/gen_test.go b/cc/gen_test.go index 85df33312..439f0a996 100644 --- a/cc/gen_test.go +++ b/cc/gen_test.go @@ -67,7 +67,7 @@ func TestGen(t *testing.T) { t.Errorf("missing aidl includes in global flags") } - aidlCommand := android.RuleBuilderSboxProtoForTests(t, aidlManifest).Commands[0].GetCommand() + aidlCommand := android.RuleBuilderSboxProtoForTests(t, ctx, aidlManifest).Commands[0].GetCommand() if !strings.Contains(aidlCommand, "-Isub") { t.Errorf("aidl command for c.aidl should contain \"-Isub\", but was %q", aidlCommand) } diff --git a/cc/genrule_test.go b/cc/genrule_test.go index 0d16e6261..929524480 100644 --- a/cc/genrule_test.go +++ b/cc/genrule_test.go @@ -178,7 +178,7 @@ func TestCmdPrefix(t *testing.T) { android.OptionalFixturePreparer(tt.preparer), ).RunTestWithBp(t, bp) gen := result.ModuleForTests("gen", tt.variant) - sboxProto := android.RuleBuilderSboxProtoForTests(t, gen.Output("genrule.sbox.textproto")) + sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("genrule.sbox.textproto")) cmd := *sboxProto.Commands[0].Command android.AssertStringDoesContain(t, "incorrect CC_ARCH", cmd, "CC_ARCH="+tt.arch+" ") android.AssertStringDoesContain(t, "incorrect CC_NATIVE_BRIDGE", cmd, "CC_NATIVE_BRIDGE="+tt.nativeBridge+" ") diff --git a/cc/testing.go b/cc/testing.go index 71d986b4f..b1583f169 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -797,7 +797,7 @@ func AssertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, func checkOverrides(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, jsonPath string, expected []string) { t.Helper() out := singleton.MaybeOutput(jsonPath) - content := android.ContentFromFileRuleForTests(t, out) + content := android.ContentFromFileRuleForTests(t, ctx, out) var flags snapshotJsonFlags if err := json.Unmarshal([]byte(content), &flags); err != nil { diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go index c5431b3d3..890a53308 100644 --- a/cc/vendor_snapshot_test.go +++ b/cc/vendor_snapshot_test.go @@ -23,13 +23,14 @@ import ( "testing" ) -func checkJsonContents(t *testing.T, ctx android.TestingSingleton, jsonPath string, key string, value string) { - jsonOut := ctx.MaybeOutput(jsonPath) +func checkJsonContents(t *testing.T, ctx *android.TestContext, snapshotSingleton android.TestingSingleton, jsonPath string, key string, value string) { + jsonOut := snapshotSingleton.MaybeOutput(jsonPath) if jsonOut.Rule == nil { t.Errorf("%q expected but not found", jsonPath) return } - if !strings.Contains(jsonOut.Args["content"], fmt.Sprintf("%q:%q", key, value)) { + content := android.ContentFromFileRuleForTests(t, ctx, jsonOut) + if !strings.Contains(content, fmt.Sprintf("%q:%q", key, value)) { t.Errorf("%q must include %q:%q but it only has %v", jsonPath, key, value, jsonOut.Args["content"]) } } @@ -167,8 +168,8 @@ func TestVendorSnapshotCapture(t *testing.T) { filepath.Join(staticDir, "libvendor_available.a.json"), filepath.Join(staticDir, "libvendor_available.cfi.a.json")) - checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libb.a.json"), "MinSdkVersion", "apex_inherit") - checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libvendor_available.a.json"), "MinSdkVersion", "29") + checkJsonContents(t, ctx, snapshotSingleton, filepath.Join(staticDir, "libb.a.json"), "MinSdkVersion", "apex_inherit") + checkJsonContents(t, ctx, snapshotSingleton, filepath.Join(staticDir, "libvendor_available.a.json"), "MinSdkVersion", "29") // For binary executables, all vendor:true and vendor_available modules are captured. if archType == "arm64" { diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go index 7c14531bd..4cff4b886 100644 --- a/genrule/genrule_test.go +++ b/genrule/genrule_test.go @@ -543,7 +543,7 @@ func TestGenruleHashInputs(t *testing.T) { for _, test := range testcases { t.Run(test.name, func(t *testing.T) { gen := result.ModuleForTests(test.name, "") - manifest := android.RuleBuilderSboxProtoForTests(t, gen.Output("genrule.sbox.textproto")) + manifest := android.RuleBuilderSboxProtoForTests(t, result.TestContext, gen.Output("genrule.sbox.textproto")) hash := manifest.Commands[0].GetInputHash() android.AssertStringEquals(t, "hash", test.expectedHash, hash) diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index f86e1acef..7b89dded4 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -84,7 +84,7 @@ func TestDroidstubs(t *testing.T) { for _, c := range testcases { m := ctx.ModuleForTests(c.moduleName, "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, manifest) cmdline := String(sboxProto.Commands[0].Command) android.AssertStringContainsEquals(t, "api-versions generation flag", cmdline, "--generate-api-levels", c.generate_xml) if c.expectedJarFilename != "" { @@ -133,7 +133,7 @@ func getAndroidJarPatternsForDroidstubs(t *testing.T, sdkType string) []string { m := ctx.ModuleForTests("foo-stubs", "android_common") manifest := m.Output("metalava.sbox.textproto") - cmd := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command) + cmd := String(android.RuleBuilderSboxProtoForTests(t, ctx, manifest).Commands[0].Command) r := regexp.MustCompile(`--android-jar-pattern [^ ]+/android.jar`) return r.FindAllString(cmd, -1) } @@ -212,7 +212,7 @@ func TestDroidstubsSandbox(t *testing.T) { t.Errorf("Expected inputs %q, got %q", w, g) } - manifest := android.RuleBuilderSboxProtoForTests(t, m.Output("metalava.sbox.textproto")) + manifest := android.RuleBuilderSboxProtoForTests(t, ctx, m.Output("metalava.sbox.textproto")) if g, w := manifest.Commands[0].GetCommand(), "reference __SBOX_SANDBOX_DIR__/out/.intermediates/foo/gen/foo.txt"; !strings.Contains(g, w) { t.Errorf("Expected command to contain %q, got %q", w, g) } @@ -302,7 +302,7 @@ func TestDroidstubsWithSdkExtensions(t *testing.T) { }) m := ctx.ModuleForTests("baz-stubs", "android_common") manifest := m.Output("metalava.sbox.textproto") - cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command) + cmdline := String(android.RuleBuilderSboxProtoForTests(t, ctx, manifest).Commands[0].Command) android.AssertStringDoesContain(t, "sdk-extensions-root present", cmdline, "--sdk-extensions-root sdk/extensions") android.AssertStringDoesContain(t, "sdk-extensions-info present", cmdline, "--sdk-extensions-info sdk/extensions/info.txt") } @@ -434,6 +434,6 @@ func TestDroidstubsHideFlaggedApi(t *testing.T) { m := result.ModuleForTests("foo", "android_common") manifest := m.Output("metalava.sbox.textproto") - cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command) + cmdline := String(android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest).Commands[0].Command) android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--hide-annotation android.annotation.FlaggedApi") } diff --git a/java/java_test.go b/java/java_test.go index 81119a79e..0c750ebe1 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1921,7 +1921,7 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) { for _, c := range testcases { m := ctx.ModuleForTests(c.moduleName, "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() sourceFilesFlag := "--source-files " + strings.Join(c.sourceTextFileDirs, " ") android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag) @@ -2026,7 +2026,7 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) { for _, c := range testcases { m := ctx.ModuleForTests(c.moduleName, "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() sourceFilesFlag := "--source-files " + strings.Join(c.sourceTextFileDirs, " ") android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag) @@ -2316,7 +2316,7 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) { m := ctx.ModuleForTests("bar1", "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar") } @@ -2480,7 +2480,7 @@ func TestJavaApiContributionImport(t *testing.T) { `) m := ctx.ModuleForTests("foo", "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx.TestContext, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() sourceFilesFlag := "--source-files current.txt" android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag) @@ -2501,7 +2501,7 @@ func TestJavaApiLibraryApiFilesSorting(t *testing.T) { `) m := ctx.ModuleForTests("foo", "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() // Api files are sorted from the narrowest api scope to the widest api scope. @@ -2543,7 +2543,7 @@ func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) { `) m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common") manifest := m.Output("metalava.sbox.textproto") - sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/.intermediates/bar/android_common/turbine-combined/bar.jar" android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag) diff --git a/java/lint_test.go b/java/lint_test.go index ec901aa70..5e6b8bcea 100644 --- a/java/lint_test.go +++ b/java/lint_test.go @@ -39,7 +39,7 @@ func TestJavaLint(t *testing.T) { foo := ctx.ModuleForTests("foo", "android_common") - sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto")) if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") { t.Error("did not pass --baseline flag") } @@ -61,7 +61,7 @@ func TestJavaLintWithoutBaseline(t *testing.T) { foo := ctx.ModuleForTests("foo", "android_common") - sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto")) if strings.Contains(*sboxProto.Commands[0].Command, "--baseline") { t.Error("passed --baseline flag for non existent file") } @@ -108,7 +108,7 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) { foo := ctx.ModuleForTests("foo", "android_common") - sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) + sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto")) if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline mybaseline.xml") { t.Error("did not use the correct file for baseline") } @@ -276,7 +276,7 @@ func TestJavaLintDatabaseSelectionFull(t *testing.T) { RunTestWithBp(t, thisBp) foo := result.ModuleForTests("foo", "android_common") - sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) + sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, foo.Output("lint.sbox.textproto")) if !strings.Contains(*sboxProto.Commands[0].Command, "/"+testCase.expected_file) { t.Error("did not use full api database for case", testCase) }