@@ -120,15 +120,15 @@ EOF
120120 bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
121121 expect_log " bleh"
122122 expect_log " Tra-la!" # Invalidation
123- cat bazel-genfiles /zoo/ball-pit1.txt > $TEST_log
123+ cat bazel-bin /zoo/ball-pit1.txt > $TEST_log
124124 expect_log " Tra-la!"
125125
126126 bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
127127 expect_not_log " Tra-la!" # No invalidation
128128
129129 bazel build //zoo:ball-pit2 >& $TEST_log || fail " Failed to build"
130130 expect_not_log " Tra-la!" # No invalidation
131- cat bazel-genfiles /zoo/ball-pit2.txt > $TEST_log
131+ cat bazel-bin /zoo/ball-pit2.txt > $TEST_log
132132 expect_log " Tra-la!"
133133
134134 # Test invalidation of the WORKSPACE file
@@ -154,15 +154,15 @@ EOF
154154 bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
155155 expect_log " blah"
156156 expect_log " Tra-la-la!" # Invalidation
157- cat bazel-genfiles /zoo/ball-pit1.txt > $TEST_log
157+ cat bazel-bin /zoo/ball-pit1.txt > $TEST_log
158158 expect_log " Tra-la-la!"
159159
160160 bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
161161 expect_not_log " Tra-la-la!" # No invalidation
162162
163163 bazel build //zoo:ball-pit2 >& $TEST_log || fail " Failed to build"
164164 expect_not_log " Tra-la-la!" # No invalidation
165- cat bazel-genfiles /zoo/ball-pit2.txt > $TEST_log
165+ cat bazel-bin /zoo/ball-pit2.txt > $TEST_log
166166 expect_log " Tra-la-la!"
167167}
168168
355355 bazel build @foo//:bar >& $TEST_log || fail " Failed to build"
356356 expect_log " foo"
357357 expect_not_log " Workspace name in .*/WORKSPACE (.*) does not match the name given in the repository's definition (@foo)"
358- cat bazel-genfiles /external/foo/bar.txt > $TEST_log
358+ cat bazel-bin /external/foo/bar.txt > $TEST_log
359359 expect_log " foo"
360360}
361361
@@ -892,8 +892,8 @@ build:bar --repo_env=FOO=bar
892892EOF
893893
894894 bazel build --config=foo //:repoenv //:unrelated
895- cp ` bazel info bazel-genfiles 2> /dev/null` /repoenv.txt repoenv1.txt
896- cp ` bazel info bazel-genfiles 2> /dev/null` /unrelated.txt unrelated1.txt
895+ cp ` bazel info bazel-bin 2> /dev/null` /repoenv.txt repoenv1.txt
896+ cp ` bazel info bazel-bin 2> /dev/null` /unrelated.txt unrelated1.txt
897897 echo ; cat repoenv1.txt; echo ; cat unrelated1.txt; echo
898898
899899 grep -q ' FOO=foo' repoenv1.txt \
904904 FOO=CHANGED bazel build --config=foo //:repoenv //:unrelated
905905 # nothing should change, as actions don't see FOO and for repositories
906906 # the value is fixed by --repo_env
907- cp ` bazel info bazel-genfiles 2> /dev/null` /repoenv.txt repoenv2.txt
908- cp ` bazel info bazel-genfiles 2> /dev/null` /unrelated.txt unrelated2.txt
907+ cp ` bazel info bazel-bin 2> /dev/null` /repoenv.txt repoenv2.txt
908+ cp ` bazel info bazel-bin 2> /dev/null` /unrelated.txt unrelated2.txt
909909 echo ; cat repoenv2.txt; echo ; cat unrelated2.txt; echo
910910
911911 diff repoenv1.txt repoenv2.txt \
916916 bazel build --config=bar //:repoenv //:unrelated
917917 # The new config should be picked up, but the unrelated target should
918918 # not be rerun
919- cp ` bazel info bazel-genfiles 3> /dev/null` /repoenv.txt repoenv3.txt
920- cp ` bazel info bazel-genfiles 3> /dev/null` /unrelated.txt unrelated3.txt
919+ cp ` bazel info bazel-bin 3> /dev/null` /repoenv.txt repoenv3.txt
920+ cp ` bazel info bazel-bin 3> /dev/null` /unrelated.txt unrelated3.txt
921921 echo ; cat repoenv3.txt; echo ; cat unrelated3.txt; echo
922922
923923 grep -q ' FOO=bar' repoenv3.txt \
926926 || fail " Expected unrelated action to not be rerun"
927927}
928928
929+ function test_repo_env_inverse() {
930+ # This test makes sure that a repository rule that has no dependencies on
931+ # environment variables does _not_ get refetched when --repo_env changes.
932+ setup_starlark_repository
933+
934+ cat > test.bzl << 'EOF '
935+ def _impl(ctx):
936+ # Record a time stamp to verify that the rule is not rerun.
937+ ctx.execute(["bash", "-c", "date +%s >> env.txt"])
938+ ctx.file("BUILD", 'exports_files(["env.txt"])')
939+
940+ repo = repository_rule(
941+ implementation = _impl,
942+ )
943+ EOF
944+ cat > BUILD << 'EOF '
945+ genrule(
946+ name = "repoenv",
947+ outs = ["repoenv.txt"],
948+ srcs = ["@foo//:env.txt"],
949+ cmd = "cp $< $@",
950+ )
951+ EOF
952+ cat > .bazelrc << EOF
953+ build:foo --repo_env=FOO=foo
954+ build:bar --repo_env=FOO=bar
955+ EOF
956+
957+ bazel build --config=foo //:repoenv
958+ cp ` bazel info bazel-bin 2> /dev/null` /repoenv.txt repoenv1.txt
959+ echo ; cat repoenv1.txt; echo ;
960+
961+ sleep 2 # ensure any rerun will have a different time stamp
962+
963+ bazel build --config=bar //:repoenv
964+ # The new config should not trigger a rerun of repoenv.
965+ cp ` bazel info bazel-bin 2> /dev/null` /repoenv.txt repoenv2.txt
966+ echo ; cat repoenv2.txt; echo ;
967+
968+ diff repoenv1.txt repoenv2.txt \
969+ || fail " Expected repository to not change"
970+ }
971+
929972function test_repo_env_invalidation() {
930973 # regression test for https://github.com/bazelbuild/bazel/issues/8869
931974 WRKDIR=$( mktemp -d " ${TEST_TMPDIR} /testXXXXXX" )
@@ -962,18 +1005,18 @@ genrule(
9621005EOF
9631006
9641007 bazel build //:repotime
965- cp ` bazel info bazel-genfiles 2> /dev/null` /repotime.txt time1.txt
1008+ cp ` bazel info bazel-bin 2> /dev/null` /repotime.txt time1.txt
9661009
9671010 sleep 2;
9681011 bazel build --repo_env=foo=bar //:repotime
969- cp ` bazel info bazel-genfiles 2> /dev/null` /repotime.txt time2.txt
1012+ cp ` bazel info bazel-bin 2> /dev/null` /repotime.txt time2.txt
9701013 diff time1.txt time2.txt && fail " Expected repo to be refetched" || :
9711014
9721015 bazel shutdown
9731016 sleep 2;
9741017
9751018 bazel build --repo_env=foo=bar //:repotime
976- cp ` bazel info bazel-genfiles 2> /dev/null` /repotime.txt time3.txt
1019+ cp ` bazel info bazel-bin 2> /dev/null` /repotime.txt time3.txt
9771020 diff time2.txt time3.txt || fail " Expected repo to not be refetched"
9781021}
9791022
@@ -1387,9 +1430,9 @@ EOF
13871430 echo " initial" > reference.txt.shadow
13881431
13891432 bazel build //:source //:configure
1390- grep ' initial' ` bazel info bazel-genfiles ` /source.txt \
1433+ grep ' initial' ` bazel info bazel-bin ` /source.txt \
13911434 || fail ' //:source not generated properly'
1392- grep ' initial' ` bazel info bazel-genfiles ` /configure.txt \
1435+ grep ' initial' ` bazel info bazel-bin ` /configure.txt \
13931436 || fail ' //:configure not generated properly'
13941437
13951438 echo " new value" > reference.txt.shadow
@@ -1401,9 +1444,9 @@ EOF
14011444 && fail " Expected 'source' not to be synced" || :
14021445
14031446 bazel build //:source //:configure
1404- grep -q ' initial' ` bazel info bazel-genfiles ` /source.txt \
1447+ grep -q ' initial' ` bazel info bazel-bin ` /source.txt \
14051448 || fail ' //:source did not keep its old value'
1406- grep -q ' new value' ` bazel info bazel-genfiles ` /configure.txt \
1449+ grep -q ' new value' ` bazel info bazel-bin ` /configure.txt \
14071450 || fail ' //:configure not synced properly'
14081451}
14091452
@@ -1752,9 +1795,9 @@ load("@netrc//:data.bzl", "netrc")
17521795) for name in ["login", "password"]]
17531796EOF
17541797 bazel build //:login //:password
1755- grep ' myusername' ` bazel info bazel-genfiles ` /login.txt \
1798+ grep ' myusername' ` bazel info bazel-bin ` /login.txt \
17561799 || fail " Username not parsed correctly"
1757- grep ' mysecret' ` bazel info bazel-genfiles ` /password.txt \
1800+ grep ' mysecret' ` bazel info bazel-bin ` /password.txt \
17581801 || fail " Password not parsed correctly"
17591802
17601803 # Also check the precise value of parsed file
@@ -1789,7 +1832,7 @@ genrule(
17891832)
17901833EOF
17911834 bazel build //:check_expected
1792- grep ' OK' ` bazel info bazel-genfiles ` /check_expected.txt \
1835+ grep ' OK' ` bazel info bazel-bin ` /check_expected.txt \
17931836 || fail " Parsed dict not equal to expected value"
17941837}
17951838
@@ -1895,7 +1938,7 @@ genrule(
18951938)
18961939EOF
18971940 bazel build //:check_expected
1898- grep ' OK' ` bazel info bazel-genfiles ` /check_expected.txt \
1941+ grep ' OK' ` bazel info bazel-bin ` /check_expected.txt \
18991942 || fail " Authentication merged incorrectly"
19001943}
19011944
0 commit comments