Skip to content

Commit caaccb7

Browse files
committed
Go: Run go clean -modcache in finally for integration tests
This ensures that the temporary GOPATH is cleaned up correctly in case of an integration test failure as well
1 parent a99849d commit caaccb7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

go/integration-tests-lib/go_integration_test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ def go_integration_test(source = "src"):
99
goPath = os.path.join(os.path.abspath(os.getcwd()), ".go")
1010
os.environ['GOPATH'] = goPath
1111

12-
run_codeql_database_create([], lang="go", source=source)
12+
try:
13+
run_codeql_database_create([], lang="go", source=source)
1314

14-
check_diagnostics()
15-
16-
# Clean up the temporary GOPATH to prevent Bazel failures next
17-
# time the tests are run; see https://github.com/golang/go/issues/27161
18-
subprocess.call(["go", "clean", "-modcache"])
15+
check_diagnostics()
16+
finally:
17+
# Clean up the temporary GOPATH to prevent Bazel failures next
18+
# time the tests are run; see https://github.com/golang/go/issues/27161
19+
subprocess.call(["go", "clean", "-modcache"])

0 commit comments

Comments
 (0)