aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2016-01-20 20:06:28 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-01-21 10:34:49 +0000
commitbd9f25c593a140acb15d3fd3fc7f66d091e1a898 (patch)
tree8a91d7d3aeb44f0e226138f73aa34fb4c49f1505 /src/test
parente87849b8d391af8f5d98e3a91e680e88a1264b64 (diff)
Add a DEVELOPER_DIR make variable to genrules to propagate the apple xcode environment variable DEVELOPER_DIR to commands.
If $(DEVELOPER_DIR) is included in the genrule command, we bootstrap the XCODE_VERSION_OVERRIDE environment variable to the command. The contract with the actual action executor is, if XCODE_VERSION_OVERRIDE is present in the environment, to additionally bootstrap the DEVELOPER_DIR absolute path to the command. -- MOS_MIGRATED_REVID=112605616
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java14
-rw-r--r--src/test/shell/bazel/BUILD8
-rwxr-xr-xsrc/test/shell/bazel/bazel_mac_genrule_test.sh52
3 files changed, 74 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
index 32f8027723..e763627037 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java
@@ -219,12 +219,26 @@ public abstract class BuildViewTestCase extends FoundationTestCase {
new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)),
ConstantRuleVisibility.PUBLIC, true, 7, "",
UUID.randomUUID());
+ // The below call evaluates and caches the build graph. If any modifications are made to
+ // packages which have already been set up, they will not be in the current cached build graph
+ // view. Call {@link #invalidateAllFiles} to clear this cache.
useConfiguration();
setUpSkyframe();
// Also initializes ResourceManager.
ResourceManager.instance().setAvailableResources(getStartingResources());
}
+ /**
+ * Clears the current build graph cache by invalidating all files.
+ */
+ protected void invalidateAllFiles() throws InterruptedException {
+ // This is necessary as the build graph may have already been evaluated and cached. If so,
+ // the previous setup steps in this method would not be taken into account in any of the
+ // build graphs for this class's tests.
+ getSkyframeExecutor().invalidateFilesUnderPathForTesting(reporter,
+ ModifiedFileSet.EVERYTHING_MODIFIED, rootDirectory);
+ }
+
protected AnalysisMock getAnalysisMock() {
try {
Class<?> providerClass = Class.forName(TestConstants.TEST_ANALYSIS_MOCK);
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index 21863ed6f0..6f179feefd 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -120,6 +120,14 @@ sh_test(
)
sh_test(
+ name = "bazel_mac_genrule_test",
+ srcs = ["bazel_mac_genrule_test.sh"],
+ data = [
+ ":test-deps",
+ ],
+)
+
+sh_test(
name = "bazel_execute_testlog",
srcs = ["bazel_execute_testlog.sh"],
data = [":test-deps"],
diff --git a/src/test/shell/bazel/bazel_mac_genrule_test.sh b/src/test/shell/bazel/bazel_mac_genrule_test.sh
new file mode 100755
index 0000000000..a7e0552eee
--- /dev/null
+++ b/src/test/shell/bazel/bazel_mac_genrule_test.sh
@@ -0,0 +1,52 @@
+#!/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.
+
+# Load test environment
+source $(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test-setup.sh \
+ || { echo "test-setup.sh not found!" >&2; exit 1; }
+
+if [ "${PLATFORM}" != "darwin" ]; then
+ echo "This test suite requires running on OS X" >&2
+ exit 0
+fi
+
+function test_developer_dir() {
+ mkdir -p package
+ # TODO(bazel-team): Local host genrule execution should convert
+ # the XCODE_VERSION_OVERRIDE environment variable to a DEVELOPER_DIR
+ # absolute path, preventing us from needing to set this environment
+ # variable ourself.
+ export DEVELOPER_DIR="/Applications/Xcode_5.4.app/Contents/Developer/"
+
+ echo "\\\${XCODE_VERSION_OVERRIDE}" ${DEVELOPER_DIR}
+
+ cat > package/BUILD <<EOF
+genrule(
+ name = "foo",
+ srcs = [],
+ outs = ["developerdir.out"],
+ tags = ["requires-darwin"],
+ cmd = "DEVELOPER_DIR='${DEVELOPER_DIR}' && echo \$\${XCODE_VERSION_OVERRIDE} \$(DEVELOPER_DIR) > \$@",
+)
+EOF
+
+ bazel build -s //package:foo --xcode_version=5.4 || fail "Should build"
+ assert_equals "5.4 /Applications/Xcode_5.4.app/Contents/Developer/" \
+ "$(cat bazel-genfiles/package/developerdir.out)" || \
+ fail "Unexpected value for DEVELOPER_DIR make variable"
+}
+
+run_suite "genrule test suite for Apple Mac hosts"