From 4566119b39b91e708320cad678d04131e5197a3b Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sun, 22 May 2016 19:44:21 -0400 Subject: [PATCH] Close temporary file before running go tool cover --- runtests | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/runtests b/runtests index b0fd06f..72c1f0d 100755 --- a/runtests +++ b/runtests @@ -49,9 +49,9 @@ def _test(): ('{}/{}'.format(PACKAGE_NAME, subpackage)).rstrip('/') ]) - combined = _combine_coverprofiles(coverprofiles) - _run('go tool cover -func={}'.format(combined.name).split()) - combined.close() + combined_name = _combine_coverprofiles(coverprofiles) + _run('go tool cover -func={}'.format(combined_name).split()) + os.remove(combined_name) def _gfmxr(): @@ -78,7 +78,9 @@ def _is_go_runnable(line): def _combine_coverprofiles(coverprofiles): - combined = tempfile.NamedTemporaryFile(suffix='.coverprofile') + combined = tempfile.NamedTemporaryFile( + suffix='.coverprofile', delete=False + ) combined.write('mode: set\n') for coverprofile in coverprofiles: @@ -88,7 +90,9 @@ def _combine_coverprofiles(coverprofiles): combined.write(line) combined.flush() - return combined + name = combined.name + combined.close() + return name if __name__ == '__main__':