have pg_regress fall back on testing with the canonical results file if an
authorAndrew Dunstan <andrew@dunslane.net>
Tue, 1 Aug 2006 14:56:29 +0000 (14:56 +0000)
committerAndrew Dunstan <andrew@dunslane.net>
Tue, 1 Aug 2006 14:56:29 +0000 (14:56 +0000)
alternative test is specified but none succeeds.

src/test/regress/pg_regress.c

index 07c07c0096e96e5ef27012b3afc0bed3104cf5f1..922e7657e0087a94898fe9a4060ab4fb527130dd 100644 (file)
@@ -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.