daml/ci/patch_bazel_windows/patch-bazel
Andreas Herrmann 4b1438276c
Update Bazel 2.1.0 --> 3.3.1 (#6761)
* Upgrade nixpkgs revision

* Remove unused minio

It used to be used as a gateway to push the Nix cache to GCS, but has
since been replaced by nix-store-gcs-proxy.

* Update Bazel on Windows

changelog_begin
changelog_end

* Fix hlint warnings

The nixpkgs update implied an hlint update which enabled new warnings.

* Fix "Error applying patch"

Since Bazel 2.2.0 the order of generating `WORKSPACE` and `BUILD` files
and applying patches has been reversed. The allows users to define
patches to these files that will not be immediately overwritten.
However, it also means that patches on another repository's original
`WORKSPACE` file will likely become invalid.

* a948eb7255
* https://github.com/bazelbuild/bazel/issues/10681

Hint: If you're generating a patch with `git` then you can use the
following command to exclude the `WORKSPACE` file.

```
git diff ':(exclude)WORKSPACE'
```

* Update rules_nixpkgs

* nixpkgs location expansion escaping

* Drop --noincompatible_windows_native_test_wrapper

* client_server_test using sh_inline_test

client_server_test used to produce an executable shell script in form of
a text file output. However, since the removal of
`--noincompatible_windows_native_test_wrapper` this no longer works on
Windows since `.sh` files are not directly executable on Windows.

This change fixes the issue by producing the script file in a dedicated
rule and then wrapping it in a `sh_test` rule which also works on
Windows.

* daml_test using sh_inline_test

* daml_doc_test using sh_inline_test

* _daml_validate_test using sh_inline_test

* damlc_compile_test using sh_inline_test

* client_server_test find .exe on Windows

* Bump Windows cache for Bazel update

Remove `clean --expunge` after merge.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-23 09:46:04 +02:00

141 lines
6.8 KiB
Plaintext

diff --git a/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html b/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html
index e665cc4a34..7f8cdf493d 100644
--- a/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html
+++ b/src/main/java/com/google/devtools/build/docgen/templates/attributes/common/tags.html
@@ -86,8 +86,9 @@
<li><code>exclusive</code> keyword will force the test to be run in the
&quot;exclusive&quot; mode, ensuring that no other tests are running at the
same time. Such tests will be executed in serial fashion after all build
- activity and non-exclusive tests have been completed. They will also always
- run locally and thus without sandboxing.
+ activity and non-exclusive tests have been completed. Remote execution is
+ disabled for such tests because Bazel doesn't have control over what's
+ running on a remote machine.
</li>
<li><code>manual</code> keyword will force the test target to not be included in target pattern
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java
index 214969c1a8..0de7325853 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestTargetProperties.java
@@ -87,9 +87,12 @@ public class TestTargetProperties {
Map<String, String> executionInfo = Maps.newLinkedHashMap();
executionInfo.putAll(TargetUtils.getExecutionInfo(rule));
- if (TargetUtils.isLocalTestRule(rule) || TargetUtils.isExclusiveTestRule(rule)) {
+ if (TargetUtils.isLocalTestRule(rule)) {
executionInfo.put(ExecutionRequirements.LOCAL, "");
}
+ if (TargetUtils.isExclusiveTestRule(rule)) {
+ executionInfo.put(ExecutionRequirements.NO_REMOTE_EXEC, "");
+ }
if (executionRequirements != null) {
// This will overwrite whatever TargetUtils put there, which might be confusing.
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index b55046dfe3..5271532d8b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -1031,6 +1031,7 @@ public class CppCompileAction extends AbstractAction implements IncludeScannable
looseHdrsDirs = Sets.newHashSet(ccCompilationContext.getLooseHdrsDirs().toList());
}
if (!isDeclaredIn(cppConfiguration, actionExecutionContext, input, looseHdrsDirs)) {
+ System.err.println("DA-DEBUG: isDeclaredIn was false" + input.getExecPath().toString());
errors.add(input.getExecPath().toString());
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
index 013e47d499..761fb2e28c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
@@ -154,6 +154,7 @@ public class HeaderDiscovery {
LabelConstants.EXPERIMENTAL_EXTERNAL_PATH_PREFIX.getRelative(
execPath.relativeTo(execRoot.getParentDirectory()));
} else {
+ System.err.println("DA-DEBUG: Absolute path " + execPathFragment.getPathString() + " outside of execroot " + execRoot);
problems.add(execPathFragment.getPathString());
continue;
}
@@ -181,6 +182,7 @@ public class HeaderDiscovery {
// Abort if we see files that we can't resolve, likely caused by
// undeclared includes or illegal include constructs.
+ System.err.println("DA-DEBUG: Valid system includes: " + permittedSystemIncludePrefixes.toString());
problems.add(execPathFragment.getPathString());
}
if (shouldValidateInclusions) {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/test/TestTargetPropertiesTest.java b/src/test/java/com/google/devtools/build/lib/rules/test/TestTargetPropertiesTest.java
index 5571f5fcde..0c0b113bba 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/test/TestTargetPropertiesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/test/TestTargetPropertiesTest.java
@@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.test;
import static com.google.common.truth.Truth.assertThat;
+import com.google.devtools.build.lib.actions.ExecutionRequirements;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.test.TestProvider;
@@ -50,4 +51,22 @@ public class TestTargetPropertiesTest extends BuildViewTestCase {
.getLocalResourceUsage(testAction.getOwner().getLabel(), false);
assertThat(localResourceUsage.getCpuUsage()).isEqualTo(4.0);
}
+
+ @Test
+ public void testTestWithExclusiveDisablesRemoteExecution() throws Exception {
+ scratch.file("tests/test.sh", "#!/bin/bash", "exit 0");
+ scratch.file(
+ "tests/BUILD",
+ "sh_test(",
+ " name = 'test',",
+ " size = 'small',",
+ " srcs = ['test.sh'],",
+ " tags = ['exclusive'],",
+ ")");
+ ConfiguredTarget testTarget = getConfiguredTarget("//tests:test");
+ TestRunnerAction testAction =
+ (TestRunnerAction)
+ getGeneratingAction(TestProvider.getTestStatusArtifacts(testTarget).get(0));
+ assertThat(testAction.getExecutionInfo()).isEqualTo(ExecutionRequirements.NO_REMOTE_EXEC);
+ }
}
diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh
index 9d9ff41dfb..4ed6f3c24d 100755
--- a/src/test/shell/bazel/remote/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote/remote_execution_test.sh
@@ -1845,6 +1845,34 @@ EOF
@default_foo//:all
}
+function test_exclusive_tag() {
+ # Test that the exclusive tag works with the remote cache.
+ mkdir -p a
+ cat > a/success.sh <<'EOF'
+#!/bin/sh
+exit 0
+EOF
+ chmod 755 a/success.sh
+ cat > a/BUILD <<'EOF'
+sh_test(
+ name = "success_test",
+ srcs = ["success.sh"],
+ tags = ["exclusive"],
+)
+EOF
+
+ bazel test \
+ --remote_cache=grpc://localhost:${worker_port} \
+ //a:success_test || fail "Failed to test //a:success_test"
+
+ bazel test \
+ --remote_cache=grpc://localhost:${worker_port} \
+ --nocache_test_results \
+ //a:success_test >& $TEST_log || fail "Failed to test //a:success_test"
+
+ expect_log "remote cache hit"
+}
+
# TODO(alpha): Add a test that fails remote execution when remote worker
# supports sandbox.