Skip to content

Commit

Permalink
Reenable C++ tests on Mac
Browse files Browse the repository at this point in the history
Closes bazelbuild#20784.

PiperOrigin-RevId: 597193470
Change-Id: Ia84f05a4704d35ab65ab68ce514e474900091d08
  • Loading branch information
comius authored and meteorcloudy committed Feb 21, 2024
1 parent 1d46604 commit dfe70fa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 44 deletions.
12 changes: 0 additions & 12 deletions .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ tasks:
- "-//src/test/shell/bazel/android:android_instrumentation_test_integration_test_with_head_android_tools"
- "-//src/test/shell/bazel/android:aapt_integration_test"
- "-//src/test/shell/bazel/android:aapt_integration_test_with_head_android_tools"
# Disable recently regressed tests: https://github.com/bazelbuild/bazel/issues/20437
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CppSysrootTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcImportConfiguredTargetTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:ObjcRulesTests"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:BazelJ2ObjcLibraryTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcToolchainTest"
include_json_profile:
- build
- test
Expand Down Expand Up @@ -288,12 +282,6 @@ tasks:
- "-//src/test/shell/bazel/android:android_instrumentation_test_integration_test_with_head_android_tools"
- "-//src/test/shell/bazel/android:aapt_integration_test"
- "-//src/test/shell/bazel/android:aapt_integration_test_with_head_android_tools"
# Disable recently regressed tests: https://github.com/bazelbuild/bazel/issues/20437
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CppSysrootTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcImportConfiguredTargetTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:ObjcRulesTests"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:BazelJ2ObjcLibraryTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcToolchainTest"
# https://github.com/bazelbuild/bazel/issues/17411
- "-//src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace:PatchApiBlackBoxTest"
# https://github.com/bazelbuild/bazel/issues/17447
Expand Down
13 changes: 0 additions & 13 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,6 @@ tasks:
- "-//src/test/shell/bazel/android:android_instrumentation_test_integration_test_with_head_android_tools"
- "-//src/test/shell/bazel/android:aapt_integration_test"
- "-//src/test/shell/bazel/android:aapt_integration_test_with_head_android_tools"
# Disable recently regressed tests: https://github.com/bazelbuild/bazel/issues/20437
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CppSysrootTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcImportConfiguredTargetTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:ObjcRulesTests"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:BazelJ2ObjcLibraryTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcToolchainTest"
include_json_profile:
- build
- test
Expand Down Expand Up @@ -346,13 +340,6 @@ tasks:
- "-//src/test/shell/bazel/android:android_instrumentation_test_integration_test_with_head_android_tools"
- "-//src/test/shell/bazel/android:aapt_integration_test"
- "-//src/test/shell/bazel/android:aapt_integration_test_with_head_android_tools"
# Disable recently regressed tests: https://github.com/bazelbuild/bazel/issues/20437
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CppSysrootTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcImportConfiguredTargetTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:ObjcRulesTests"
- "-//src/test/java/com/google/devtools/build/lib/rules/objc:BazelJ2ObjcLibraryTest"
- "-//src/test/java/com/google/devtools/build/lib/rules/cpp:CcToolchainTest"
- "-//src/test/shell/integration:minimal_jdk_test"
# https://github.com/bazelbuild/bazel/issues/17411
- "-//src/test/java/com/google/devtools/build/lib/blackbox/tests/workspace:PatchApiBlackBoxTest"
# https://github.com/bazelbuild/bazel/issues/17447
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,24 @@ public String getToolchainExecConstraints() {

public String getToolchainTargetConstraints() {
ImmutableList<String> constraints = this.toolchainTargetConstraints;
if (constraints.isEmpty() && getTargetCpu().equals("k8")) {
// Use default constraints
constraints =
ImmutableList.of(
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64",
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:linux");
if (constraints.isEmpty()) {
if (getTargetCpu().equals("k8")) {
// Use default constraints
constraints =
ImmutableList.of(
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64",
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:linux");
} else if (getTargetCpu().equals("darwin_x86_64")) {
constraints =
ImmutableList.of(
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64",
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:macos");
} else if (getTargetCpu().equals("darwin_arm64")) {
constraints =
ImmutableList.of(
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:arm64",
TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:macos");
}
}
return formatConstraints("target", constraints);
}
Expand Down Expand Up @@ -727,15 +739,14 @@ public void writeOSX() throws IOException {
" toolchain_type = '" + TestConstants.TOOLS_REPOSITORY + "//tools/cpp:toolchain_type'",
")");
crosstoolBuild.add(toolchainConfig.getCcToolchainConfigRule());
// Add the newly-created toolchain to the WORKSPACE.
config.append(
"WORKSPACE",
"register_toolchains('//" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL_DIR + ":all')");
}

config.overwrite(
MockObjcSupport.DEFAULT_OSX_CROSSTOOL_DIR + "/BUILD",
Joiner.on("\n").join(crosstoolBuild.build()));
config.append(
"WORKSPACE",
"register_toolchains('//" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL_DIR + ":all')");
config.overwrite(crosstoolTop + "/cc_toolchain_config.bzl", ccToolchainConfigFileContents);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ java_test(
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
"//src/main/java/com/google/devtools/build/lib/util:os",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/test/java/com/google/devtools/build/lib/actions/util",
"//src/test/java/com/google/devtools/build/lib/analysis/util",
"//src/test/java/com/google/devtools/build/lib/packages:testutil",
"//src/test/java/com/google/devtools/build/lib/testutil:TestConstants",
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.util.Crosstool.CcToolchainConfig;
import com.google.devtools.build.lib.packages.util.MockCcSupport;
import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -710,7 +711,17 @@ public void testExpandLabelInLinkoptsAgainstSrc() throws Exception {
@Test
public void testCcLibraryWithDashStaticOnDarwin() throws Exception {
getAnalysisMock().ccSupport().setupCcToolchainConfigForCpu(mockToolsConfig, "darwin_x86_64");
useConfiguration("--cpu=darwin_x86_64");
mockToolsConfig.create(
"platforms/BUILD",
"platform(",
" name = 'darwin_x86_64',",
" constraint_values = [",
" '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:macos',",
" '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64',",
" ],",
")");
useConfiguration("--cpu=darwin_x86_64", "--platforms=//platforms:darwin_x86_64");

checkError(
"badlib",
"lib_with_dash_static",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ public void macRequiresDarwinForExecution() throws Exception {
// The default mock environment doesn't have platform_mappings (which map --cpu to a platform),
// nor does it have Apple platforms defined, so we have to set one up ourselves.
mockToolsConfig.create(
"mockplatforms/BUILD",
"platforms/BUILD",
"platform(",
" name='macos',",
String.format(
" constraint_values=['%sos:macos'],", TestConstants.CONSTRAINTS_PACKAGE_ROOT),
")",
"");
useConfiguration("--cpu=darwin_x86_64", "--platforms=//mockplatforms:macos");
" name = 'darwin_x86_64',",
" constraint_values = [",
" '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "os:macos',",
" '" + TestConstants.CONSTRAINTS_PACKAGE_ROOT + "cpu:x86_64',",
" ],",
")");
useConfiguration("--cpu=darwin_x86_64", "--platforms=//platforms:darwin_x86_64");
scratch.file(
"pkg/BUILD", //
"py_test(",
Expand Down

0 comments on commit dfe70fa

Please sign in to comment.