From a3bae608135fb11decd2f29f5db268690736dd5d Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Tue, 1 Aug 2006 14:56:29 +0000 Subject: [PATCH] have pg_regress fall back on testing with the canonical results file if an alternative test is specified but none succeeds. --- src/test/regress/pg_regress.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index fb8c7d8dee..335e4d7de6 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.17 2006/07/30 01:45:21 momjian Exp $ + * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.18 2006/08/01 14:56:29 adunstan Exp $ * *------------------------------------------------------------------------- */ @@ -913,6 +913,36 @@ results_differ(const char *testname) } } + /* + * fall back on the canonical results file if we haven't tried it yet + * and haven't found a complete match yet. + */ + + if (strcmp(expectname, testname) != 0) + { + snprintf(expectfile, sizeof(expectfile), "%s/expected/%s.out", + inputdir, testname, i); + + snprintf(cmd, sizeof(cmd), + SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE, + basic_diff_opts, expectfile, resultsfile, diff); + + if (run_diff(cmd, diff) == 0) + { + /* No diff = no changes = good */ + unlink(diff); + return false; + } + + l = file_line_count(diff); + if (l < best_line_count) + { + /* This diff was a better match than the last one */ + best_line_count = l; + strcpy(best_expect_file, expectfile); + } + } + /* * Use the best comparison file to generate the "pretty" diff, which * we append to the diffs summary file.