slog - potentially broken test

103 views
Skip to first unread message

Merrick Clay

unread,
Jul 2, 2023, 9:23:56 PM7/2/23
to golang-nuts
When attempting to build from source on Windows, a test in slog fails for me every time. Am I doing something wrong or should I file an issue and submit a PR to improve this test? The issue seems to be the "source" being surrounded by quotes. See details below.

Test output (from running all.bat)
Building Go cmd/dist using C:\Program Files\Go. (go1.20.5 windows/amd64)
Building Go toolchain1 using C:\Program Files\Go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for windows/amd64.

##### Test execution environment.
# GOARCH: amd64
# CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
# GOOS: windows
# OS Version: 10.0.22621

##### Testing packages.
(other tests)
--- FAIL: TestConnections (0.00s)
    logger_test.go:109:
        got  time=2023-07-02T18:04:14.412-06:00 level=INFO source="C:/Users/Merrick Clay/goprojects/src/goroot/src/log/slog/logger_test.go:108" msg=msg2
        want ^time=\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|[+-]\d{2}:\d{2}) level=INFO source=.*logger_test.go:\d{3} msg=msg2$

FAIL
FAIL    log/slog        1.187s

go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Merrick Clay\AppData\Local\go-build
set GOENV=C:\Users\Merrick Clay\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Merrick Clay\goprojects\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Merrick Clay\goprojects
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Merrick Clay\goprojects\src\goroot\src\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\MERRIC~1\AppData\Local\Temp\go-build60902014=/tmp/go-build -gno-record-gcc-switches

Kurtis Rader

unread,
Jul 2, 2023, 10:38:14 PM7/2/23
to Merrick Clay, golang-nuts
It appears to be quoting the source string because your build path contains a space. Apparently the slog authors didn't anticipate that case. I would open an issue. They may want to change the code to always quote the source file string or they may simply want to update the regex in the unit test to allow for optional double-quotes around the file name.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0c19486e-2b30-400e-a0da-f9c51e929a6en%40googlegroups.com.


--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Steven Hartland

unread,
Jul 3, 2023, 5:40:20 AM7/3/23
to Merrick Clay, golang-nuts
Looks like a bug, I suspect because you have a space in the path the path was quoted breaking the regexp as it's not expecting the final quote.
Try editing the regexp to:
^time=\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}(Z|[+-]\d{2}:\d{2}) level=INFO source=.*logger_test.go:\d{3}"? msg=msg2$

Merrick Clay

unread,
Jul 3, 2023, 5:58:20 PM7/3/23
to golang-nuts
Yeah, I've already edited the test so my build would succeed. Adding the optional closing quote did the trick. I'll open an issue. Thanks for the advice!
Reply all
Reply to author
Forward
0 new messages