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