mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Instantiate lexer inline for the test
Don't use the lex constructor, remove the constructor introduced in the prevous commit.
This commit is contained in:
parent
485f7dde08
commit
bf0e441576
|
@ -428,16 +428,9 @@ func (l *lexer) nextItem() item {
|
||||||
|
|
||||||
// lex creates a new scanner for the input string.
|
// lex creates a new scanner for the input string.
|
||||||
func lex(input string) *lexer {
|
func lex(input string) *lexer {
|
||||||
return lexWithSeriesDesc(input, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// lexWithSeriesDesc creates a new scanner for the input string
|
|
||||||
// and specify seriesDesc to prevent data race in tests
|
|
||||||
func lexWithSeriesDesc(input string, seriesDesc bool) *lexer {
|
|
||||||
l := &lexer{
|
l := &lexer{
|
||||||
input: input,
|
input: input,
|
||||||
items: make(chan item),
|
items: make(chan item),
|
||||||
seriesDesc: seriesDesc,
|
|
||||||
}
|
}
|
||||||
go l.run()
|
go l.run()
|
||||||
return l
|
return l
|
||||||
|
|
|
@ -438,7 +438,13 @@ var tests = []struct {
|
||||||
// for the parser to avoid duplicated effort.
|
// for the parser to avoid duplicated effort.
|
||||||
func TestLexer(t *testing.T) {
|
func TestLexer(t *testing.T) {
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
l := lexWithSeriesDesc(test.input, test.seriesDesc)
|
l := &lexer{
|
||||||
|
input: test.input,
|
||||||
|
items: make(chan item),
|
||||||
|
seriesDesc: test.seriesDesc,
|
||||||
|
}
|
||||||
|
go l.run()
|
||||||
|
|
||||||
out := []item{}
|
out := []item{}
|
||||||
for it := range l.items {
|
for it := range l.items {
|
||||||
out = append(out, it)
|
out = append(out, it)
|
||||||
|
|
Loading…
Reference in a new issue