diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2015-12-02 09:51:33 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2015-12-02 22:25:27 +0000 |
commit | 01220b83fbe68932243d8428786ce294530a300d (patch) | |
tree | 5f3b5488da07b43ef9ee6ce147d6e968bee0f031 /src/test/shell | |
parent | 234cc16c22cd7c5a9c16de3b1e850843f656587c (diff) |
Add invalidation test when a Skylark file loaded from the WORKSPACE change
Fixes #672
--
MOS_MIGRATED_REVID=109174420
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/skylark_repository_test.sh | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh index bc1cd6ef82..0dcc4c5d63 100755 --- a/src/test/shell/bazel/skylark_repository_test.sh +++ b/src/test/shell/bazel/skylark_repository_test.sh @@ -30,13 +30,13 @@ function test_macro_local_repository() { cat > carnivore/BUILD <<'EOF' genrule( name = "mongoose", - cmd = "echo 'Tra-la!' > $@", + cmd = "echo 'Tra-la!' | tee $@", outs = ["moogoose.txt"], visibility = ["//visibility:public"], ) EOF + cd ${WORKSPACE_DIR} - pwd cat > WORKSPACE <<EOF load('/test', 'macro') @@ -72,12 +72,52 @@ EOF bazel build //zoo:ball-pit1 >& $TEST_log || fail "Failed to build" expect_log "bleh." + expect_log "Tra-la!" # Invalidation cat bazel-genfiles/zoo/ball-pit1.txt >$TEST_log expect_log "Tra-la!" + bazel build //zoo:ball-pit1 >& $TEST_log || fail "Failed to build" + expect_not_log "Tra-la!" # No invalidation + bazel build //zoo:ball-pit2 >& $TEST_log || fail "Failed to build" + expect_not_log "Tra-la!" # No invalidation cat bazel-genfiles/zoo/ball-pit2.txt >$TEST_log expect_log "Tra-la!" + + # Test invalidation of the WORKSPACE file + create_new_workspace + repo2=$new_workspace_dir + + mkdir -p carnivore + cat > carnivore/BUILD <<'EOF' +genrule( + name = "mongoose", + cmd = "echo 'Tra-la-la!' | tee $@", + outs = ["moogoose.txt"], + visibility = ["//visibility:public"], +) +EOF + cd ${WORKSPACE_DIR} + cat >test.bzl <<EOF +def macro(path): + print('blah') + native.local_repository(name='endangered', path='$repo2') + native.bind(name='mongoose', actual='@endangered//carnivore:mongoose') +EOF + bazel build //zoo:ball-pit1 >& $TEST_log || fail "Failed to build" + expect_log "blah." + expect_log "Tra-la-la!" # Invalidation + cat bazel-genfiles/zoo/ball-pit1.txt >$TEST_log + expect_log "Tra-la-la!" + + bazel build //zoo:ball-pit1 >& $TEST_log || fail "Failed to build" + expect_not_log "Tra-la-la!" # No invalidation + + bazel build //zoo:ball-pit2 >& $TEST_log || fail "Failed to build" + expect_not_log "Tra-la-la!" # No invalidation + cat bazel-genfiles/zoo/ball-pit2.txt >$TEST_log + expect_log "Tra-la-la!" + } function tear_down() { |