Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tj
Created October 20, 2011 00:36
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tj/1300101 to your computer and use it in GitHub Desktop.
Save tj/1300101 to your computer and use it in GitHub Desktop.
tiny bash test runner
TESTS = $(shell find test/test.*.js)
test:
@./test/run.sh $(TESTS)
.PHONY: test
#!/usr/bin/env bash
echo
for file in $@; do
printf "\033[90m ${file#test/}\033[0m "
node $file && printf "\033[36m✓\033[0m\n"
test $? -eq 0 || exit $?
done
echo
$ make test
test.exports.js ✓
test.socket.events.js ✓
test.socket.js ✓
test.socket.messages.js ✓
test.socket.pub-sub.filter.js ✓
test.socket.pub-sub.js ✓
test.socket.req-rep.js ✓
test.socket.req-rep.multiple.js ✓
test.socket.sndmore.js ✓
@TooTallNate
Copy link

n00b question: How do I use this?

@tj
Copy link
Author

tj commented Oct 20, 2011

one sec I'll add a make target example :D

@tj
Copy link
Author

tj commented Oct 20, 2011

I was rewriting express tests to use similar until I realized windows would be fucked haha. You can also do something like make TESTS=test/test.socket.*.js or just node test/test.socket.js, so even though it's stupid-simple it's kinda nice

@TooTallNate
Copy link

Oh fuck ya, that shit is sexy (The $@ confused me, now I know what that means :p).

I'm gonna start using this over my lazy one-liner version: https://github.com/TooTallNate/create/blob/bd015233ca4ac6b7a3cd13c8d1ff0a45dc8f9340/package.json#L9

@dshaw
Copy link

dshaw commented Oct 20, 2011

Hot!

@craigbarnes
Copy link

You can get free parallel execution with this + make -j2 test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment