#!/bin/zsh setopt extended_glob cd $(dirname $0) bin=../../dist/build/fix-imports/fix-imports tests=$* if [[ -z $tests ]]; then tests=$(echo *(/)) fi tmp=$(mktemp -t fix-imports) function test() { pushd $1 local flags= if [[ -r flags ]]; then flags=$(cat flags) fi $bin ${=flags} Main.hs & $tmp diff $tmp expected local failed=$? if [[ $failed != 0 ]]; then echo '==== expected:' cat expected echo '==== got:' cat $tmp fi popd return $failed } failed=0 for test in ${=tests}; do if ! test $test; then echo $test FAILED failed=1 break else echo $test passed fi done rm -f $tmp exit $failed