license_kind_conversion_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2022 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. "android/soong/android"
  17. "testing"
  18. )
  19. func registerLicenseKindModuleTypes(_ android.RegistrationContext) {}
  20. func TestLicenseKindBp2Build(t *testing.T) {
  21. tests := []struct {
  22. description string
  23. module string
  24. expected ExpectedRuleTarget
  25. }{
  26. {
  27. description: "license_kind",
  28. module: `
  29. license_kind {
  30. name: "my_license",
  31. conditions: [
  32. "by_exception_only",
  33. "not_allowed",
  34. ],
  35. url: "https://spdx.org/licenses/0BSD",
  36. visibility: ["//visibility:public"],
  37. }`,
  38. expected: ExpectedRuleTarget{
  39. "license_kind",
  40. "my_license",
  41. AttrNameToString{
  42. "conditions": `[
  43. "by_exception_only",
  44. "not_allowed",
  45. ]`,
  46. "url": `"https://spdx.org/licenses/0BSD"`,
  47. "visibility": `["//visibility:public"]`,
  48. },
  49. android.HostAndDeviceDefault,
  50. },
  51. },
  52. }
  53. for _, test := range tests {
  54. RunBp2BuildTestCase(t,
  55. registerLicenseKindModuleTypes,
  56. Bp2buildTestCase{
  57. Description: test.description,
  58. ModuleTypeUnderTest: "license_kind",
  59. ModuleTypeUnderTestFactory: android.LicenseKindFactory,
  60. Blueprint: test.module,
  61. ExpectedBazelTargets: []string{test.expected.String()},
  62. })
  63. }
  64. }