platform_compat_config_conversion_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2023 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package bp2build
  15. import (
  16. "testing"
  17. "android/soong/android"
  18. "android/soong/java"
  19. )
  20. func runPlatformCompatConfigTestCase(t *testing.T, tc Bp2buildTestCase) {
  21. t.Helper()
  22. RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
  23. ctx.RegisterModuleType("java_library", java.LibraryFactory)
  24. ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
  25. }, tc)
  26. }
  27. func TestPlatformCompatConfig(t *testing.T) {
  28. runPlatformCompatConfigTestCase(t, Bp2buildTestCase{
  29. Description: "platform_compat_config - conversion test",
  30. Blueprint: `
  31. platform_compat_config {
  32. name: "foo",
  33. src: ":lib",
  34. }`,
  35. Filesystem: map[string]string{
  36. "a/b/Android.bp": `
  37. java_library {
  38. name: "lib",
  39. srcs: ["a.java"],
  40. }`,
  41. },
  42. ExpectedBazelTargets: []string{
  43. MakeBazelTarget("platform_compat_config", "foo", AttrNameToString{
  44. "src": `"//a/b:lib"`,
  45. }),
  46. },
  47. })
  48. }