Skip to content

Commit

Permalink
Tests: print a warning if zip failed
Browse files Browse the repository at this point in the history
If test-setup.sh fails to create the undeclared
outputs zip, then print a warning but carry on.
Failing to create this zip is a nuisance but not a
fatal error.

The warning is printed to the test log. If the
test fails, this is printed to the console too. If
the test passes, then the warning remains only in
the test log (Bazel prints no output for passing
tests).

Fixes #8336

Change-Id: Iee8121d76e96445252d97142cef68c50afbb25b1

Closes #8720.

Change-Id: Iee8121d76e96445252d97142cef68c50afbb25b1
PiperOrigin-RevId: 255401321
  • Loading branch information
laszlocsomor authored and copybara-github committed Jun 27, 2019
1 parent 26e94c9 commit 168ee7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/test/py/bazel/test_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _CreateMockWorkspace(self):
'shutil.copyfile(r.Rlocation("__main__/foo/dummy.ico"),',
' os.path.join(root, "out1", "data1.ico"))',
'shutil.copyfile(r.Rlocation("__main__/foo/dummy.dat"),',
' os.path.join(root, "out2", "data2.dat"))',
' os.path.join(root, "out2", "my data 2.dat"))',
],
executable=True)

Expand Down Expand Up @@ -413,7 +413,7 @@ def _AssertUndeclaredOutputs(self, flags):
'empty/': 0,
'empty/sub/': 0,
'out1/data1.ico': 70,
'out2/data2.dat': 16
'out2/my data 2.dat': 16
})

undecl_mf = os.path.join(bazel_testlogs, 'foo', 'undecl_test',
Expand All @@ -439,7 +439,7 @@ def _AssertUndeclaredOutputs(self, flags):
'image/icon', 'text/ico', 'application/ico'
]):
self._FailWithOutput(mf_content)
if mf_content[1] != 'out2/data2.dat\t16\tapplication/octet-stream':
if mf_content[1] != 'out2/my data 2.dat\t16\tapplication/octet-stream':
self._FailWithOutput(mf_content)

def _AssertUndeclaredOutputsAnnotations(self, flags):
Expand Down
12 changes: 8 additions & 4 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,14 @@ fi

# Zip up undeclared outputs.
if [[ -n "$TEST_UNDECLARED_OUTPUTS_ZIP" ]] && cd "$TEST_UNDECLARED_OUTPUTS_DIR"; then
(
shopt -s dotglob failglob
zip -qr "$TEST_UNDECLARED_OUTPUTS_ZIP" -- *
) 2> /dev/null
shopt -s dotglob
if [[ "$(echo *)" != "*" ]]; then
# If * found nothing, echo printed the literal *.
# Otherwise echo printed the top-level files and directories.
# Pass files to zip with *, so paths with spaces aren't broken up.
zip -qr "$TEST_UNDECLARED_OUTPUTS_ZIP" -- * 2>/dev/null || \
echo >&2 "Could not create \"$TEST_UNDECLARED_OUTPUTS_ZIP\": zip not found or failed"
fi
fi

exit $exitCode

0 comments on commit 168ee7c

Please sign in to comment.