diff options
author | Zi Wang <mrziwang@google.com> | 2023-10-10 05:19:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-10-10 05:19:10 +0000 |
commit | 57e60bf82b8fb0b98535323db8f0ff68896d3049 (patch) | |
tree | 1d2626214563b5e88039f6db532455a4dcc666e4 /bp2build | |
parent | 6525ee82d7fe84f274f9b4214c3ea3bb4426b02f (diff) | |
parent | 734266b633f4dc61e17609983559ad8355a15b5f (diff) | |
download | soong-57e60bf82b8fb0b98535323db8f0ff68896d3049.tar.gz |
Merge "Use correct module name for java_import in shouldConvertWithBp2build verification" into main
Diffstat (limited to 'bp2build')
-rw-r--r-- | bp2build/java_import_conversion_test.go | 35 | ||||
-rw-r--r-- | bp2build/java_library_conversion_test.go | 25 |
2 files changed, 60 insertions, 0 deletions
diff --git a/bp2build/java_import_conversion_test.go b/bp2build/java_import_conversion_test.go index 5661620e2..d9910afb9 100644 --- a/bp2build/java_import_conversion_test.go +++ b/bp2build/java_import_conversion_test.go @@ -21,6 +21,13 @@ import ( "testing" ) +func runJavaImportTestCaseWithRegistrationCtxFunc(t *testing.T, tc Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) { + t.Helper() + (&tc).ModuleTypeUnderTest = "java_import" + (&tc).ModuleTypeUnderTestFactory = java.ImportFactory + RunBp2BuildTestCase(t, registrationCtxFunc, tc) +} + func runJavaImportTestCase(t *testing.T, tc Bp2buildTestCase) { t.Helper() RunBp2BuildTestCase(t, registerJavaImportModuleTypes, tc) @@ -120,3 +127,31 @@ java_import_host { }), }}) } + +func TestJavaImportSameNameAsJavaLibrary(t *testing.T) { + runJavaImportTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{ + Description: "java_import has the same name as other package java_library's", + Filesystem: map[string]string{ + "foo/bar/Android.bp": simpleModule("java_library", "test_lib"), + "test.jar": "", + }, + Blueprint: `java_import { + name: "test_lib", + jars: ["test.jar"], + bazel_module: { bp2build_available: true }, +} +`, + ExpectedBazelTargets: []string{ + MakeBazelTarget("java_import", "test_lib", AttrNameToString{ + "jars": `["test.jar"]`, + }), + MakeBazelTarget("java_library", "test_lib-neverlink", AttrNameToString{ + "exports": `[":test_lib"]`, + "neverlink": `True`, + "sdk_version": `"none"`, + }), + }, + }, func(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_library", java.LibraryFactory) + }) +} diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go index 426dffa2b..ad0ec655a 100644 --- a/bp2build/java_library_conversion_test.go +++ b/bp2build/java_library_conversion_test.go @@ -1041,3 +1041,28 @@ filegroup { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }) } + +func TestJavaLibrarySameNameAsPrebuilt(t *testing.T) { + runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{ + Description: "java_library and prebuilt module have the same name", + Filesystem: map[string]string{ + "foo/bar/Android.bp": simpleModule("java_import", "test_lib"), + }, + Blueprint: `java_library { + name: "test_lib", + srcs: ["a.java"], + sdk_version: "current", + bazel_module: { bp2build_available: true }, +} +`, + ExpectedBazelTargets: []string{ + MakeBazelTarget("java_library", "test_lib", AttrNameToString{ + "srcs": `["a.java"]`, + "sdk_version": `"current"`, + }), + MakeNeverlinkDuplicateTarget("java_library", "test_lib"), + }, + }, func(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_import", java.ImportFactory) + }) +} |