-
Notifications
You must be signed in to change notification settings - Fork 196
CI: Specify tmpdir for running golang unit tests #870
Conversation
.ci/go-test.sh
Outdated
@@ -10,6 +10,9 @@ set -e | |||
script_name=${0##*/} | |||
typeset -A long_options | |||
|
|||
# directory to use for temporary files | |||
TMPDIR=${TMPDIR:-/tmp} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is mktemp -d
overkill :) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean specifically make a new tmp directory for the tests to use @marcov ? I could go for that.
Move the `go_test_flags` variable to the `main()` function to simplify subsequent changes. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
It is possible for the `go-test.sh` script to fail when attemping to write to a file as it can already be closed. This problem seems to relate to the golang `testing` package itself so work around the problem by specifying an explicit temporary directory for `testing` to create files in. Fixes kata-containers#869. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
31dd973
to
8d1c745
Compare
@marcov - good call - branch updated! |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
obviously an improvement.
one question.
if [ "$1" = "html-coverage" ]; then | ||
test_html_coverage | ||
elif [ "$run_coverage" = yes ]; then | ||
test_coverage | ||
else | ||
test_local | ||
fi | ||
|
||
[ -d "${golang_tmp}" ] && [ "${golang_tmp}" != "/" ] && rm -rf "${golang_tmp}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the script has a -e
set, would this be safer as a shell TRAP to catch the case where the tests fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did consider that but thought it would be better to leave the tmpfiles in the case of test failures as they might help us diagnose what went wrong.
@jodh-intel What happens to the commit? I can't find the corresponding code in tests master and I'm seeing the exact same failure when running |
FYI, the root cause is how we flush coverage report in TestMain(). I fixed it in kata-containers/runtime#2371 |
@bergwolf - The code is in |
It is possible for the
go-test.sh
script to fail when attemping towrite to a file as it can already be closed. This problem seems to
relate to the golang
testing
package itself so work around theproblem by specifying an explicit temporary directory for
testing
tocreate files in.
Fixes #869.
Signed-off-by: James O. D. Hunt james.o.hunt@intel.com