From bf0e441576266ed3bf3d50d6a96ec30833f2defa Mon Sep 17 00:00:00 2001 From: Alexey Miroshkin Date: Mon, 29 Aug 2016 09:20:43 +0200 Subject: [PATCH] Instantiate lexer inline for the test Don't use the lex constructor, remove the constructor introduced in the prevous commit. --- promql/lex.go | 11 ++--------- promql/lex_test.go | 8 +++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/promql/lex.go b/promql/lex.go index 297c835011..5bbe843646 100644 --- a/promql/lex.go +++ b/promql/lex.go @@ -428,16 +428,9 @@ func (l *lexer) nextItem() item { // lex creates a new scanner for the input string. 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{ - input: input, - items: make(chan item), - seriesDesc: seriesDesc, + input: input, + items: make(chan item), } go l.run() return l diff --git a/promql/lex_test.go b/promql/lex_test.go index c497f896ff..cc12a3ca3e 100644 --- a/promql/lex_test.go +++ b/promql/lex_test.go @@ -438,7 +438,13 @@ var tests = []struct { // for the parser to avoid duplicated effort. func TestLexer(t *testing.T) { 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{} for it := range l.items { out = append(out, it)