diff options
author | John Cater <jcater@google.com> | 2016-10-25 20:09:39 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-10-25 20:21:50 +0000 |
commit | e08f11c37cfe349c8b687d97100bf4a3af21719a (patch) | |
tree | bee981881edb1b153a58a0128f5a2d56204a57bc /src/test/shell | |
parent | d573fc0d5364fa4ade2ebb9ac644af8496738835 (diff) |
Adds a check that the new local repository path exists and is a
directory.
Fixes #1981.
--
Change-Id: I16a96be3f4f9de66e608b1914a2554613ddc096a
Reviewed-on: https://bazel-review.googlesource.com/c/6910/
MOS_MIGRATED_REVID=137192543
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/local_repository_test.sh | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/test/shell/bazel/local_repository_test.sh b/src/test/shell/bazel/local_repository_test.sh index 8a495c76e8..41452675ff 100755 --- a/src/test/shell/bazel/local_repository_test.sh +++ b/src/test/shell/bazel/local_repository_test.sh @@ -1087,6 +1087,7 @@ EOF # Regression test for https://github.com/bazelbuild/bazel/issues/792 function test_build_all() { local r=$TEST_TMPDIR/r + rm -rf $r mkdir -p $r touch $r/WORKSPACE cat > $r/BUILD <<'EOF' @@ -1120,6 +1121,7 @@ EOF # Regression test for #1697. function test_overwrite_build_file() { local r=$TEST_TMPDIR/r + rm -rf $r mkdir -p $r touch $r/WORKSPACE cat > $r/BUILD <<'EOF' @@ -1147,4 +1149,94 @@ EOF assert_contains "orig" $r/BUILD } +function test_new_local_repository_path_not_existing() { + local r=$TEST_TMPDIR/r + rm -rf $r + cat > WORKSPACE <<EOF +new_local_repository( + name = "r", + path = "$TEST_TMPDIR/r", + build_file_content = """ +genrule( + name = "rewrite", + cmd = "echo bar > \$@", + outs = ["rewrite.out"], +) +""", +) +EOF + bazel build @r//... &> $TEST_log && fail "Build succeeded unexpectedly" + expect_log "does not exist" +} + +function test_new_local_repository_path_not_directory() { + local r=$TEST_TMPDIR/r + rm -rf $r + touch $r + cat > WORKSPACE <<EOF +new_local_repository( + name = "r", + path = "$TEST_TMPDIR/r", + build_file_content = """ +genrule( + name = "rewrite", + cmd = "echo bar > \$@", + outs = ["rewrite.out"], +) +""", +) +EOF + bazel build @r//... &> $TEST_log && fail "Build succeeded unexpectedly" + expect_log "is not a directory" +} + +function test_new_local_repository_path_symlink_to_dir() { + local r=$TEST_TMPDIR/r + local s=$TEST_TMPDIR/s + rm -rf $r + rm -rf $s + mkdir -p $s + ln -s $s $r + + cat > WORKSPACE <<EOF +new_local_repository( + name = "r", + path = "$TEST_TMPDIR/r", + build_file_content = """ +genrule( + name = "rewrite", + cmd = "echo bar > \$@", + outs = ["rewrite.out"], +) +""", +) +EOF + bazel build @r//:rewrite &> $TEST_log || fail "Build failed" +} + +function test_new_local_repository_path_symlink_to_file() { + local r=$TEST_TMPDIR/r + local s=$TEST_TMPDIR/s + rm -rf $r + rm -rf $s + touch $s + ln -s $s $r + + cat > WORKSPACE <<EOF +new_local_repository( + name = "r", + path = "$TEST_TMPDIR/r", + build_file_content = """ +genrule( + name = "rewrite", + cmd = "echo bar > \$@", + outs = ["rewrite.out"], +) +""", +) +EOF + bazel build @r//:rewrite &> $TEST_log && fail "Build succeeded unexpectedly" + expect_log "is not a directory" +} + run_suite "local repository tests" |