]> Cypherpunks repositories - gostls13.git/commit
log/slog: fix time regexp in test
authorKir Kolyshkin <kolyshkin@gmail.com>
Fri, 22 Sep 2023 20:42:50 +0000 (13:42 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 27 Sep 2023 01:15:17 +0000 (01:15 +0000)
commit0de57ebf88b4386810bd4ad42d9ff9c16f15d970
treec97a3af1d1b6b39e3dba8b1abf8136ae32258de0
parent17bddc8bf4fdbe50ea67f75db5cddc3061b5000d
log/slog: fix time regexp in test

CL 525556 started using timeRE regexp to match time output from JSON
handler, and relaxed it to allow arbitrary (rather than fixed 3 digit)
precision.

What it missed is in JSON handler the fractional part is omitted
entirely (together with the decimal dot) when the nanoseconds field is
0.

As a result, there are occasional CI failures in js/wasm (which, I guess,
has better chances to return zero nanoseconds).

To fix the flaky test, let's use two different regular expressions,
tailored to text and JSON.

Change-Id: Ie98990fcf278bb0916ab31c9177e6b22a523062a
Reviewed-on: https://go-review.googlesource.com/c/go/+/530675
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
src/log/slog/logger_test.go