Commit f4ba82e3 authored by Robert Ricci's avatar Robert Ricci

Sort both the current tables and database-fill.sql before comparing

them - the old method was relying on them coming out of the database
in the same order, which may not be the case.
parent 8afbdd12
......@@ -23,29 +23,47 @@ my $testbed_srcdir = "@top_srcdir@";
# Locals
my $master_fill = "$testbed_srcdir/sql/database-fill.sql";
my $export_tables = "../utils/export_tables";
my $tempfile = "/tmp/dbdiff.$$";
my $tempdifffile = "/tmp/dbdiff.$$";
my $tempnewfile = "/tmp/dbdiff.new.$$";
my $tempoldfile = "/tmp/dbdiff.old.$$";
my $exitcode = 0;
#
# Diff exits with 2 if a problem. We tell diff to ignore whitespace
# changes and comment lines (line starting with '--').
#
if (system("perl $export_tables | ".
"diff -b -B -I '^--.*\$' $master_fill - > $tempfile") == 2) {
unlink($tempfile);
# We sort(1) the text files so that we don't pick up differences in ordering,
# which could be pretty random.
#
if (system("perl $export_tables | sort > $tempoldfile")) {
unlink($tempoldfile);
die("*** $0:\n".
" $export_tables failed!\n");
}
if (system("sort $master_fill > $tempnewfile")) {
unlink($tempoldfile);
die("*** $0:\n".
" diff $export_tables failed!\n");
" sort $master_fill failed!\n");
}
if (system("diff -b -B -I '^--.*\$' $tempoldfile $tempnewfile > $tempdifffile")
== 2) {
unlink($tempdifffile);
die("*** $0:\n".
" diff $tempoldfile $tempnewfile failed!\n");
}
unlink($tempoldfile);
unlink($tempnewfile);
# No differences ...
if (!$?) {
unlink($tempfile);
unlink($tempdifffile);
exit(0);
}
#
# Oh well. Cat the diff to stdout and exit with non-zero status.
#
system("cat $tempfile");
unlink($tempfile);
system("cat $tempdifffile");
unlink($tempdifffile);
exit(1);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment