python_test_conversion_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. "android/soong/python"
  17. "testing"
  18. )
  19. func TestPythonTestHostSimple(t *testing.T) {
  20. runBp2BuildTestCaseWithPythonLibraries(t, Bp2buildTestCase{
  21. Description: "simple python_test_host converts to a native py_test",
  22. ModuleTypeUnderTest: "python_test_host",
  23. ModuleTypeUnderTestFactory: python.PythonTestHostFactory,
  24. Filesystem: map[string]string{
  25. "a.py": "",
  26. "b/c.py": "",
  27. "b/d.py": "",
  28. "b/e.py": "",
  29. "files/data.txt": "",
  30. },
  31. Blueprint: `python_test_host {
  32. name: "foo",
  33. main: "a.py",
  34. srcs: ["**/*.py"],
  35. exclude_srcs: ["b/e.py"],
  36. data: ["files/data.txt",],
  37. libs: ["bar"],
  38. bazel_module: { bp2build_available: true },
  39. }
  40. python_library_host {
  41. name: "bar",
  42. srcs: ["b/e.py"],
  43. bazel_module: { bp2build_available: false },
  44. }`,
  45. ExpectedBazelTargets: []string{
  46. MakeBazelTarget("py_test", "foo", AttrNameToString{
  47. "data": `["files/data.txt"]`,
  48. "deps": `[":bar"]`,
  49. "main": `"a.py"`,
  50. "imports": `["."]`,
  51. "srcs": `[
  52. "a.py",
  53. "b/c.py",
  54. "b/d.py",
  55. ]`,
  56. "target_compatible_with": `select({
  57. "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
  58. "//conditions:default": [],
  59. })`,
  60. }),
  61. },
  62. })
  63. }