Testing Dolt using BATS (Bash Automated Testing System)
dolthub.com
dolthub.com
Bash is inherently untestable.
The only way to reliably return something besides a status code is via globals.
That means that most functions already rely on previously set global state. Which is one of the reasons that Bash scripts don't scale (the other is non-existent error handling).
Do yourself a favor and use a proper scripting language.
Your bash is untestable, but that's just because of your chosen abstractions.
Bash is just a proper script language with a weird string and implicit IO system.
Disclaimer: I stick to POSIX sh but same difference.
Initially I was skeptical, and tried using Node and Mocha for writing tests instead, but calling shell from other languages is pretty cumbersome, and at some point that became very annoying. I gave Bats a try and was pleasantly surprised.
Once one gets used to it Shell is a really good language if the large chunk of your work is calling out external processes and passing the outputs between them. Sure, some language design choices of Shell are arcane and subpar, but with tools like Bats and Shellcheck it's possible to reach comparable levels of developer ergonomics that we all got used to with more popular languages.
Lots of bash hate on HN today.
Shellcheck is the training wheels bash deserves, if you're learning it's indispensable just to harass you for quoting.
Are you sure?
2011: https://news.ycombinator.com/item?id=3408934
(Links for the curious. Reposts are ok after a year: https://news.ycombinator.com/newsfaq.html)
It’s a general unit test tool, but working in bash orients Bats towards testing of scripted/automated infrastructure. I’ve used it for tests of Chef/Puppet configuration and found Bats a good fit. Seems odd to find it used as the test framework for a data management tool but clearly it floats their boat.
https://github.com/bats-core/bats-core
It's really nice for when you want to run/test a bunch of things in bash and have nice output and test suites.