Support cc_test.isolated in bp2build

This property implicitly adds `libgtest_isolated_main` to the static
libs of the test. bp2build will make this and `liblog` explicit in BUILD
files

Since the deps are made explicit in BUILD files, `isolated` becomes a
no-op for cc_test. Remove this property from cc_test.

Test: unit tests
Bug: 244432609
Change-Id: I189a7b6b62d9064f4b2abad49ac4975468046498
diff --git a/cc/test.go b/cc/test.go
index bd8fba1..53a097a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -682,8 +682,7 @@
 type testBinaryAttributes struct {
 	binaryAttributes
 
-	Gtest    bool
-	Isolated bool
+	Gtest bool
 
 	tidyAttributes
 	tradefed.TestConfigAttributes
@@ -725,12 +724,11 @@
 	for _, propIntf := range m.GetProperties() {
 		if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {
 			testBinaryAttrs.Gtest = proptools.BoolDefault(testLinkerProps.Gtest, true)
-			testBinaryAttrs.Isolated = gtestIsolated
 			break
 		}
 	}
 
-	addImplicitGtestDeps(ctx, &testBinaryAttrs)
+	addImplicitGtestDeps(ctx, &testBinaryAttrs, gtestIsolated)
 
 	for _, testProps := range m.GetProperties() {
 		if p, ok := testProps.(*TestBinaryProperties); ok {
@@ -766,18 +764,25 @@
 
 // cc_test that builds using gtest needs some additional deps
 // addImplicitGtestDeps makes these deps explicit in the generated BUILD files
-func addImplicitGtestDeps(ctx android.BazelConversionPathContext, attrs *testBinaryAttributes) {
+func addImplicitGtestDeps(ctx android.BazelConversionPathContext, attrs *testBinaryAttributes, gtestIsolated bool) {
+	addDepsAndDedupe := func(lla *bazel.LabelListAttribute, modules []string) {
+		moduleLabels := android.BazelLabelForModuleDeps(ctx, modules)
+		lla.Value.Append(moduleLabels)
+		// Dedupe
+		lla.Value = bazel.FirstUniqueBazelLabelList(lla.Value)
+	}
+	// this must be kept in sync with Soong's implementation in:
+	// https://cs.android.com/android/_/android/platform/build/soong/+/460fb2d6d546b5ab493a7e5479998c4933a80f73:cc/test.go;l=300-313;drc=ec7314336a2b35ea30ce5438b83949c28e3ac429;bpv=1;bpt=0
 	if attrs.Gtest {
-		gtestDeps := android.BazelLabelForModuleDeps(
-			ctx,
-			[]string{
+		// TODO - b/244433197: Handle canUseSdk
+		if gtestIsolated {
+			addDepsAndDedupe(&attrs.Deps, []string{"libgtest_isolated_main"})
+			addDepsAndDedupe(&attrs.Dynamic_deps, []string{"liblog"})
+		} else {
+			addDepsAndDedupe(&attrs.Deps, []string{
 				"libgtest_main",
 				"libgtest",
-			},
-		)
-		attrs.Deps.Value.Append(gtestDeps)
-		// Dedupe
-		attrs.Deps.Value = bazel.FirstUniqueBazelLabelList(attrs.Deps.Value)
+			})
+		}
 	}
-	// TODO(b/244432609): handle `isolated` property.
 }