diff --git a/.bazelci/postsubmit.yml b/.bazelci/postsubmit.yml index 67f4a9ac43699a..ddb47ab1f8494d 100644 --- a/.bazelci/postsubmit.yml +++ b/.bazelci/postsubmit.yml @@ -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 @@ -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 diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index c474d1c9710d7a..a2f32dffa84885 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -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 @@ -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 diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java b/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java index 841d0f058bebd7..5bf080dcf6378b 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/Crosstool.java @@ -301,12 +301,24 @@ public String getToolchainExecConstraints() { public String getToolchainTargetConstraints() { ImmutableList 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); } @@ -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); } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD index 15459e8ec20e43..18e7e91f87759d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD @@ -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", diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java index cc9983c4973ece..9d811b5fbfb08e 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCommonTest.java @@ -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; @@ -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", diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyTestConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyTestConfiguredTargetTest.java index bb277f0c1d792d..f7e32a8894c29f 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PyTestConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyTestConfiguredTargetTest.java @@ -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(",