helper: Escape test name in TF_LOG_PATH_MASK

This commit is contained in:
Radek Simko 2017-10-31 06:48:57 +00:00
parent a41d5d634d
commit d39025b9d8
No known key found for this signature in database
GPG Key ID: 1F1C84FE689A88D7
1 changed files with 4 additions and 1 deletions

View File

@ -382,7 +382,10 @@ func LogOutput(t TestT) (logOutput io.Writer, err error) {
} }
if logPathMask := os.Getenv(EnvLogPathMask); logPathMask != "" { if logPathMask := os.Getenv(EnvLogPathMask); logPathMask != "" {
logPath := fmt.Sprintf(logPathMask, t.Name()) // Escape special characters which may appear if we have subtests
testName := strings.Replace(t.Name(), "/", "__", -1)
logPath := fmt.Sprintf(logPathMask, testName)
var err error var err error
logOutput, err = os.OpenFile(logPath, syscall.O_CREAT|syscall.O_RDWR|syscall.O_APPEND, 0666) logOutput, err = os.OpenFile(logPath, syscall.O_CREAT|syscall.O_RDWR|syscall.O_APPEND, 0666)
if err != nil { if err != nil {