Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: T.TempDir does not clean illegal characters correctly on Go 1.16.13 #50644

Closed
Juneezee opened this issue Jan 16, 2022 · 2 comments
Closed

Comments

@Juneezee
Copy link

Juneezee commented Jan 16, 2022

What version of Go are you using (go version)?

$ go version
go version go1.16.13 windows/amd64

Does this issue reproduce with the latest release?

  • Go 1.17.6: No
  • Go 1.16.13: Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
  set GO111MODULE=
  set GOARCH=amd64
  set GOBIN=
  set GOCACHE=C:\Users\runneradmin\AppData\Local\go-build
  set GOENV=C:\Users\runneradmin\AppData\Roaming\go\env
  set GOEXE=.exe
  set GOFLAGS=
  set GOHOSTARCH=amd64
  set GOHOSTOS=windows
  set GOINSECURE=
  set GOMODCACHE=C:\Users\runneradmin\go\pkg\mod
  set GONOPROXY=
  set GONOSUMDB=
  set GOOS=windows
  set GOPATH=C:\Users\runneradmin\go
  set GOPRIVATE=
  set GOPROXY=https://proxy.golang.org,direct
  set GOROOT=C:\hostedtoolcache\windows\go\1.16.13\x64
  set GOSUMDB=sum.golang.org
  set GOTMPDIR=
  set GOTOOLDIR=C:\hostedtoolcache\windows\go\1.16.13\x64\pkg\tool\windows_amd64
  set GOVCS=
  set GOVERSION=go1.16.13
  set GCCGO=gccgo
  set AR=ar
  set CC=gcc
  set CXX=g++
  set CGO_ENABLED=1
  set GOMOD=NUL
  set CGO_CFLAGS=-g -O2
  set CGO_CPPFLAGS=
  set CGO_CXXFLAGS=-g -O2
  set CGO_FFLAGS=-g -O2
  set CGO_LDFLAGS=-g -O2
  set PKG_CONFIG=pkg-config
  set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\RUNNER~1\AppData\Local\Temp\go-build10994681=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import "testing"

func TestTempDir(t *testing.T) {
	tests := []struct {
		name string
	}{
		{
			name: "**aaa",
		},
		{
			name: "bbb**",
		},
		{
			name: "**aaa bbb**",
		},
		{
			name: "subdir/**",
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			t.TempDir()
		})
	}
}

What did you expect to see?

=== RUN   TestTempDir
--- PASS: TestTempDir (0.00s)
=== RUN   TestTempDir/**aaa
    --- PASS: TestTempDir/**aaa (0.00s)
=== RUN   TestTempDir/bbb**
    --- PASS: TestTempDir/bbb** (0.00s)
=== RUN   TestTempDir/**aaa_bbb**
    --- PASS: TestTempDir/**aaa_bbb** (0.00s)
=== RUN   TestTempDir/subdir/**
    --- PASS: TestTempDir/subdir/** (0.00s)
PASS

What did you see instead?

--- FAIL: TestTempDir (0.00s)
    --- FAIL: TestTempDir/**aaa (0.00s)
        main_test.go:25: TempDir: mkdir C:\Users\RUNNER~1\AppData\Local\Temp\TestTempDir_*1134522990aaa: The filename, directory name, or volume label syntax is incorrect.
    --- FAIL: TestTempDir/bbb** (0.00s)
        main_test.go:25: TempDir: mkdir C:\Users\RUNNER~1\AppData\Local\Temp\TestTempDir_bbb*1840932692: The filename, directory name, or volume label syntax is incorrect.
    --- FAIL: TestTempDir/**aaa_bbb** (0.00s)
        main_test.go:25: TempDir: mkdir C:\Users\RUNNER~1\AppData\Local\Temp\TestTempDir_**aaa_bbb*2013955203: The filename, directory name, or volume label syntax is incorrect.
    --- FAIL: TestTempDir/subdir/** (0.00s)
        main_test.go:25: TempDir: mkdir C:\Users\RUNNER~1\AppData\Local\Temp\TestTempDir_subdir_*1630578384: The filename, directory name, or volume label syntax is incorrect.
FAIL
FAIL	tempdir	0.020s
FAIL
@Juneezee Juneezee changed the title testing: T.TempDir does not clean illegal characters correctly testing: T.TempDir does not clean illegal characters correctly on Go 1.16.13 Jan 16, 2022
@Juneezee
Copy link
Author

Juneezee commented Jan 16, 2022

This commit 97cee43 fixes the problem. Should it be backported to Go 1.16?

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Jan 16, 2022

I opened #50645 to backport the fix. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants