aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xsrc/test/shell/bazel/bazel_test_test.sh29
-rwxr-xr-xtools/test/test-setup.sh34
2 files changed, 48 insertions, 15 deletions
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index 0cf9154594..6db8b8340d 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -600,4 +600,33 @@ EOF
diff expected_annotations "$annotations" > d || fail "$annotations differs from expected:$N$(cat d)$N"
}
+function test_no_zip_annotation_manifest_when_no_undeclared_outputs() {
+ mkdir -p dir
+
+ cat <<'EOF' > dir/test.sh
+#!/bin/sh
+echo "pass"
+exit 0
+EOF
+
+ chmod +x dir/test.sh
+
+ cat <<'EOF' > dir/BUILD
+ sh_test(
+ name = "test",
+ srcs = [ "test.sh" ],
+ )
+EOF
+
+ bazel test -s //dir:test &> $TEST_log || fail "expected success"
+
+ # Check that the undeclared outputs directory doesn't exist.
+ outputs_dir=bazel-testlogs/dir/test/test.outputs/
+ [ ! -d $outputs_dir ] || fail "$outputs_dir was present after test"
+
+ # Check that the undeclared outputs manifest directory doesn't exist.
+ outputs_manifest_dir=bazel-testlogs/dir/test/test.outputs_manifest/
+ [ ! -d $outputs_manifest_dir ] || fail "$outputs_manifest_dir was present after test"
+}
+
run_suite "bazel test tests"
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index 77b02083ba..5eb43a0bdd 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -225,21 +225,25 @@ write_xml_output_file
# Add all of the files from the undeclared outputs directory to the manifest.
if [[ -n "$TEST_UNDECLARED_OUTPUTS_DIR" && -n "$TEST_UNDECLARED_OUTPUTS_MANIFEST" ]]; then
- # For each file, write a tab-separated line with name (relative to
- # TEST_UNDECLARED_OUTPUTS_DIR), size, and mime type to the manifest. e.g.
- # foo.txt 9 text/plain
- while read -r undeclared_output; do
- rel_path="${undeclared_output#$TEST_UNDECLARED_OUTPUTS_DIR/}"
- # stat has different flags for different systems. -c is supported by GNU,
- # and -f by BSD (and thus OSX). Try both.
- file_size="$(stat -f%z "$undeclared_output" 2>/dev/null || stat -c%s "$undeclared_output" 2>/dev/null || echo "Could not stat $undeclared_output")"
- file_type="$(file -L -b --mime-type "$undeclared_output")"
-
- printf "$rel_path\t$file_size\t$file_type\n"
- done <<< "$(find -L "$TEST_UNDECLARED_OUTPUTS_DIR" -type f | sort)" \
- > "$TEST_UNDECLARED_OUTPUTS_MANIFEST"
- if [[ ! -s "$TEST_UNDECLARED_OUTPUTS_MANIFEST" ]]; then
- rm "$TEST_UNDECLARED_OUTPUTS_MANIFEST"
+ undeclared_outputs="$(find -L "$TEST_UNDECLARED_OUTPUTS_DIR" -type f | sort)"
+ # Only write the manifest if there are any undeclared outputs.
+ if [[ ! -z "$undeclared_outputs" ]]; then
+ # For each file, write a tab-separated line with name (relative to
+ # TEST_UNDECLARED_OUTPUTS_DIR), size, and mime type to the manifest. e.g.
+ # foo.txt 9 text/plain
+ while read -r undeclared_output; do
+ rel_path="${undeclared_output#$TEST_UNDECLARED_OUTPUTS_DIR/}"
+ # stat has different flags for different systems. -c is supported by GNU,
+ # and -f by BSD (and thus OSX). Try both.
+ file_size="$(stat -f%z "$undeclared_output" 2>/dev/null || stat -c%s "$undeclared_output" 2>/dev/null || echo "Could not stat $undeclared_output")"
+ file_type="$(file -L -b --mime-type "$undeclared_output")"
+
+ printf "$rel_path\t$file_size\t$file_type\n"
+ done <<< "$undeclared_outputs" \
+ > "$TEST_UNDECLARED_OUTPUTS_MANIFEST"
+ if [[ ! -s "$TEST_UNDECLARED_OUTPUTS_MANIFEST" ]]; then
+ rm "$TEST_UNDECLARED_OUTPUTS_MANIFEST"
+ fi
fi
fi