Fix difference in default cc_test.isolated
in soong and bp2build
Soong defaults to false, while bp2build defaults to true. This CL fixes bp2build's default to false to match Soong. To prevent future differences, bp2build now uses the `isolated()` function used by Soong. The type of the context object has been changed to EarlyModuleContext so that the ctx object does not depend on mutations that might not run in bp2build. Test: TH Bug: 244432609 Change-Id: I15346107896312961e8d12270cf2f9a2a48827e1
This commit is contained in:
@@ -121,7 +121,7 @@ cc_test_library {
|
|||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
})`,
|
})`,
|
||||||
"gtest": "True",
|
"gtest": "True",
|
||||||
"isolated": "True",
|
"isolated": "False",
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
"dynamic_deps": `[":cc_test_lib2"] + select({
|
"dynamic_deps": `[":cc_test_lib2"] + select({
|
||||||
"//build/bazel/platforms/os:android": [":foolib"],
|
"//build/bazel/platforms/os:android": [":foolib"],
|
||||||
@@ -185,7 +185,7 @@ cc_test {
|
|||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
"srcs": `["test.cpp"]`,
|
"srcs": `["test.cpp"]`,
|
||||||
"gtest": "True",
|
"gtest": "True",
|
||||||
"isolated": "True",
|
"isolated": "False",
|
||||||
"deps": `[
|
"deps": `[
|
||||||
":libgtest_main",
|
":libgtest_main",
|
||||||
":libgtest",
|
":libgtest",
|
||||||
@@ -213,7 +213,7 @@ cc_test {
|
|||||||
targets: []testBazelTarget{
|
targets: []testBazelTarget{
|
||||||
{"cc_test", "mytest", AttrNameToString{
|
{"cc_test", "mytest", AttrNameToString{
|
||||||
"gtest": "True",
|
"gtest": "True",
|
||||||
"isolated": "True",
|
"isolated": "False",
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
"srcs": `["test.cpp"]`,
|
"srcs": `["test.cpp"]`,
|
||||||
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
||||||
@@ -244,7 +244,7 @@ cc_test {
|
|||||||
targets: []testBazelTarget{
|
targets: []testBazelTarget{
|
||||||
{"cc_test", "mytest", AttrNameToString{
|
{"cc_test", "mytest", AttrNameToString{
|
||||||
"gtest": "True",
|
"gtest": "True",
|
||||||
"isolated": "True",
|
"isolated": "False",
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
"srcs": `["test.cpp"]`,
|
"srcs": `["test.cpp"]`,
|
||||||
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
||||||
@@ -271,6 +271,7 @@ cc_test {
|
|||||||
srcs: ["test.cpp"],
|
srcs: ["test.cpp"],
|
||||||
test_config_template: "test_config_template.xml",
|
test_config_template: "test_config_template.xml",
|
||||||
auto_gen_config: true,
|
auto_gen_config: true,
|
||||||
|
isolated: true,
|
||||||
}
|
}
|
||||||
` + simpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
|
` + simpleModuleDoNotConvertBp2build("cc_library_static", "libgtest_main") +
|
||||||
simpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
|
simpleModuleDoNotConvertBp2build("cc_library_static", "libgtest"),
|
||||||
@@ -312,7 +313,7 @@ cc_test {
|
|||||||
targets: []testBazelTarget{
|
targets: []testBazelTarget{
|
||||||
{"cc_test", "mytest", AttrNameToString{
|
{"cc_test", "mytest", AttrNameToString{
|
||||||
"gtest": "True",
|
"gtest": "True",
|
||||||
"isolated": "True",
|
"isolated": "False",
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
"srcs": `["test.cpp"]`,
|
"srcs": `["test.cpp"]`,
|
||||||
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
||||||
|
@@ -267,7 +267,7 @@ func (test *testDecorator) gtest() bool {
|
|||||||
return BoolDefault(test.LinkerProperties.Gtest, true)
|
return BoolDefault(test.LinkerProperties.Gtest, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *testDecorator) isolated(ctx BaseModuleContext) bool {
|
func (test *testDecorator) isolated(ctx android.EarlyModuleContext) bool {
|
||||||
return BoolDefault(test.LinkerProperties.Isolated, false)
|
return BoolDefault(test.LinkerProperties.Isolated, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,10 +721,11 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
|
|||||||
|
|
||||||
m.convertTidyAttributes(ctx, &testBinaryAttrs.tidyAttributes)
|
m.convertTidyAttributes(ctx, &testBinaryAttrs.tidyAttributes)
|
||||||
|
|
||||||
|
gtestIsolated := m.linker.(*testBinary).isolated(ctx)
|
||||||
for _, propIntf := range m.GetProperties() {
|
for _, propIntf := range m.GetProperties() {
|
||||||
if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {
|
if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {
|
||||||
testBinaryAttrs.Gtest = proptools.BoolDefault(testLinkerProps.Gtest, true)
|
testBinaryAttrs.Gtest = proptools.BoolDefault(testLinkerProps.Gtest, true)
|
||||||
testBinaryAttrs.Isolated = proptools.BoolDefault(testLinkerProps.Isolated, true)
|
testBinaryAttrs.Isolated = gtestIsolated
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -742,7 +743,7 @@ func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
|
|||||||
p.Auto_gen_config,
|
p.Auto_gen_config,
|
||||||
p.Test_options.Test_suite_tag,
|
p.Test_options.Test_suite_tag,
|
||||||
p.Test_config_template,
|
p.Test_config_template,
|
||||||
getTradefedConfigOptions(ctx, p, testBinaryAttrs.Isolated),
|
getTradefedConfigOptions(ctx, p, gtestIsolated),
|
||||||
&testInstallBase,
|
&testInstallBase,
|
||||||
)
|
)
|
||||||
testBinaryAttrs.TestConfigAttributes = testConfigAttributes
|
testBinaryAttrs.TestConfigAttributes = testConfigAttributes
|
||||||
|
Reference in New Issue
Block a user