summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2021-03-20 14:19:46 +0000
committerPaul Duffin <paulduffin@google.com>2021-03-24 22:08:05 +0000
commit76e5c8a37f4b713dee60d4ba1ea5342277b3d441 (patch)
treeba18d83774aab77da740da4dd6ea98e4f643c0b3 /java/java_test.go
parent958408d92163a96db5095e9a74f5942579e1ca14 (diff)
Convert test that disallows non existent paths to use fixtures
This change needed to add some additional files to the registered files for PrepareForTestWithJavaDefaultModules because otherwise they would fail when "TestAllowNonExistentPaths = false". Those files were being added by the TestJavaLintRequiresCustomLintFileToExist (albeit in some cases in different locations to that required by the default modules but as the files are needed by the modules defined in PrepareForTestWithJavaDefaultModules they should be defined in it. A couple of other places also provided some files so moving them into PrepareForTestWithJavaDefaultModules caused some conflicts which needed to be resolved. Bug: 183184375 Test: m nothing Change-Id: I76ce9f1673c1c1c4000635b76b8377d582224bf1
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go52
1 files changed, 25 insertions, 27 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 1a79f497b..9924be7bf 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -133,6 +133,15 @@ func defaultModuleToPath(name string) string {
}
}
+// Test that the PrepareForTestWithJavaDefaultModules provides all the files that it uses by
+// running it in a fixture that requires all source files to exist.
+func TestPrepareForTestWithJavaDefaultModules(t *testing.T) {
+ android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestDisallowNonExistentPaths,
+ ).RunTest(t)
+}
+
func TestJavaLinkType(t *testing.T) {
testJava(t, `
java_library {
@@ -1220,33 +1229,22 @@ func TestJavaLintWithoutBaseline(t *testing.T) {
}
func TestJavaLintRequiresCustomLintFileToExist(t *testing.T) {
- config := TestConfig(t.TempDir(),
- nil,
- `
- java_library {
- name: "foo",
- srcs: [
- ],
- min_sdk_version: "29",
- sdk_version: "system_current",
- lint: {
- baseline_filename: "mybaseline.xml",
- },
- }
- `, map[string][]byte{
- "build/soong/java/lint_defaults.txt": nil,
- "prebuilts/cmdline-tools/tools/bin/lint": nil,
- "prebuilts/cmdline-tools/tools/lib/lint-classpath.jar": nil,
- "framework/aidl": nil,
- "a.java": nil,
- "AndroidManifest.xml": nil,
- "build/make/target/product/security": nil,
- })
- config.TestAllowNonExistentPaths = false
- testJavaErrorWithConfig(t,
- "source path \"mybaseline.xml\" does not exist",
- config,
- )
+ android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestDisallowNonExistentPaths,
+ ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern([]string{`source path "mybaseline.xml" does not exist`})).
+ RunTestWithBp(t, `
+ java_library {
+ name: "foo",
+ srcs: [
+ ],
+ min_sdk_version: "29",
+ sdk_version: "system_current",
+ lint: {
+ baseline_filename: "mybaseline.xml",
+ },
+ }
+ `)
}
func TestJavaLintUsesCorrectBpConfig(t *testing.T) {