Merge pull request #16506 from hashicorp/b-helper-t-escape-path

helper: Escape test name in TF_LOG_PATH_MASK
This commit is contained in:
Radek Simko 2017-10-31 16:41:43 +00:00 committed by GitHub
commit 586255fdc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {