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

Commit 6ee23ad2 authored by Jingwen Chen's avatar Jingwen Chen
Browse files

cc_test mixed builds: suffix bazel label with __tf_internal.

To support `b test //path/to:my_test` command line, the actual
executable in the cc_test macro now has the __tf_internal suffix in its
name, so that the top level test suite target can be named without any suffixes.

See other CLs in this topic for more info.

Test: presubmits
Fixes: 292159775
Change-Id: I2d0bfc4276717ae881f6f3eb6aefa88bb47f25da
parent 41a58a97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3261,7 +3261,7 @@ func TestLibDepAndroidMkExportInMixedBuilds(t *testing.T) {
							},
						},
						LabelToCcBinary: map[string]cquery.CcUnstrippedInfo{
							"//:test": cquery.CcUnstrippedInfo{
							"//:test__tf_internal": cquery.CcUnstrippedInfo{
								CcAndroidMkInfo: tc.androidMkInfo,
							},
							"//:binary": cquery.CcUnstrippedInfo{
+15 −2
Original line number Diff line number Diff line
@@ -641,14 +641,27 @@ type ccTestBazelHandler struct {

var _ BazelHandler = (*ccTestBazelHandler)(nil)

// The top level target named $label is a test_suite target,
// not the internal cc_test executable target.
//
// This is to ensure `b test //$label` runs the test_suite target directly,
// which depends on tradefed_test targets, instead of the internal cc_test
// target, which doesn't have tradefed integrations.
//
// However, for cquery, we want the internal cc_test executable target, which
// has the suffix "__tf_internal".
func mixedBuildsTestLabel(label string) string {
	return label + "__tf_internal"
}

func (handler *ccTestBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
	bazelCtx := ctx.Config().BazelContext
	bazelCtx.QueueBazelRequest(label, cquery.GetCcUnstrippedInfo, android.GetConfigKey(ctx))
	bazelCtx.QueueBazelRequest(mixedBuildsTestLabel(label), cquery.GetCcUnstrippedInfo, android.GetConfigKey(ctx))
}

func (handler *ccTestBazelHandler) ProcessBazelQueryResponse(ctx android.ModuleContext, label string) {
	bazelCtx := ctx.Config().BazelContext
	info, err := bazelCtx.GetCcUnstrippedInfo(label, android.GetConfigKey(ctx))
	info, err := bazelCtx.GetCcUnstrippedInfo(mixedBuildsTestLabel(label), android.GetConfigKey(ctx))
	if err != nil {
		ctx.ModuleErrorf(err.Error())
		return