Skip to content

Commit 74eb956

Browse files
committed
Release 2.0
There's a few incompatible changes to the CLI interface as it was all getting quite messy, so release as 2.0. This also enables TOML 1.1 default (via the github.com/BurntSushi/toml update). Fixes #168 Fixes #173
1 parent 0761797 commit 74eb956

10 files changed

Lines changed: 235 additions & 81 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
"test": {
66
"strategy": {
77
"matrix": {
8-
"go-version": ["1.19.x", "1.24.x"],
8+
"go-version": ["1.19.x", "1.25.x"],
99
"os": ["ubuntu-latest", "macos-latest", "windows-latest"]
1010
}
1111
},
1212
"runs-on": "${{ matrix.os }}",
1313
"steps": [
1414
{
1515
"name": "Install Go",
16-
"uses": "actions/setup-go@v5",
16+
"uses": "actions/setup-go@v6",
1717
"with": {"go-version": "${{ matrix.go-version }}"}
1818
},
1919
{
2020
"name": "Checkout code",
21-
"uses": "actions/checkout@v4"
21+
"uses": "actions/checkout@v6"
2222
},
2323
{
2424
"name": "Test",

CHANGELOG.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
v2.0.0 2025-12-18
2+
-----------------
3+
This release has a number of incompatible changes. It also sets TOML 1.1 as the
4+
default version to test.
5+
6+
### Incompatible changes
7+
- The CLI syntax has been cleaned up to make it easier to use. The main
8+
motivation was to enable running all tests (decoder and encoder) with just one
9+
`toml-test` invocation, which was hard to do in a compatible way.
10+
11+
To run the tests, you now need to use the `test` subcommand. And the decoder
12+
and encoder binaries are specified via the `-decoder` and `-encoder` flags
13+
rather than as positional arguments.
14+
15+
Before:
16+
17+
% toml-test my-decoder
18+
% toml-test -encoder my-encoder
19+
20+
Now:
21+
22+
% toml-test test -decoder=my-decoder -encoder=my-encoder
23+
24+
- `toml-test -copy` is now `toml-test copy`.
25+
26+
- `toml-test -version` is now `toml-test version`.
27+
28+
- `toml-test -list` has been removed; I don't think anyone was using it(?) and
29+
the `copy` command should cover most use cases. It can be added again if
30+
someone needs it.
31+
32+
- Rename `-print-skip` flag to `-script`.
33+
34+
- Remove `-testdir` flag to load test files from the filesystem. Tests have been
35+
built in the binary since 1.0.0-beta1 (2021), and this flag has not really
36+
been useless ever since.
37+
38+
- It now tests TOML 1.1 by default. Use `-toml=1.0` if you want to test TOML
39+
1.0.
40+
41+
### Other changes
42+
- Add various new tests, and rename some existing tests for consistency.
43+
44+
- Add `-json` flag to the `test` command, to print test output as JSON rather
45+
than text.
46+
47+
- Allow setting `-toml=latest`.
48+
49+
- Add `-skip-must-err` flag to the `test` command, to treat skipped tests that
50+
don't fail as an error.
51+
52+
v1.6.0, 2025-04-15
53+
------------------
54+
This is a small maintenance release which fixes a few small bugs in the test
55+
runner and adds a few small tests. See the git log for details: v1.5.0...v1.6.0
56+
57+
v1.5.0, 2024-05-31
58+
------------------
59+
### Changes
60+
- This release requires Go 1.19 to build.
61+
62+
- Add quite a lot of new test.
63+
64+
- Only "pass" an invalid test if the decoder exits with exactly exit 1, rather
65+
than any exit >0. This catches segfaults, panics, and other crashes which
66+
shouldn't be considered "passing".
67+
68+
- Tests are now run in parallel, defaulting to the number of available cores.
69+
Use the `-parallel` flag to set the number of cores to use.
70+
71+
- Few small improvements to toml-test runner output.
72+
73+
### New features
74+
- The `-copy` flag copies all tests to the given directory (taking the `-toml`
75+
flag in to account). This is much easier than manually copying the files.
76+
77+
- Add `-errors` flag to test expected error messages for invalid tests. See
78+
`-help` for details.
79+
80+
- Add `-print-skip`, to print out a small bash/zsh script with `-skip` flags for
81+
tests that failed. Useful to get a list of "known failures" for CI
82+
integrations and such.
83+
84+
- Add `-timeout` flag to set the maximum execution time per test, to catch
85+
infinite loops and/or pathological cases. This defaults to 1s, but can
86+
probably be set (much) lower for most implementations.
87+
88+
- Add `-int-as-float` flag, for implementations that treat all numbers as
89+
floats.
90+
91+
- Add `-cat` flag to create a large (valid) TOML document, for benchmarks and
92+
such.
93+
94+
v1.4.0, 2023-09-29
95+
------------------
96+
- Move from github.com/BurntSushi/toml-test to github.com/toml-lang/toml-test
97+
98+
In most cases things should keep working as GitHub will redirect things, but
99+
you'll have to update the path if you install from source with `go install`.
100+
101+
- Both TOML 1.0 and the upcoming TOML 1.1 are now supported.
102+
103+
If you implemented your own test-runner, then you should only copy/use the
104+
files listed in `tests/files-toml-1.0.0` (or `tests/files-toml-1.1.0`). Some
105+
things that are invalid in 1.0 are now valid in 1.1.
106+
107+
Also see "Usage without toml-test binary" in the README.md.
108+
109+
For the `toml-test` tool the default remains 1.0; add `-toml 1.1.0` to use
110+
TOML 1.1.
111+
112+
- Add a few tests, and improve output on test failures a bit.
113+
114+
v1.2.0, 2023-01-15
115+
------------------
116+
A few minor fixes and additional tests; see the git log for details:
117+
v1.2.0...v1.3.0
118+
119+
v1.2.0, 2022-06-02
120+
------------------
121+
A few minor fixes and additional tests; see the git log for details:
122+
v1.1.0...v1.2.0
123+
124+
v1.1.0, 2022-01-12
125+
------------------
126+
Adds various tests; see the git log for details: v1.0.0...v1.1.0
127+
128+
v1.0.0, 2021-08-04
129+
------------------
130+
Many changes since the last release in 2013: much improved error output, support
131+
TOML 1.0.0, add several flags to give more control over which tests to run/skip.
132+
133+
Some minor incompatibilities in the test tool:
134+
135+
- You no longer need to add a type hint to arrays.
136+
- Tests are always referenced as valid/[...] or invalid/[..]
137+
- The datetime-local, date-local, and time-local types are added. You will need
138+
to add support for this in your -encode and -decode test helpers.

README.md

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,67 +15,59 @@ If you find something in your parser that's not exactly covered by toml-test
1515
already then it should be added here; just creating an issue is enough: don't
1616
*need* to create a PR.
1717

18-
Compatible with TOML version [v1.0.0].
18+
Compatible with TOML versions [v1.0.0] and [v1.1.0].
1919

2020
[TOML]: https://toml.io
2121
[v1.0.0]: https://toml.io/en/v1.0.0
22+
[v1.1.0]: https://toml.io/en/v1.1.0
2223

2324
Installation
2425
------------
2526
There are binaries on the [release page]; these are statically compiled and
26-
should run in most environments. It's recommended you use a binary, or a tagged
27+
should run in most environments. It's recommended you use a binary or a tagged
2728
release if you build from source especially in CI environments. This prevents
2829
your tests from breaking on changes to tests in this tool.
2930

3031
To compile from source you will need Go 1.19 or newer:
3132

32-
% go install github.com/toml-lang/toml-test/cmd/toml-test@latest
33+
% go install github.com/toml-lang/toml-test/v2/cmd/toml-test@latest
3334

3435
This will build a `toml-test` binary in the `~/go/bin` directory. You can change
3536
that directory by setting `GOBIN`; for example to use the current directory:
3637

37-
% GOBIN="$(pwd)" go install github.com/toml-lang/toml-test/cmd/toml-test@latest
38+
% GOBIN="$(pwd)" go install github.com/toml-lang/toml-test/v2/cmd/toml-test@latest
3839

39-
[release page]: https://github.com/toml-lang/toml-test/releases
40-
41-
Running in CI
42-
-------------
43-
The [setup-toml-test] action can be used in GitHub. See the README for more
44-
details.
40+
See [CHANGELOG.md] for a list of changes.
4541

46-
For other CI systems: the action essentially just downloads a release binary.
47-
See index.js. Should be easy enough to reproduce elsewhere.
48-
49-
[setup-toml-test]: https://github.com/toml-lang/setup-toml-test
42+
[release page]: https://github.com/toml-lang/toml-test/releases
43+
[CHANGELOG.md]: ./CHANGELOG.md
5044

5145
Usage
5246
-----
53-
`toml-test` accepts an encoder or decoder as the first positional argument, for
54-
example:
55-
56-
% toml-test my-toml-decoder
57-
% toml-test my-toml-encoder -encoder
58-
59-
The `-encoder` flag is used to signal that this is an encoder rather than a
60-
decoder.
61-
62-
For example, to run the tests against the Go TOML library:
47+
`toml-test test` runs the test suite, and requires an `-decoder` and/or
48+
`-encoder` flag; for example:
6349

6450
# Install my parser
6551
% go install github.com/BurntSushi/toml/cmd/toml-test-decoder@master
6652
% go install github.com/BurntSushi/toml/cmd/toml-test-encoder@master
6753

68-
% toml-test toml-test-decoder
69-
toml-test v2023-10-23 [toml-test-decoder]: using embeded tests: 278 passed
54+
# Run tests
55+
% toml-test test \
56+
-decoder=toml-test-decoder \
57+
-encoder=toml-test-encoder
58+
59+
[..]
7060

71-
% toml-test -encoder toml-test-encoder
72-
toml-test v2023-10-23 [toml-test-encoder]: using embeded tests: 94 passed, 0 failed
61+
toml-test v2025-12-16 [toml-test-decoder] [toml-test-encoder]
62+
valid tests: 205 passed, 0 failed
63+
encoder tests: 205 passed, 0 failed
64+
invalid tests: 460 passed, 15 failed
7365

7466
You can use `-run [name]` or `-skip [name]` to run or skip specific tests. Both
7567
flags can be given more than once and accept glob patterns: `-run
7668
'valid/string/*'`.
7769

78-
See `toml-test -help` for detailed usage.
70+
See `toml-test test -help` for detailed usage.
7971

8072
### Implementing a decoder
8173
For your decoder to be compatible with `toml-test` it **must** satisfy the
@@ -230,13 +222,13 @@ version of TOML; for example the 1.0.0 tests contain a test that trailing commas
230222
in tables are invalid, but in 1.1.0 this should be considered valid.
231223

232224
In short: you can't "just" copy all .toml and .json files from the tests/
233-
directory. The easiest way to copy the correct files is to use `-copy`:
225+
directory. The easiest way to copy the correct files is to use `copy`:
234226

235227
# Default of TOML 1.0
236-
% toml-test -copy ./tests
228+
% toml-test copy ./tests
237229

238230
# Use TOML 1.1
239-
% toml-test -copy ./tests -toml 1.1.0
231+
% toml-test copy -toml 1.1.0 ./tests
240232

241233
Alternatively, the [tests/files-toml-1.0.0] and [tests/files-toml-1.1.0] files
242234
contain a list of files you should run for that TOML version. You can use them
@@ -257,7 +249,7 @@ mentioned above, tests are split into two groups: invalid and valid tests.
257249

258250
Invalid tests **only check if a decoder rejects invalid TOML data**. Or, in the
259251
case of testing encoders, invalid tests **only check if an encoder rejects an
260-
invalid representation of TOML** (e.g., a hetergeneous array). Therefore, all
252+
invalid representation of TOML** (e.g., a heterogeneous array). Therefore, all
261253
invalid tests should try to **test one thing and one thing only**. Invalid tests
262254
should be named after the fault it is trying to expose. Invalid tests for
263255
decoders are in the `tests/invalid` directory while invalid tests for encoders

cmd/toml-test/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"sort"
99
"strings"
1010

11-
tomltest "github.com/toml-lang/toml-test"
11+
tomltest "github.com/toml-lang/toml-test/v2"
1212
"zgo.at/zli"
1313
)
1414

cmd/toml-test/main.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,30 @@ func main() {
3333
return
3434
}
3535
if err != nil {
36-
if helpFlag.Set() {
37-
if contains(f.Args, "test") {
38-
fmt.Print(usageTest)
39-
} else {
40-
fmt.Print(usage)
41-
}
42-
return
43-
}
4436
zli.F(err)
4537
}
38+
if helpFlag.Set() {
39+
f.Args, cmd = []string{cmd}, "help"
40+
}
4641

4742
switch cmd {
4843
case "help":
49-
if contains(f.Args, "test") {
50-
fmt.Print(usageTest)
51-
} else {
52-
fmt.Print(usage)
44+
topic := ""
45+
if len(f.Args) > 0 {
46+
topic = f.Args[0]
5347
}
48+
u, ok := helpTopics[topic]
49+
if !ok {
50+
zli.Fatalf("no help for %q", topic)
51+
}
52+
fmt.Print(u)
5453
case "version":
5554
v := f.Bool(false, "v")
5655
zli.F(f.Parse())
5756
zli.PrintVersion(v.Bool())
5857
case "copy", "cp":
5958
cmdCopy(f)
6059
case "test":
61-
if helpFlag.Set() || contains(f.Args, "help") {
62-
fmt.Print(usageTest)
63-
return
64-
}
6560
cmdTest(f)
6661
}
6762
}
68-
69-
func contains[S ~[]E, E comparable](s S, v E) bool {
70-
for i := range s {
71-
if v == s[i] {
72-
return true
73-
}
74-
}
75-
return false
76-
}

cmd/toml-test/test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/BurntSushi/toml"
13-
tomltest "github.com/toml-lang/toml-test"
13+
tomltest "github.com/toml-lang/toml-test/v2"
1414
"zgo.at/jfmt"
1515
"zgo.at/zli"
1616
)

0 commit comments

Comments
 (0)