From 91a7a34fb46fa04165ac90ca095d1272f2a39327 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 16 Jun 2016 14:55:33 +0000 Subject: Create mark file for local repositories, too Local repositories were not marked, so if a WS file switched from remote->local->remote, on the first run the remote rule would create a mark file, on the second run the local rule would ignore it, and then on the third run the remote rule would look at the mark file and see, "I'm already up-to-date," leaving the repository as a local repo. Fixes #977. -- MOS_MIGRATED_REVID=125060180 --- src/test/shell/bazel/external_correctness_test.sh | 17 +++++-- src/test/shell/bazel/external_integration_test.sh | 55 ++++++++++++++++------- 2 files changed, 52 insertions(+), 20 deletions(-) (limited to 'src/test/shell') diff --git a/src/test/shell/bazel/external_correctness_test.sh b/src/test/shell/bazel/external_correctness_test.sh index 4141a8ccd2..6d79320fe6 100755 --- a/src/test/shell/bazel/external_correctness_test.sh +++ b/src/test/shell/bazel/external_correctness_test.sh @@ -287,7 +287,8 @@ EOF } -function test_top_level_dir_changes() { +function top_level_dir_changes_helper() { + batch_flag="$1" mkdir -p r/subdir m touch r/one r/subdir/two @@ -305,16 +306,24 @@ genrule( ) EOF cd m - bazel build @r//:fg &> $TEST_log || \ + bazel "$batch_flag" build @r//:fg &> $TEST_log || \ fail "Expected build to succeed" touch ../r/three - bazel build @r//:fg &> $TEST_log || \ + bazel "$batch_flag" build @r//:fg &> $TEST_log || \ fail "Expected build to succeed" assert_contains "external/r/three" bazel-genfiles/external/r/fg.out touch ../r/subdir/four - bazel build @r//:fg &> $TEST_log || \ + bazel "$batch_flag" build @r//:fg &> $TEST_log || \ fail "Expected build to succeed" assert_contains "external/r/subdir/four" bazel-genfiles/external/r/fg.out } +function test_top_level_dir_changes_batch() { + top_level_dir_changes_helper --batch +} + +function test_top_level_dir_changes_nobatch() { + top_level_dir_changes_helper --nobatch +} + run_suite "//external correctness tests" diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index f41b001639..4873710775 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -281,22 +281,6 @@ EOF expect_log $what_does_the_fox_say } -# Pending proper external file handling -function DISABLED_test_changed_zip() { - nc_port=$(pick_random_unused_tcp_port) || fail "Couldn't get TCP port" - http_archive_helper zip_up - http_archive_helper zip_up "nowrite" - expect_not_log "Downloading from" - local readonly output_base=$(bazel info output_base) - local readonly repo_zip=$output_base/external/endangered/fox.zip - rm $repo_zip || fail "Couldn't delete $repo_zip" - touch $repo_zip || fail "Couldn't touch $repo_zip" - [[ -s $repo_zip ]] && fail "File size not 0" - http_archive_helper zip_up "nowrite" - expect_log "Downloading from" - [[ -s $repo_zip ]] || fail "File size was 0" -} - function test_cached_across_server_restart() { http_archive_helper zip_up bazel shutdown >& $TEST_log || fail "Couldn't shut down" @@ -825,4 +809,43 @@ EOF expect_log "//external:androidsdk" } +function test_flip_flopping() { + REPO_PATH=$TEST_TMPDIR/repo + mkdir -p "$REPO_PATH" + cd "$REPO_PATH" + touch WORKSPACE BUILD foo + zip -r repo.zip * + startup_server $PWD + # Make the remote repo and local repo slightly different. + rm foo + touch bar + cd - + + cat > local_ws < remote_ws < $TEST_log || fail "Build failed" + test -L "$external_dir/repo" || fail "creating local symlink failed" + test -a "$external_dir/repo/bar" || fail "bar not found" + cp remote_ws WORKSPACE + bazel build @repo//:all &> $TEST_log || fail "Build failed" + test -d "$external_dir//repo" || fail "creating remote repo failed" + test -a "$external_dir/repo/foo" || fail "foo not found" + done + + shutdown_server +} + run_suite "external tests" -- cgit v1.2.3