Commit f4ba82e3 authored by Robert Ricci's avatar Robert Ricci
Browse files

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@"; ...@@ -23,29 +23,47 @@ my $testbed_srcdir = "@top_srcdir@";
# Locals # Locals
my $master_fill = "$testbed_srcdir/sql/database-fill.sql"; my $master_fill = "$testbed_srcdir/sql/database-fill.sql";
my $export_tables = "../utils/export_tables"; 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; my $exitcode = 0;
# #
# Diff exits with 2 if a problem. We tell diff to ignore whitespace # Diff exits with 2 if a problem. We tell diff to ignore whitespace
# changes and comment lines (line starting with '--'). # changes and comment lines (line starting with '--').
# #
if (system("perl $export_tables | ". # We sort(1) the text files so that we don't pick up differences in ordering,
"diff -b -B -I '^--.*\$' $master_fill - > $tempfile") == 2) { # which could be pretty random.
unlink($tempfile); #
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". 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 ... # No differences ...
if (!$?) { if (!$?) {
unlink($tempfile); unlink($tempdifffile);
exit(0); exit(0);
} }
# #
# Oh well. Cat the diff to stdout and exit with non-zero status. # Oh well. Cat the diff to stdout and exit with non-zero status.
# #
system("cat $tempfile"); system("cat $tempdifffile");
unlink($tempfile); unlink($tempdifffile);
exit(1); exit(1);
Supports Markdown
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