@@ -114,15 +114,20 @@ func TestWithCallDepth(t *testing.T) {
114
114
}
115
115
}
116
116
117
- func TestRunSlogTestsOnSlogHandlerLogSink (t * testing.T ) {
117
+ func TestRunSlogTestsOnNaiveSlogHandler (t * testing.T ) {
118
118
// This proves that slogHandler passes slog's own tests when given a
119
- // non-SlogSink LogSink.
119
+ // LogSink which does not implement SlogSink .
120
120
exceptions := []string {
121
121
// logr sinks handle time themselves
122
122
"a Handler should ignore a zero Record.Time" ,
123
123
// slogHandler does not do groups "properly", so these all fail with
124
124
// "missing group". It's looking for `"G":{"a":"b"}` and getting
125
125
// `"G.a": "b"`.
126
+ //
127
+ // NOTE: These make a weird coupling to Go versions. Newer Go versions
128
+ // don't need some of these exceptions, but older ones do. It's unclear
129
+ // if that is because something changed in slog or if the test was
130
+ // removed.
126
131
"a Handler should handle Group attributes" ,
127
132
"a Handler should handle the WithGroup method" ,
128
133
"a Handler should handle multiple WithGroup and WithAttr calls" ,
@@ -137,21 +142,21 @@ func TestRunSlogTestsOnSlogHandlerLogSink(t *testing.T) {
137
142
// or SlogSink (since those get special treatment). We can trust that
138
143
// the slog JSONHandler works.
139
144
handler := slog .NewJSONHandler (buffer , nil )
140
- sink := & passthruLogSink {handler : handler }
145
+ sink := & passthruLogSink {handler : handler } // passthruLogSink does not implement SlogSink.
141
146
logger := New (sink )
142
147
return ToSlogHandler (logger )
143
148
}, exceptions ... )
144
149
}
145
150
146
- func TestRunSlogTestsOnSlogHandlerSlogSink (t * testing.T ) {
151
+ func TestRunSlogTestsOnEnlightenedSlogHandler (t * testing.T ) {
147
152
// This proves that slogHandler passes slog's own tests when given a
148
- // SlogSink.
153
+ // LogSink which implements SlogSink.
149
154
exceptions := []string {}
150
155
testhelp .RunSlogTests (t , func (buffer * bytes.Buffer ) slog.Handler {
151
156
// We want a known-good Logger that emits JSON and implements SlogSink,
152
157
// to cover those paths. We can trust that the slog JSONHandler works.
153
158
handler := slog .NewJSONHandler (buffer , nil )
154
- sink := & passthruSlogSink {handler : handler }
159
+ sink := & passthruSlogSink {handler : handler } // passthruSlogSink implements SlogSink.
155
160
logger := New (sink )
156
161
return ToSlogHandler (logger )
157
162
}, exceptions ... )
0 commit comments