@@ -120,15 +120,15 @@ EOF
120
120
bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
121
121
expect_log " bleh"
122
122
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
124
124
expect_log " Tra-la!"
125
125
126
126
bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
127
127
expect_not_log " Tra-la!" # No invalidation
128
128
129
129
bazel build //zoo:ball-pit2 >& $TEST_log || fail " Failed to build"
130
130
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
132
132
expect_log " Tra-la!"
133
133
134
134
# Test invalidation of the WORKSPACE file
@@ -154,15 +154,15 @@ EOF
154
154
bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
155
155
expect_log " blah"
156
156
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
158
158
expect_log " Tra-la-la!"
159
159
160
160
bazel build //zoo:ball-pit1 >& $TEST_log || fail " Failed to build"
161
161
expect_not_log " Tra-la-la!" # No invalidation
162
162
163
163
bazel build //zoo:ball-pit2 >& $TEST_log || fail " Failed to build"
164
164
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
166
166
expect_log " Tra-la-la!"
167
167
}
168
168
355
355
bazel build @foo//:bar >& $TEST_log || fail " Failed to build"
356
356
expect_log " foo"
357
357
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
359
359
expect_log " foo"
360
360
}
361
361
@@ -892,8 +892,8 @@ build:bar --repo_env=FOO=bar
892
892
EOF
893
893
894
894
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
897
897
echo ; cat repoenv1.txt; echo ; cat unrelated1.txt; echo
898
898
899
899
grep -q ' FOO=foo' repoenv1.txt \
904
904
FOO=CHANGED bazel build --config=foo //:repoenv //:unrelated
905
905
# nothing should change, as actions don't see FOO and for repositories
906
906
# 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
909
909
echo ; cat repoenv2.txt; echo ; cat unrelated2.txt; echo
910
910
911
911
diff repoenv1.txt repoenv2.txt \
916
916
bazel build --config=bar //:repoenv //:unrelated
917
917
# The new config should be picked up, but the unrelated target should
918
918
# 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
921
921
echo ; cat repoenv3.txt; echo ; cat unrelated3.txt; echo
922
922
923
923
grep -q ' FOO=bar' repoenv3.txt \
926
926
|| fail " Expected unrelated action to not be rerun"
927
927
}
928
928
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
+
929
972
function test_repo_env_invalidation() {
930
973
# regression test for https://github.com/bazelbuild/bazel/issues/8869
931
974
WRKDIR=$( mktemp -d " ${TEST_TMPDIR} /testXXXXXX" )
@@ -962,18 +1005,18 @@ genrule(
962
1005
EOF
963
1006
964
1007
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
966
1009
967
1010
sleep 2;
968
1011
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
970
1013
diff time1.txt time2.txt && fail " Expected repo to be refetched" || :
971
1014
972
1015
bazel shutdown
973
1016
sleep 2;
974
1017
975
1018
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
977
1020
diff time2.txt time3.txt || fail " Expected repo to not be refetched"
978
1021
}
979
1022
@@ -1387,9 +1430,9 @@ EOF
1387
1430
echo " initial" > reference.txt.shadow
1388
1431
1389
1432
bazel build //:source //:configure
1390
- grep ' initial' ` bazel info bazel-genfiles ` /source.txt \
1433
+ grep ' initial' ` bazel info bazel-bin ` /source.txt \
1391
1434
|| fail ' //:source not generated properly'
1392
- grep ' initial' ` bazel info bazel-genfiles ` /configure.txt \
1435
+ grep ' initial' ` bazel info bazel-bin ` /configure.txt \
1393
1436
|| fail ' //:configure not generated properly'
1394
1437
1395
1438
echo " new value" > reference.txt.shadow
@@ -1401,9 +1444,9 @@ EOF
1401
1444
&& fail " Expected 'source' not to be synced" || :
1402
1445
1403
1446
bazel build //:source //:configure
1404
- grep -q ' initial' ` bazel info bazel-genfiles ` /source.txt \
1447
+ grep -q ' initial' ` bazel info bazel-bin ` /source.txt \
1405
1448
|| 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 \
1407
1450
|| fail ' //:configure not synced properly'
1408
1451
}
1409
1452
@@ -1752,9 +1795,9 @@ load("@netrc//:data.bzl", "netrc")
1752
1795
) for name in ["login", "password"]]
1753
1796
EOF
1754
1797
bazel build //:login //:password
1755
- grep ' myusername' ` bazel info bazel-genfiles ` /login.txt \
1798
+ grep ' myusername' ` bazel info bazel-bin ` /login.txt \
1756
1799
|| fail " Username not parsed correctly"
1757
- grep ' mysecret' ` bazel info bazel-genfiles ` /password.txt \
1800
+ grep ' mysecret' ` bazel info bazel-bin ` /password.txt \
1758
1801
|| fail " Password not parsed correctly"
1759
1802
1760
1803
# Also check the precise value of parsed file
@@ -1789,7 +1832,7 @@ genrule(
1789
1832
)
1790
1833
EOF
1791
1834
bazel build //:check_expected
1792
- grep ' OK' ` bazel info bazel-genfiles ` /check_expected.txt \
1835
+ grep ' OK' ` bazel info bazel-bin ` /check_expected.txt \
1793
1836
|| fail " Parsed dict not equal to expected value"
1794
1837
}
1795
1838
@@ -1895,7 +1938,7 @@ genrule(
1895
1938
)
1896
1939
EOF
1897
1940
bazel build //:check_expected
1898
- grep ' OK' ` bazel info bazel-genfiles ` /check_expected.txt \
1941
+ grep ' OK' ` bazel info bazel-bin ` /check_expected.txt \
1899
1942
|| fail " Authentication merged incorrectly"
1900
1943
}
1901
1944
0 commit comments