You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I’m working on creating a validation that needs to handle paths, and as such I have started to leverage the package path/filepath, it works fine for linux and macos, however Windows seems to hang, regardless of the path we are validating (windows or linux). The function in question is
func Depth(path string) uint {
var count uint = 0
for p := filepath.Clean(path); p != "/" && p != "."; count++ {
p = filepath.Dir(p)
}
return count
}
What did you see happen?
We are able to encourage a hang by simply putting this inside of a test function and letting CI run it.
Resulting in:
2m 39s
Run go test -timeout 120s -cover \
github.com/coreos/ignition/v2/config/doc coverage: 0.0% of statements
ok github.com/coreos/ignition/v2/config 1.160s coverage: 17.6% of statements
? github.com/coreos/ignition/v2/config/shared [no test files]
github.com/coreos/ignition/v2/config/shared/parse coverage: 0.0% of statements
github.com/coreos/ignition/v2/config/shared/validations coverage: 0.0% of statements
github.com/coreos/ignition/v2/config/shared/errors coverage: 0.0% of statements
? github.com/coreos/ignition/v2/config/translate/tests/pkga [no test files]
? github.com/coreos/ignition/v2/config/translate/tests/pkgb [no test files]
github.com/coreos/ignition/v2/config/util coverage: 0.0% of statements
ok github.com/coreos/ignition/v2/config/merge 1.184s coverage: 69.3% of statements
ok github.com/coreos/ignition/v2/config/translate 1.151s coverage: 45.2% of statements
ok github.com/coreos/ignition/v2/config/v3_0 1.182s coverage: 41.9% of statements
ok github.com/coreos/ignition/v2/config/v3_0/types 1.159s coverage: 52.7% of statements
ok github.com/coreos/ignition/v2/config/v3_1 1.181s coverage: 49.0% of statements
ok github.com/coreos/ignition/v2/config/v3_1/translate 1.110s coverage: 55.7% of statements
ok github.com/coreos/ignition/v2/config/v3_1/types 1.205s coverage: 55.3% of statements
ok github.com/coreos/ignition/v2/config/v3_2 1.169s coverage: 49.0% of statements
ok github.com/coreos/ignition/v2/config/v3_2/translate 1.137s coverage: 55.3% of statements
ok github.com/coreos/ignition/v2/config/v3_2/types 1.142s coverage: 51.1% of statements
ok github.com/coreos/ignition/v2/config/v3_3 1.188s coverage: 49.0% of statements
ok github.com/coreos/ignition/v2/config/v3_3/translate 1.133s coverage: 55.7% of statements
ok github.com/coreos/ignition/v2/config/v3_3/types 1.150s coverage: 53.7% of statements
ok github.com/coreos/ignition/v2/config/v3_4 1.180s coverage: 49.0% of statements
ok github.com/coreos/ignition/v2/config/v3_4/translate 1.153s coverage: 49.5% of statements
ok github.com/coreos/ignition/v2/config/v3_4/types 1.192s coverage: 57.0% of statements
ok github.com/coreos/ignition/v2/config/v3_5_experimental 1.214s coverage: 49.0% of statements
ok github.com/coreos/ignition/v2/config/v3_5_experimental/translate 1.131s coverage: 31.2% of statements
github.com/coreos/ignition/v2/validate coverage: 0.0% of statements
coverage: 2.6% of statements
panic: test timed out after 2m0s
running tests:
TestDepthPath (2m0s)
goroutine 18 [running]:
testing.(*M).startAlarm.func1()
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:2366 +0x265
created by time.goFunc
C:/hostedtoolcache/windows/go/1.22.1/x64/src/time/sleep.go:177 +0x45
goroutine 1 [chan receive]:
testing.(*T).Run(0xc000120820, {0x140424bc9, 0xd}, 0x140450d90)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:1750 +0x851
testing.runTests.func1(0xc000120820)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:2161 +0x86
testing.tRunner(0xc000120820, 0xc000107b00)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:1689 +0x21f
testing.runTests(0xc000008180, {0x1403adc00, 0x20, 0x20}, {0xc000107ba8?, 0xc000107bf0?, 0x1406286a0?})
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:2159 +0x8bf
testing.(*M).Run(0xc000064f00)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:2027 +0xf18
main.main()
_testmain.go:143 +0x2e5
goroutine 7 [runnable]:
strings.Replace({0xc00000b324, 0x0}, {0x140421e39, 0x1}, {0x1404a6688, 0x1}, 0xffffffffffffffff)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/strings/strings.go:1060 +0x3be
strings.ReplaceAll(...)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/strings/strings.go:1100
path/filepath.FromSlash(...)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/path/filepath/path.go:231
path/filepath.VolumeName({0xc00000b324, 0x1})
C:/hostedtoolcache/windows/go/1.22.1/x64/src/path/filepath/path.go:638 +0x6a
path/filepath.Dir({0xc00000b324, 0x1})
C:/hostedtoolcache/windows/go/1.22.1/x64/src/path/filepath/path.go:620 +0x35
github.com/coreos/ignition/v2/config/v3_5_experimental/types.TestDepthPath(0xc000120b60)
D:/a/ignition/ignition/config/v3_5_experimental/types/config_test.go:353 +0x7e
testing.tRunner(0xc000120b60, 0x140450d90)
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:1689 +0x21f
created by testing.(*T).Run in goroutine 1
C:/hostedtoolcache/windows/go/1.22.1/x64/src/testing/testing.go:1742 +0x826
FAIL github.com/coreos/ignition/v2/config/v3_5_experimental/types 120.152s
ok github.com/coreos/ignition/v2/config/validate 1.108s coverage: 46.8% of statements
FAIL
Do you have any ideas why this would get stuck on windows explicitly, we expect the IO interactions differ, but dont know enough about how windows works to know.
Do you have any ideas why this would get stuck on windows explicitly, we expect the IO interactions differ, but dont know enough about how windows works to know.
What did you expect to see?
I was expecting it to run it smoothly since Linux worked well. I also tried in differents Golang versions such1.22.1and 1.22.2.
The text was updated successfully, but these errors were encountered:
The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows.
(...)
Finally, any occurrences of slash are replaced by Separator.
I have not tested this but I guess this your function should be something like to work across OSes:
func Depth(path string) uint {
var count uint = 0
for p := filepath.Clean(path); p != filepath.Seperator && p != "."; count++ {
p = filepath.Dir(p)
}
return count
}
seankhliao
changed the title
Windows Path Issue in package path/filepath
path/filepath: Windows Path Issue
Apr 19, 2024
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Go version
1.21.0
Output of
go env
in your module/workspace:What did you do?
Hey, I’m working on creating a validation that needs to handle paths, and as such I have started to leverage the package path/filepath, it works fine for linux and macos, however Windows seems to hang, regardless of the path we are validating (windows or linux). The function in question is
What did you see happen?
We are able to encourage a hang by simply putting this inside of a test function and letting CI run it.
Resulting in:
Do you have any ideas why this would get stuck on windows explicitly, we expect the IO interactions differ, but dont know enough about how windows works to know.
Do you have any ideas why this would get stuck on windows explicitly, we expect the IO interactions differ, but dont know enough about how windows works to know.
What did you expect to see?
I was expecting it to run it smoothly since Linux worked well. I also tried in differents Golang versions such
1.22.1
and1.22.2
.The text was updated successfully, but these errors were encountered: