diff options
author | Yue Gan <yueg@google.com> | 2016-04-08 08:35:46 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-04-08 14:34:46 +0000 |
commit | 0eda09d599c9eb83bf3ebb747d9dcb0390453999 (patch) | |
tree | a1b177e5a412d86c4188f555762cfdc8aa270f4c /src | |
parent | 3ab018d6d8f49eb4eee7cbefee094fb68c3051a3 (diff) |
Run test in standalone mode with "local = 1". Fixes #1052.
--
MOS_MIGRATED_REVID=119351752
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java | 3 | ||||
-rw-r--r-- | src/test/shell/bazel/BUILD | 7 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_localtest_test.sh | 50 |
3 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java index c8190e48e4..4cd561c6fc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java @@ -83,6 +83,9 @@ public class TestTargetProperties { Map<String, String> executionInfo = Maps.newLinkedHashMap(); executionInfo.putAll(TargetUtils.getExecutionInfo(rule)); + if (isLocal) { + executionInfo.put("local", ""); + } if (executionRequirements != null) { // This will overwrite whatever TargetUtils put there, which might be confusing. executionInfo.putAll(executionRequirements.getExecutionInfo()); diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD index 81a570edb3..8f09a4729c 100644 --- a/src/test/shell/bazel/BUILD +++ b/src/test/shell/bazel/BUILD @@ -98,6 +98,13 @@ sh_test( ) sh_test( + name = "bazel_localtest_test", + srcs = ["bazel_localtest_test.sh"], + data = [":test-deps"], + tags = ["local"], +) + +sh_test( name = "bazel_objc_test", srcs = ["bazel_objc_test.sh"], data = [ diff --git a/src/test/shell/bazel/bazel_localtest_test.sh b/src/test/shell/bazel/bazel_localtest_test.sh new file mode 100755 index 0000000000..0034d47eb6 --- /dev/null +++ b/src/test/shell/bazel/bazel_localtest_test.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +# Load test environment +source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \ + || { echo "test-setup.sh not found!" >&2; exit 1; } + +function test_run_local() { + mkdir -p dir + cat > emptyfile + + # In standalone mode, + # we have access to /var which is not mounted in sandboxed mode + cat <<EOF > dir/test_local.sh +#!/bin/bash +test -e "$(pwd)/emptyfile" && exit 0 || true +echo "no $(pwd)/emptyfile in standalone mode" +exit 1 +EOF + + chmod +x dir/test_local.sh + + cat <<EOF > dir/BUILD +sh_test( + name = "localtest", + srcs = [ "test_local.sh" ], + size = "small", + local = 1 +) +EOF + + bazel test //dir:all &> $TEST_log || fail "expected success" +} + +run_suite "test tests" |