From 6aff7f4f2bf0c6418fb88e967653f2feeb83819e Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Wed, 9 Dec 2015 08:57:08 +0000 Subject: Refactor external repository support significantly to solve a number of issues. In particular: - Separate the implementation of maven_server into a RepositoryFunction and one that creates the MavenServerValue (ideally, maven_server wouldn't exist but we'll have to make to for the time being) - Refactor the logic of determining whether an external repository needs to be re-fetched to RepositoryDelegatorFunction - Make RepositoryFunctions not be SkyFunctions anymore (they are called from RepositoryDelegatorFunction, though, who *is* a SkyFunction) - Add a Skyframe dirtiness checker that makes --nofetch RepositoryValues not be cached - Add a bunch of test cases and javadoc There is only one wart that I know of that remains: changes to BUILD files of new_* repository rules that weren't refetched when their RepositoryValue was initiall created on server restart won't take effect. This is because we don't add those BUILD files to the created RepositoryValue. This will fix itself once the ExternalFilesHelper refactoring is submitted. -- MOS_MIGRATED_REVID=109768345 --- src/test/shell/bazel/git_repository_test.sh | 47 +++++++++++++++++++++++++++++ src/test/shell/bazel/maven_test.sh | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'src/test/shell') diff --git a/src/test/shell/bazel/git_repository_test.sh b/src/test/shell/bazel/git_repository_test.sh index 4beda0c47b..e9061d5b6c 100755 --- a/src/test/shell/bazel/git_repository_test.sh +++ b/src/test/shell/bazel/git_repository_test.sh @@ -267,6 +267,53 @@ EOF } +function test_git_repository_refetched_when_commit_changes() { + local repo_dir=$TEST_TMPDIR/repos/refetch + + cd $WORKSPACE_DIR + cat > WORKSPACE <& $TEST_log || fail "Build failed" + expect_log "Cloning" + assert_contains "GIT 1" bazel-genfiles/external/g/go + + cat > WORKSPACE <& $TEST_log || fail "Build failed" + expect_log "Cloning" + assert_contains "GIT 2" bazel-genfiles/external/g/go +} + +function test_git_repository_and_nofetch() { + local repo_dir=$TEST_TMPDIR/repos/refetch + + cd $WORKSPACE_DIR + cat > WORKSPACE <& $TEST_log && fail "Build succeeded" + expect_log "fetching repositories is disabled" + bazel build @g//:g >& $TEST_log || fail "Build failed" + assert_contains "GIT 1" bazel-genfiles/external/g/go + + cat > WORKSPACE <& $TEST_log || fail "Build failed" + expect_log "External repository 'g' is not up-to-date" + assert_contains "GIT 1" bazel-genfiles/external/g/go + bazel build @g//:g >& $TEST_log || fail "Build failed" + assert_contains "GIT 2" bazel-genfiles/external/g/go +} + # Helper function for setting up the workspace as follows # # $WORKSPACE_DIR/ diff --git a/src/test/shell/bazel/maven_test.sh b/src/test/shell/bazel/maven_test.sh index 94683e6738..4f36ef61d5 100755 --- a/src/test/shell/bazel/maven_test.sh +++ b/src/test/shell/bazel/maven_test.sh @@ -213,7 +213,7 @@ EOF chmod +x y.sh bazel build //:y &> $TEST_log && fail "Building thing failed" - expect_log "no such package '@x//'" + expect_log "does not represent an actual repository" } function test_auth() { -- cgit v1.2.3