pgloader/test/regress.sh
Dimitri Fontaine f6fae39b2e Explicitely use gawk in the new regression testing facility.
Turns out that debian has mawk by default, which is not behaving the
same in our very simple use case already. In passing, add gawk as a
build dependency of the debian package, because the packaging is meant
to exercize the test cases.
2014-06-03 13:39:21 +02:00

20 lines
570 B
Bash
Executable File

#! /bin/bash
# regress test driver
# - run pgloader on the given .load command file
# - parse the PostgreSQL connection string and target table
# - output a CSV for the target table
# - diff the CSV and error if diffs found
pgloader=$1
command=$2
targetdb=`gawk -F '[ ?]+' '/^ *INTO|into/ {print $3}' < $command`
table=`gawk -F '[ ?]+' '/^ *INTO|into/ {print $4}' < $command`
expected=regress/expected/`basename $2 .load`.out
out=regress/out/`basename $2 .load`.out
$pgloader $command
psql -c "copy $table to stdout" -d "$targetdb" > $out
diff -c $expected $out