Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
This commit is contained in:
@@ -17,10 +17,9 @@ func runBp2BuildTestCaseWithPythonLibraries(t *testing.T, tc bp2buildTestCase) {
|
||||
|
||||
func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
runBp2BuildTestCaseWithPythonLibraries(t, bp2buildTestCase{
|
||||
description: "simple python_binary_host converts to a native py_binary",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
||||
description: "simple python_binary_host converts to a native py_binary",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
filesystem: map[string]string{
|
||||
"a.py": "",
|
||||
"b/c.py": "",
|
||||
@@ -40,7 +39,7 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
python_library_host {
|
||||
name: "bar",
|
||||
srcs: ["b/e.py"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
@@ -59,10 +58,9 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
|
||||
func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "py2 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
||||
description: "py2 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
blueprint: `python_binary_host {
|
||||
name: "foo",
|
||||
srcs: ["a.py"],
|
||||
@@ -89,10 +87,9 @@ func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
|
||||
func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "py3 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
||||
description: "py3 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
blueprint: `python_binary_host {
|
||||
name: "foo",
|
||||
srcs: ["a.py"],
|
||||
@@ -119,10 +116,9 @@ func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
|
||||
func TestPythonBinaryHostArchVariance(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "test arch variants",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
||||
description: "test arch variants",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
filesystem: map[string]string{
|
||||
"dir/arm.py": "",
|
||||
"dir/x86.py": "",
|
||||
|
Reference in New Issue
Block a user