Skip to content

Commit

Permalink
Enables parallel testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aymerick committed Jun 15, 2015
1 parent edfc7de commit 2371f6f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 3 deletions.
4 changes: 3 additions & 1 deletion base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Test struct {
}

func launchTests(t *testing.T, tests []Test) {
// @todo Check why this fails
// NOTE: TestMustache() makes Parallel testing fail
// t.Parallel()

for _, test := range tests {
Expand Down Expand Up @@ -84,6 +84,8 @@ func launchTests(t *testing.T, tests []Test) {
}

func launchErrorTests(t *testing.T, tests []Test) {
t.Parallel()

for _, test := range tests {
var err error
var tpl *Template
Expand Down
8 changes: 8 additions & 0 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ var evalTests = []Test{
}

func TestEval(t *testing.T) {
t.Parallel()

launchTests(t, evalTests)
}

Expand Down Expand Up @@ -109,6 +111,8 @@ func TestEvalErrors(t *testing.T) {
}

func TestEvalStruct(t *testing.T) {
t.Parallel()

source := `<div class="post">
<h1>By {{author.FirstName}} {{Author.lastName}}</h1>
<div class="body">{{Body}}</div>
Expand Down Expand Up @@ -172,6 +176,8 @@ func (t *TestFoo) Subject() string {
}

func TestEvalMethod(t *testing.T) {
t.Parallel()

source := `Subject is {{subject}}! YES I SAID {{Subject}}!`
expected := `Subject is foo! YES I SAID foo!`

Expand All @@ -195,6 +201,8 @@ func testBar() string {
}

func TestEvalMethodReturningFunc(t *testing.T) {
t.Parallel()

source := `Subject is {{subject}}! YES I SAID {{Subject}}!`
expected := `Subject is bar! YES I SAID bar!`

Expand Down
3 changes: 1 addition & 2 deletions handlebars/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ type Test struct {
}

func launchTests(t *testing.T, tests []Test) {
// @todo Check why this fails
// t.Parallel()
t.Parallel()

for _, test := range tests {
var err error
Expand Down
2 changes: 2 additions & 0 deletions handlebars/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ func TestBasic(t *testing.T) {
}

func TestBasicErrors(t *testing.T) {
t.Parallel()

var err error

inputs := []string{
Expand Down
2 changes: 2 additions & 0 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,7 @@ var helperTests = []Test{
//

func TestHelper(t *testing.T) {
t.Parallel()

launchTests(t, helperTests)
}
2 changes: 2 additions & 0 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ func equal(i1, i2 []Token, checkPos bool) bool {
}

func TestLexer(t *testing.T) {
t.Parallel()

for _, test := range lexTests {
tokens := collect(&test)
if !equal(tokens, test.tokens, false) {
Expand Down
2 changes: 2 additions & 0 deletions mustache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,7 @@ var mustacheLambdasTests = []Test{
}

func TestMustacheLambdas(t *testing.T) {
t.Parallel()

launchTests(t, mustacheLambdasTests)
}
4 changes: 4 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ var parserTests = []parserTest{
}

func TestParser(t *testing.T) {
t.Parallel()

for _, test := range parserTests {
output := ""

Expand Down Expand Up @@ -156,6 +158,8 @@ var parserErrorTests = []parserTest{
}

func TestParserErrors(t *testing.T) {
t.Parallel()

for _, test := range parserErrorTests {
node, err := Parse(test.input)
if err == nil {
Expand Down
2 changes: 2 additions & 0 deletions string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var strTests = []strTest{
}

func TestStr(t *testing.T) {
t.Parallel()

for _, test := range strTests {
if res := Str(test.input); res != test.output {
t.Errorf("Failed to stringify: %s\nexpected:\n\t'%s'got:\n\t%q", test.name, test.output, res)
Expand Down
6 changes: 6 additions & 0 deletions template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ CONTENT[ '
`

func TestNewTemplate(t *testing.T) {
t.Parallel()

tpl := newTemplate(sourceBasic)
if tpl.source != sourceBasic {
t.Errorf("Failed to instantiate template")
}
}

func TestParse(t *testing.T) {
t.Parallel()

tpl, err := Parse(sourceBasic)
if err != nil || (tpl.source != sourceBasic) {
t.Errorf("Failed to parse template")
Expand All @@ -43,6 +47,8 @@ func TestParse(t *testing.T) {
}

func TestClone(t *testing.T) {
t.Parallel()

sourcePartial := `I am a {{wat}} partial`
sourcePartial2 := `Partial for the {{wat}}`

Expand Down

0 comments on commit 2371f6f

Please sign in to comment.