diff options
author | 2016-03-17 16:40:42 +0000 | |
---|---|---|
committer | 2016-03-18 12:45:10 +0000 | |
commit | 36532fced0440d231c43dba3d16be775c9c1fd19 (patch) | |
tree | 5aae3f26ea0dcf6024219176956b98a98d35f4b3 /src/test/shell/bazel/skylark_repository_test.sh | |
parent | 22fb90cd7bcc6aafd1cf30de3c77e3025b5c48c2 (diff) |
Add detection of WORKSPACE cycles due to load statements
Cycle when looking for a repository name will now shows a user-understable error.
Fixes #877.
--
MOS_MIGRATED_REVID=117453646
Diffstat (limited to 'src/test/shell/bazel/skylark_repository_test.sh')
-rwxr-xr-x | src/test/shell/bazel/skylark_repository_test.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh index 283bf6bc39..734a56caa2 100755 --- a/src/test/shell/bazel/skylark_repository_test.sh +++ b/src/test/shell/bazel/skylark_repository_test.sh @@ -216,6 +216,40 @@ EOF expect_log "Tra-la!" } +# Test cycle when loading a repository with a load statement in the WORKSPACE file that is not +# yet defined. +function test_cycle_load_repository() { + create_new_workspace + repo2=$new_workspace_dir + + echo "Tra-la!" > data.txt + cat <<'EOF' >BUILD +exports_files(["data.txt"]) +EOF + + cat <<'EOF' >ext.bzl +def macro(): + print('bleh') +EOF + + cat >WORKSPACE + + cd ${WORKSPACE_DIR} + cat > WORKSPACE <<EOF +load("@foo//:ext.bzl", "macro") +macro() +local_repository(name='foo', path='$repo2') +EOF + + local exitCode=0 + bazel build @foo//:data.txt >& $TEST_log || exitCode=$? + [ $exitCode != 0 ] || fail "building @foo//:data.txt succeed while expected failure" + + expect_not_log "PACKAGE" + expect_log "Failed to load Skylark extension '@foo//:ext.bzl'" + expect_log "Maybe repository 'foo' was defined later in your WORKSPACE file?" +} + function test_skylark_local_repository() { create_new_workspace repo2=$new_workspace_dir |