3 ms·
txtar is used in the testsuite package to make writing CLI (blackbox) tests really easy. It adds a header section for the steps to run and comparisons to make.
by verdverm 2y ago
txtar is used in the testsuite package to make writing CLI (blackbox) tests really easy. It adds a header section for the steps to run and comparisons to make. Often you compare actual output with golden data.
(https://github.com/golang/go/tree/master/src/cmd/go/testdata/script https://github.com/golang/go/tree/master/src/cmd/go/testdata...)
The tools have been extracted and made installable from here: https://github.com/rogpeppe/go-internal/tree/master/cmd https://github.com/rogpeppe/go-internal/tree/master/cmd
This is really handy for any project to have people submit reproducers as a single file anyone can run. These tools make it so you can transform between txtar and files on disk, and then run the txtar (testscript) as a test or directory of tests.
I have built them into my hof tool, "hof run [--mode test] file.txtar" so you run them as either test files or multifile scripts. The second option is handy if you want to eject a file onto the filesystem without having to do echo or EOF business in bash scripts
https://github.com/hofstadter-io/hof/tree/_dev/script/runtime https://github.com/hofstadter-io/hof/tree/_dev/script/runtim...