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