blob: fa2e48507f3b52f9f661fa24b25c706e0b48711c [file] [log] [blame]
Cole Faustd82f0362023-04-12 17:32:19 -07001// 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 (
Cole Faustd82f0362023-04-12 17:32:19 -070018 "testing"
Chris Parsonscd209032023-09-19 01:12:48 +000019
20 "android/soong/python"
Cole Faustd82f0362023-04-12 17:32:19 -070021)
22
23func 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 Parsonscd209032023-09-19 01:12:48 +000035 StubbedBuildDefinitions: []string{"bar"},
Cole Faustd82f0362023-04-12 17:32:19 -070036 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 Faustd82f0362023-04-12 17:32:19 -070048 }`,
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}