From 5f1b033f10f7200b89f993fb84de90f2423f3bce Mon Sep 17 00:00:00 2001 From: Arseny Balobanov Date: Fri, 20 Mar 2020 13:00:17 +0300 Subject: [PATCH] testtool: fix cover profile permissions issue by writing profile to /tmp. --- tools/testtool/commands/test_submission.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testtool/commands/test_submission.go b/tools/testtool/commands/test_submission.go index e028e71..f10da5c 100644 --- a/tools/testtool/commands/test_submission.go +++ b/tools/testtool/commands/test_submission.go @@ -263,11 +263,12 @@ func runTests(testDir, privateRepo, problem string) error { for testPkg, testBinary := range testBinaries { relPath := strings.TrimPrefix(testPkg, moduleImportPath) + coverProfile := path.Join(os.TempDir(), randomName()) { cmd := exec.Command(testBinary) if coverageReq.Enabled { - cmd = exec.Command(testBinary, "-test.coverprofile", "c.out") + cmd = exec.Command(testBinary, "-test.coverprofile", coverProfile) } if currentUserIsRoot() { if err := sandbox(cmd); err != nil { @@ -288,7 +289,7 @@ func runTests(testDir, privateRepo, problem string) error { if coverageReq.Enabled { log.Printf("checking coverage is at least %.2f%% for %s", coverageReq.Percent, testPkg) - percent, err := calCoverage(filepath.Join(testDir, relPath, "c.out")) + percent, err := calCoverage(coverProfile) if err != nil { return err }