mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-21 10:29:02 +00:00
137 lines
2.6 KiB
Bash
Executable file
137 lines
2.6 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# ================================================================
|
|
# This is similar to reg_test/run except that this one is only ever run
|
|
# manually, not automatically as part of the build. It can be used to iterate on
|
|
# as-yet-unreleased features (in particular, features whose definition isn't
|
|
# finalized) without breaking the build.
|
|
# ================================================================
|
|
set -e
|
|
|
|
ourdir=`dirname $0`
|
|
srcdir=$ourdir/../..
|
|
pwd=`pwd`
|
|
|
|
try1=$pwd/../mlr # For autoconf builds, in-tree or out-of-tree
|
|
try2=$srcdir/c/mlr # For non-autoconf builds
|
|
if [ -x "$try1" ]; then
|
|
path_to_mlr=$try1
|
|
elif [ -x "$try2" ]; then
|
|
path_to_mlr=$try2
|
|
else
|
|
echo "$0: Could not find path to mlr executable." 1>&2
|
|
echo "Try 1: $try1" 1>&2
|
|
echo "Try 2: $try2" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$1" = "--valgrind" ]; then
|
|
# Leak-check the test suite. Needs 'make mlrg' first.
|
|
# ../tools/clean-valg can be used to filter the output.
|
|
path_to_mlr="valgrind --leak-check=full ${path_to_mlr}g"
|
|
fi
|
|
echo Using mlr executable $path_to_mlr
|
|
|
|
indir=$ourdir/input
|
|
expdir=$ourdir/expected
|
|
outdir=$pwd/output
|
|
outfile=$outdir/out-dev
|
|
expfile=$expdir/out-dev
|
|
mkdir -p $outdir
|
|
|
|
rm -f $outfile
|
|
touch $outfile
|
|
echo
|
|
|
|
num_passed=0
|
|
|
|
announce() {
|
|
echo >> $outfile
|
|
echo "================================================================" >> $outfile
|
|
echo "$@" >> $outfile
|
|
echo >> $outfile
|
|
}
|
|
|
|
run_mlr() {
|
|
# Use just "mlr" for info messages
|
|
echo mlr "$@"
|
|
echo mlr "$@" >> $outfile
|
|
# Use path to mlr for invoking the command
|
|
$path_to_mlr "$@" >> $outfile
|
|
echo >> $outfile
|
|
# since set -e
|
|
num_passed=`expr $num_passed + 1`
|
|
}
|
|
|
|
# ================================================================
|
|
announce ABSENT-HANDLING
|
|
|
|
run_mlr put '$a = $a * 2' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put '$new = $a * 2' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put '$new = @nonesuch * 2' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put '$new = @nonesuch * $a' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put '@sum = @sum + $a; emit @sum' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put '@product = @product * $a; emit @product' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put 'begin { @sum = 10 }; @sum = @sum + $a; emit @sum' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
run_mlr put 'begin { @product = 10 }; @product = @product * $a; emit @product' <<EOF
|
|
a=1,b=2
|
|
a=,b=4
|
|
x=,b=6
|
|
a=7,b=8
|
|
EOF
|
|
|
|
# ================================================================
|
|
cat $outfile
|
|
|
|
echo
|
|
echo
|
|
echo
|
|
echo
|
|
|
|
diff -I '^mlr ' -C5 $expfile $outfile
|
|
|
|
# ================================================================
|
|
echo ALL REGRESSION TESTS PASSED
|
|
echo Tests completed: $num_passed
|