Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fbff97a8 authored by Jingwen Chen's avatar Jingwen Chen
Browse files

bp2build: Convert cc_test.test_options.tags to cc_test.tags

zeek@ has been tagging unit tests that cannot run on RBE with
"no-remote". While we don't yet have RBE support with standalone `b
test` yet, we can make sure to propagate the tags now.

Bug: 236973602

Test: new unit test
Change-Id: I6d0648f184626bb01c657068804f99ffb82907a3
parent 9a2d40c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -917,6 +917,8 @@ type CommonAttributes struct {
	Name string
	// Data mapped from: Required
	Data bazel.LabelListAttribute

	Tags bazel.StringListAttribute
}

// constraintAttributes represents Bazel attributes pertaining to build constraints,
+24 −0
Original line number Diff line number Diff line
@@ -148,3 +148,27 @@ cc_test {
		},
	})
}

func TestCcTest_TestOptions_Tags(t *testing.T) {
	runCcTestTestCase(t, ccTestBp2buildTestCase{
		description: "cc test with test_options.tags converted to tags",
		blueprint: `
cc_test {
    name: "mytest",
    host_supported: true,
    srcs: ["test.cpp"],
    test_options: { tags: ["no-remote"] },
}
`,
		targets: []testBazelTarget{
			{"cc_test", "mytest", AttrNameToString{
				"tags":           `["no-remote"]`,
				"local_includes": `["."]`,
				"srcs":           `["test.cpp"]`,
				"gtest":          "True",
				"isolated":       "True",
			},
			},
		},
	})
}
+3 −0
Original line number Diff line number Diff line
@@ -659,6 +659,7 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
	testBinaryAttrs.binaryAttributes = binaryBp2buildAttrs(ctx, m)

	var data bazel.LabelListAttribute
	var tags bazel.StringListAttribute

	testBinaryProps := m.GetArchVariantProperties(ctx, &TestBinaryProperties{})
	for axis, configToProps := range testBinaryProps {
@@ -670,6 +671,7 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
				combinedData.Append(android.BazelLabelForModuleDeps(ctx, p.Data_bins))
				combinedData.Append(android.BazelLabelForModuleDeps(ctx, p.Data_libs))
				data.SetSelectValue(axis, config, combinedData)
				tags.SetSelectValue(axis, config, p.Test_options.Tags)
			}
		}
	}
@@ -690,6 +692,7 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
		android.CommonAttributes{
			Name: m.Name(),
			Data: data,
			Tags: tags,
		},
		&testBinaryAttrs)
}