Merge pull request #1925 from hashmap/1898-test-race

Fix data race in lexer and lexer test
This commit is contained in:
Fabian Reinartz 2016-08-29 09:28:02 +02:00 committed by GitHub
commit 23ddbd64aa
2 changed files with 7 additions and 3 deletions

View file

@ -38,7 +38,7 @@ check_license:
test: test:
@echo ">> running tests" @echo ">> running tests"
@$(GO) test -short $(pkgs) @$(GO) test -race -short $(pkgs)
format: format:
@echo ">> formatting code" @echo ">> formatting code"

View file

@ -438,8 +438,12 @@ 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 := lex(test.input) l := &lexer{
l.seriesDesc = test.seriesDesc 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 {