summaryrefslogtreecommitdiff
path: root/sh/sh_binary_test.go
diff options
context:
space:
mode:
author Makoto Onuki <omakoto@google.com> 2023-08-24 22:17:56 +0000
committer Android Build Cherrypicker Worker <android-build-cherrypicker-worker@google.com> 2023-08-24 22:17:56 +0000
commit1725b20d144e7f7054e63f88e297c5461e6dbe9e (patch)
tree0d41eaa516b1c12edf69302d21f57ec51bdadfe3 /sh/sh_binary_test.go
parent4e6c42d417c41f91f60333dad0974d7bfb7f5ae2 (diff)
Support java_data in sh_test_host
Bug: 297225342 Test: with a custom test rule Test: cd sh && go test ./... (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:de5d265a798ce0e12ad0a2d0a6675942df5cd10b) Merged-In: Ia5a60fa6d917f2c2fde56df543625024ec11877a Change-Id: Ia5a60fa6d917f2c2fde56df543625024ec11877a
Diffstat (limited to 'sh/sh_binary_test.go')
-rw-r--r--sh/sh_binary_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go
index 89b8126f1..5fcb58d20 100644
--- a/sh/sh_binary_test.go
+++ b/sh/sh_binary_test.go
@@ -9,6 +9,7 @@ import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/java"
)
func TestMain(m *testing.M) {
@@ -17,6 +18,7 @@ func TestMain(m *testing.M) {
var prepareForShTest = android.GroupFixturePreparers(
cc.PrepareForTestWithCcBuildComponents,
+ java.PrepareForTestWithJavaDefaultModules,
PrepareForTestWithShBuildComponents,
android.FixtureMergeMockFs(android.MockFS{
"test.sh": nil,
@@ -255,3 +257,39 @@ func TestShTestHost_dataDeviceModulesAutogenTradefedConfig(t *testing.T) {
t.Errorf("foo extraConfings %v does not contain %q", autogen.Args["extraConfigs"], expectedBinAutogenConfig)
}
}
+
+func TestShTestHost_javaData(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test_host {
+ name: "foo",
+ src: "test.sh",
+ filename: "test.sh",
+ data: [
+ "testdata/data1",
+ "testdata/sub/data2",
+ ],
+ java_data: [
+ "javalib",
+ ],
+ }
+
+ java_library_host {
+ name: "javalib",
+ srcs: [],
+ }
+ `)
+ buildOS := ctx.Config().BuildOS.String()
+ mod := ctx.ModuleForTests("foo", buildOS+"_x86_64").Module().(*ShTest)
+ if !mod.Host() {
+ t.Errorf("host bit is not set for a sh_test_host module.")
+ }
+ expectedData := []string{
+ ":testdata/data1",
+ ":testdata/sub/data2",
+ "out/soong/.intermediates/javalib/" + buildOS + "_common/combined/:javalib.jar",
+ }
+
+ entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0]
+ actualData := entries.EntryMap["LOCAL_TEST_DATA"]
+ android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", config, expectedData, actualData)
+}