Skip to content

Commit

Permalink
Accept -skip when using -cat
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Oct 7, 2023
1 parent 49e0abd commit 1429747
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/toml-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ func parseFlags() (tomltest.Runner, []string, int, string, bool) {
f, err := fs.ReadFile(fsys, "files-toml-"+tomlVersion.String())
zli.F(err)
gather := make(map[string]map[string]any) /// file -> decoded
outer1:
for _, line := range strings.Split(string(f), "\n") {
if strings.HasPrefix(line, "valid/") && strings.HasSuffix(line, ".toml") {
// SKIP
for _, s := range skip.Strings() {
if m, _ := filepath.Match(s, line); m {
continue outer1
}
}
var t map[string]any
_, err := toml.DecodeFS(fsys, line, &t)
zli.F(err)
Expand All @@ -66,7 +73,7 @@ func parseFlags() (tomltest.Runner, []string, int, string, bool) {
keys = append(keys, k)
}
sort.Strings(keys)
outer:
outer2:
for {
for _, line := range keys {
t := gather[line]
Expand Down Expand Up @@ -95,7 +102,7 @@ func parseFlags() (tomltest.Runner, []string, int, string, bool) {
fmt.Println(out.String())
wrote += out.Len() + 1
if wrote > cat.Int()*1024 {
break outer
break outer2
}
out.Reset()
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/toml-test/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Flags:
$ toml-test -cat 1024 >1M.toml
$ toml-test -cat $(( 1024 * 100 )) >100M.toml
The -skip and -toml flags can be used in combination with
-cat.
-v List all tests, even passing ones. Add twice to show detailed
output for passing tests.
Expand Down

0 comments on commit 1429747

Please sign in to comment.