Skip to content

Commit

Permalink
Use a tear_down function in build_event_stream_test.sh to shutdow…
Browse files Browse the repository at this point in the history
…n the Bazel server process and delete the `bep.txt` file.

This makes the test cases independent.

PiperOrigin-RevId: 429349428
  • Loading branch information
haxorz authored and copybara-github committed Feb 17, 2022
1 parent a73e3c1 commit 4a90f3e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/test/shell/integration/build_event_stream_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ my_rule(name = "my_lib", outs=[])
EOF
}

function tear_down() {
bazel shutdown
rm -f bep.txt
}

#### TESTS #############################################################

function test_basic() {
Expand Down Expand Up @@ -882,16 +887,13 @@ function test_build_only() {
function test_command_whitelisting() {
# We expect the "help" command to not generate a build-event stream,
# but the "build" command to do.
bazel shutdown
rm -f bep.txt
bazel help --build_event_text_file=bep.txt || fail "bazel help failed"
( [ -f bep.txt ] && fail "bazel help generated a build-event file" ) || :
bazel version --build_event_text_file=bep.txt || fail "bazel help failed"
( [ -f bep.txt ] && fail "bazel version generated a build-event file" ) || :
bazel build --build_event_text_file=bep.txt //pkg:true \
|| fail "bazel build failed"
[ -f bep.txt ] || fail "build did not generate requested build-event file"
bazel shutdown
}

function test_multiple_transports() {
Expand Down Expand Up @@ -991,7 +993,6 @@ function test_loading_failure() {
}

function test_visibility_failure() {
bazel shutdown
(bazel build --experimental_bep_target_summary \
--build_event_text_file=$TEST_log \
//visibility:cannotsee && fail "build failure expected") || true
Expand All @@ -1015,7 +1016,6 @@ function test_visibility_failure() {
function test_visibility_indirect() {
# verify that an indirect visibility error is reported, including the
# target that violates visibility constraints.
bazel shutdown
(bazel build --build_event_text_file=$TEST_log \
//visibility:indirect && fail "build failure expected") || true
expect_log 'reason: ANALYSIS_FAILURE'
Expand All @@ -1028,7 +1028,6 @@ function test_visibility_indirect() {
}

function test_independent_visibility_failures() {
bazel shutdown
(bazel build -k --build_event_text_file=$TEST_log \
//visibility:indirect //visibility:indirect2 \
&& fail "build failure expected") || true
Expand Down Expand Up @@ -1287,15 +1286,13 @@ function test_server_pid() {
|| fail "Build failed but should have succeeded"
cat bep.txt | grep server_pid >> "$TEST_log"
expect_log_once "server_pid:.*$(bazel info server_pid)$"
rm bep.txt
}

function test_bep_report_only_important_artifacts() {
bazel build --test_output=all --build_event_text_file=bep.txt \
//pkg:true || fail "Build failed but should have succeeded"
cat bep.txt >> "$TEST_log"
expect_not_log "_hidden_top_level_INTERNAL_"
rm bep.txt
}

function test_starlark_flags() {
Expand All @@ -1318,7 +1315,6 @@ EOF
--//:my_int_setting=666 \
//pkg:true || fail "Build failed but should have succeeded"
cat bep.txt >> "$TEST_log"
rm bep.txt

expect_log 'option_name: "//:my_int_setting"'
expect_log 'option_value: "666"'
Expand Down

0 comments on commit 4a90f3e

Please sign in to comment.