aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-02-10 13:29:46 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2016-02-10 16:34:47 +0000
commit6f07b795763fcde7716fa12d124c65e553a50c47 (patch)
tree126642070968c705102fd2b548d65dac3ff08de0 /src/test/shell
parentea02b8a51fc924755971f78e392100b50d8dc5a2 (diff)
Allow load of external label in the WORKSPACE file.
Issue #824 Step 5. The only thing left to resolve issue #824 are correct handling of the following cases: - Forbidding overloading of a repository outside of the first part of the workspace file (or it will leads to incorrectness issue and the only use-case is the redefinition of the bazel_tools repository). - Better error reporting when trying to refer to a non-existent repository from the workspace file, for now it will print a SkyFrame cycle exception. -- MOS_MIGRATED_REVID=114316464
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/skylark_repository_test.sh51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh
index 3d59bda4be..3c20c9c321 100755
--- a/src/test/shell/bazel/skylark_repository_test.sh
+++ b/src/test/shell/bazel/skylark_repository_test.sh
@@ -117,7 +117,6 @@ EOF
expect_not_log "Tra-la-la!" # No invalidation
cat bazel-genfiles/zoo/ball-pit2.txt >$TEST_log
expect_log "Tra-la-la!"
-
}
function test_load_from_symlink_to_outside_of_workspace() {
@@ -140,38 +139,44 @@ EOF
rm -fr $TEST_TMPDIR/other
}
-# Loading a skylark file located in an external repo from a WORKSPACE file
-# is disallowed.
-function test_external_load_from_workspace_file_invalid() {
+# Test load from repository.
+function test_external_load_from_workspace() {
create_new_workspace
- external_repo=${new_workspace_dir}
-
- cat > ${WORKSPACE_DIR}/WORKSPACE <<EOF
-local_repository(name = "external_repo", path = "${external_repo}")
-load("@external_repo//external_pkg:ext.bzl", "CONST")
-EOF
+ repo2=$new_workspace_dir
- mkdir ${WORKSPACE_DIR}/local_pkg
- cat > ${WORKSPACE_DIR}/local_pkg/BUILD <<EOF
+ mkdir -p carnivore
+ cat > carnivore/BUILD <<'EOF'
genrule(
- name = "shouldnt_be_built",
- cmd = "echo echo"
+ name = "mongoose",
+ cmd = "echo 'Tra-la-la!' | tee $@",
+ outs = ["moogoose.txt"],
+ visibility = ["//visibility:public"],
)
EOF
- mkdir ${external_repo}/external_pkg
- touch ${external_repo}/external_pkg/BUILD
- cat > ${external_repo}/external_pkg/ext.bzl <<EOF
-CONST = 17
+ create_new_workspace
+ repo3=$new_workspace_dir
+ # Our macro
+ cat >WORKSPACE
+ cat >test.bzl <<EOF
+def macro(path):
+ print('bleh')
+ native.local_repository(name='endangered', path=path)
+EOF
+ cat >BUILD <<'EOF'
+exports_files(["test.bzl"])
EOF
cd ${WORKSPACE_DIR}
- bazel build local_pkg:shouldnt_be_built >& $TEST_log && \
- fail "Expected build to fail" || true
+ cat > WORKSPACE <<EOF
+local_repository(name='proxy', path='$repo3')
+load('@proxy//:test.bzl', 'macro')
+macro('$repo2')
+EOF
- expect_log "Extension file '@external_repo//external_pkg:ext.bzl' may not be \
-loaded from a WORKSPACE file since the extension file is located in an \
-external repository."
+ bazel build @endangered//carnivore:mongoose >& $TEST_log \
+ || fail "Failed to build"
+ expect_log "bleh."
}
function tear_down() {