Comments on: How to test shell scripts https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/ Extract tables from PDFs and scrape the web Thu, 14 Jul 2016 16:12:42 +0000 hourly 1 https://wordpress.org/?v=4.6 By: npm install urchin | ScraperWiki Data Blog https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/#comment-829 Mon, 24 Jun 2013 16:37:28 +0000 http://blog.scraperwiki.com/?p=758217698#comment-829 […] the shell testing framework for extreme hipster superheroes (I’m not including myself in that group I should add), is now available as an npm […]

]]>
By: dgvncsz0f https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/#comment-828 Fri, 14 Dec 2012 12:17:45 +0000 http://blog.scraperwiki.com/?p=758217698#comment-828 There is also a golden-test approach: http://joyful.com/shelltestrunner/

I find it quite useful, and it is possible to test shell scripts using
a pattern like this:

— script.sh
some_function () {

}

— script.test
. script.sh; some_function [args…]
<<>>
expected stdout
>>>2
expected stderr
>>=0 # execpted exit code

]]>
By: descartavel1 https://blog.scraperwiki.com/2012/12/how-to-test-shell-scripts/#comment-827 Wed, 12 Dec 2012 18:43:17 +0000 http://blog.scraperwiki.com/?p=758217698#comment-827 had you been writing scripts like it’s the norm when writing Makefile all you had to do was replace your collateral generator command with something innocuous.

e.g.
SORT=/bin/sort
CURL=/bin/curl
$SORT $1 | $CURL http://example.com/save.php -T — #or something like this, totally forgot now how to POST something with curl

then you could have another script for testing that that would call the initial script but with $CURL being /bin/echo or something. and for repeatability testing you can write another script that does that uses a know input and compare that to a know output of the echo.

never touched any of the frameworks you mention and would be scared of what complexity they introduce on my scripts to begin with.

]]>