summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2021-03-12 17:56:51 -0800
committerColin Cross <ccross@android.com>2021-03-18 16:17:34 -0700
commit1661aff8bea44396b3587e19c8c79fd574bf043d (patch)
treec4d9c848db7bb229ec3025b05f68debf1b7956cc /java/java_test.go
parentef972743e8d4c047bbba7747caf3e90215889eb0 (diff)
Run lint actions in sbox
Run lint actions in sbox with RuleBuilder.SandboxInputs. This copies all input files into the sandbox, which prevents the lint tool from finding nearby source files that were not presented to it. Using SandboxInputs requires use of PathForInput or PathForOutput anywhere a path is used outside of the RuleBuilderCommand methods that take paths so that they can be translated to the paths that will be used in the sandbox. Bug: 181681346 Test: lint_test.go Test: m lint-check dist Test: m USE_RBE=true RBE_LINT=true lint-check dist Test: m USE_RBE=true RBE_LINT=true RBE_LINT_EXEC_STRATEGY=remote lint-check dist Change-Id: Iab4e09d961891ef182643583d4d456e413bc5e39
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/java/java_test.go b/java/java_test.go
index b68945fd1..75813e03c 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -25,12 +25,12 @@ import (
"strings"
"testing"
- "android/soong/genrule"
"github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
+ "android/soong/genrule"
"android/soong/python"
)
@@ -1296,9 +1296,9 @@ func TestJavaLint(t *testing.T) {
})
foo := ctx.ModuleForTests("foo", "android_common")
- rule := foo.Rule("lint")
- if !strings.Contains(rule.RuleParams.Command, "--baseline lint-baseline.xml") {
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command, "--baseline lint-baseline.xml") {
t.Error("did not pass --baseline flag")
}
}
@@ -1318,9 +1318,9 @@ func TestJavaLintWithoutBaseline(t *testing.T) {
`, map[string][]byte{})
foo := ctx.ModuleForTests("foo", "android_common")
- rule := foo.Rule("lint")
- if strings.Contains(rule.RuleParams.Command, "--baseline") {
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto"))
+ if strings.Contains(*sboxProto.Commands[0].Command, "--baseline") {
t.Error("passed --baseline flag for non existent file")
}
}
@@ -1376,9 +1376,9 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) {
})
foo := ctx.ModuleForTests("foo", "android_common")
- rule := foo.Rule("lint")
- if !strings.Contains(rule.RuleParams.Command, "--baseline mybaseline.xml") {
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, 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")
}
}