Created
November 9, 2012 01:18
-
-
Save mmalecki/4043108 to your computer and use it in GitHub Desktop.
The only test runner you'll ever need
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Running test suite" | |
passed=0 | |
failed=0 | |
total=0 | |
for t in test/*-test.js; do | |
total=`expr $total + 1` | |
echo | |
echo "Running $t..." | |
output=`node $t` | |
code=$? | |
if [ $code -ne 0 ]; then | |
failed=`expr $failed + 1` | |
echo $output | |
echo " $(tput setaf 1)✗ $t (exit code: $code)$(tput sgr0)" | |
else | |
passed=`expr $passed + 1` | |
echo " $(tput setaf 2)✓ $t $(tput sgr0)" | |
fi | |
done | |
echo | |
if [ $failed -eq 0 ]; then | |
echo "$(tput setaf 2)✓ OK » $passed passed$(tput sgr0)" | |
else | |
echo "$(tput setaf 1)✗ Failed » $failed failed$(tput sgr0)" | |
echo "$(tput setaf 2) $passed passed$(tput sgr0)" | |
exit 1 | |
fi |
I'm a bit opposed to running tests in parallel, especially if they interact with DBs or services, but if it's good for your usecase that's a very good idea
yeah that can get ugly, node stuff is usually fast enough anyway
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works even better if you use make targets, then you can -j 4