summaryrefslogtreecommitdiff
path: root/sdk/sdk_test.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-05-05 21:35:49 +0100
committer Paul Duffin <paulduffin@google.com> 2021-05-06 10:50:00 +0100
commit62035b599135c8aecc792e604f0676878ee16696 (patch)
treedb420c3de105e7b91af74ac287c293ba8327f39a /sdk/sdk_test.go
parentfc7ff2799286531d4055e774322b50d4a46318c1 (diff)
Add baseline test for sdk snapshot env variables
Bug: 157884619 Test: m nothing Change-Id: I56c14ddfec1c33b60fe70f56e4d59b90639657fe
Diffstat (limited to 'sdk/sdk_test.go')
-rw-r--r--sdk/sdk_test.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index b7da95cae..e9129e0c7 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -464,3 +464,65 @@ func TestCommonValueOptimization_InvalidArchSpecificVariants(t *testing.T) {
"struct-0" has value "should-be-but-is-not-common0"
"struct-1" has value "should-be-but-is-not-common1"`, err)
}
+
+// Ensure that sdk snapshot related environment variables work correctly.
+func TestSnapshot_EnvConfiguration(t *testing.T) {
+ bp := `
+ sdk {
+ name: "mysdk",
+ java_header_libs: ["myjavalib"],
+ }
+
+ java_library {
+ name: "myjavalib",
+ srcs: ["Test.java"],
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ host_supported: true,
+ }
+ `
+ preparer := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ android.FixtureWithRootAndroidBp(bp),
+ )
+
+ checkZipFile := func(t *testing.T, result *android.TestResult, expected string) {
+ zipRule := result.ModuleForTests("mysdk", "common_os").Rule("SnapshotZipFiles")
+ android.AssertStringEquals(t, "snapshot zip file", expected, zipRule.Output.String())
+ }
+
+ t.Run("no env variables", func(t *testing.T) {
+ result := preparer.RunTest(t)
+
+ checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip")
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+java_import {
+ name: "mysdk_myjavalib@current",
+ sdk_member_name: "myjavalib",
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ jars: ["java/myjavalib.jar"],
+}
+
+java_import {
+ name: "myjavalib",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ jars: ["java/myjavalib.jar"],
+}
+
+sdk_snapshot {
+ name: "mysdk@current",
+ visibility: ["//visibility:public"],
+ java_header_libs: ["mysdk_myjavalib@current"],
+}
+ `),
+ )
+ })
+}