Testing, and Programmable Shells

ziggy on 2005-05-26T19:25:28

Every time I see a reference to scsh, I just ask myself Why? I can understand the love of $LANGUAGE, and I can understand having a "full programming language" available at all times. But that always felt like putting a power nailgun into a square hole and declaring It Fits! to anyone within earshot.

But having a programmable shell does make sense. I've been using bash for mumble years now, but only as a Bourne shell with better PS1 escapes, readline support, and some some syntactic sugar on top(i.e. export PATH=~/bin:$PATH).

This week, I got tired of typing this:

$ make test TESTS=t/000.t
leading to failures, which then get investigated by typing this:
$ perl t/000.t 2>&1 | grep -v '^ok ' | vim -
What's a perlhacker to do? My initial reaction was to write a one-liner and stick it in ~/bin, but that didn't feel right; over time, my ~/bin slowly grows and grows with simple one-liners that I've totally forgotten about, and never use a week or so after I dropped them in there.

Time for plan B, as in bash functions:

$ function test {
> make test TESTS=t/$1.t
> }

$ function examine {
> perl t/$1.t 2>&1 | grep -v '^ok ' | vim -
> }

$ test 000     ## a failing test
$ examine 000  ## what failed?
Works for me.

If I still use them after a week, I'll drop them in my .bashrc, where I can promptly forget about them. ;-)


prove?

jesse on 2005-05-27T17:05:20

I'm surprised you aren't using prove to run individual tests ;)

Re:prove?

ziggy on 2005-05-27T18:12:56

Actually, the rule for make test just calls prove. I forgot about using prove directly because make test is burned deeper into my neurons. ;-)