Skip to content

Commit

Permalink
Don't run tests with "go test -run TestToml/..."
Browse files Browse the repository at this point in the history
Before tests would get run, just wouldn't get reported in the output.
  • Loading branch information
arp242 committed Nov 24, 2021
1 parent 9865bee commit 7eb955f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions decode_go116.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package toml
Expand Down
1 change: 1 addition & 0 deletions decode_go116_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package toml
Expand Down
3 changes: 2 additions & 1 deletion fuzz_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build gofuzzbeta
//go:build go1.18
// +build go1.18

package toml

Expand Down
1 change: 1 addition & 0 deletions internal/toml-test/json.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package tomltest
Expand Down
1 change: 1 addition & 0 deletions internal/toml-test/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

//go:generate ./gen-multi.py
Expand Down
1 change: 1 addition & 0 deletions internal/toml-test/toml.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package tomltest
Expand Down
25 changes: 22 additions & 3 deletions toml_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.16
// +build go1.16

package toml_test
Expand All @@ -6,6 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -42,11 +44,28 @@ func TestToml(t *testing.T) {
}
}

// TODO: bit of a hack to make sure not all test run; without this "-run=.."
// will still run alll tests, but just report the errors for the -run value.
// This is annoying in cases where you have some debug printf.
//
// Need to update toml-test a bit to make this easier, but this good enough
// for now.
var runTests []string
for _, a := range os.Args {
if strings.HasPrefix(a, "-test.run=TestToml/") {
a = strings.TrimPrefix(a, "-test.run=TestToml/encode/")
a = strings.TrimPrefix(a, "-test.run=TestToml/decode/")
runTests = []string{a, a + "/*"}
break
}
}

run := func(t *testing.T, enc bool) {
r := tomltest.Runner{
Files: tomltest.EmbeddedTests(),
Encoder: enc,
Parser: parser{},
Files: tomltest.EmbeddedTests(),
Encoder: enc,
Parser: parser{},
RunTests: runTests,
SkipTests: []string{
// This one is annoying to fix, and such an obscure edge case
// it's okay to leave it like this for now.
Expand Down

0 comments on commit 7eb955f

Please sign in to comment.