Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Testscript, a hidden gem the Go team kept locked away (encore.dev)
10 points by todsacerdoti on May 12, 2022 | hide | past | favorite | 3 comments


This reminds me of Littlecheck [0], the test helper we use in fish [1].

The way that works is that you provide a script to be run in some interpreter (for our cases that's usually fish, but it can also be sh or python or ruby or whatever you want), and then you give the expected output in "#CHECK" and "#CHECKERR" (for stderr) comments, optionally with regexes.

So you can write your test as a script and compare the output.

So the hello world example from the article would be one file called "hello.sh":

    #RUN: /bin/sh %s
    cat hello.txt
    #CHECK: hello world
And you'd run it with `littlecheck hello.sh`. Unmatched output is an error, so if `cat` errored out the test would fail. (the `#RUN` directive can also be a shebang line, but #RUN allows substitutions, so you can e.g. define the script runner).

[0]:https://github.com/ridiculousfish/littlecheck [1]:https://fishshell.com/


I fail to see the benefit of this over Ent [0]. Define schema in "their way" but then never have to deal with anything SQL related ever again?

[0] https://entgo.io


Are you commenting on the right article? This is about a testing library, and doesn't mention SQL?




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: