Skip to content

Commit

Permalink
sanitize test case name
Browse files Browse the repository at this point in the history
  • Loading branch information
pchila committed Feb 22, 2024
1 parent a04e882 commit 323e114
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/testing/fixture_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ func (f *Fixture) Install(ctx context.Context, installOpts *InstallOpts, opts ..
f.t.Logf("failed to dump process; failed to find project root: %s", err)
return
}
filePath := filepath.Join(dir, "build", fmt.Sprintf("TEST-%s-processes.json", f.t.Name()))

// Sub-test names are separated by "/" characters which are not valid filenames on Linux.
sanitizedTestName := strings.ReplaceAll(f.t.Name(), "/", "-")

filePath := filepath.Join(dir, "build", fmt.Sprintf("TEST-%s-ProcessDump.json", sanitizedTestName))
f.t.Logf("Dumping running processes in %s", filePath)
file, err := os.OpenFile(filePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {
f.t.Logf("failed to dump process; failed to create output file %s root: %s", file.Name(), err)
Expand Down

0 comments on commit 323e114

Please sign in to comment.