Tom Lane wrote:
Andrew Dunstan <[EMAIL PROTECTED]> writes:
One other thought I had was that we could have pg_regress always allow a fallback to the canonical result file.

Hm, that's a good thought.  Want to see how painful it is to code?


Would this do the trick?

cheers

andrew


Index: pg_regress.c
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/pg_regress.c,v
retrieving revision 1.16
diff -c -r1.16 pg_regress.c
*** pg_regress.c	27 Jul 2006 15:37:19 -0000	1.16
--- pg_regress.c	1 Aug 2006 14:04:20 -0000
***************
*** 914,919 ****
--- 914,952 ----
  		}
  	}
  
+ 	/* 
+ 	 * 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);
+ 		if (!file_exists(expectfile))
+ 			continue;
+ 
+ 		snprintf(cmd, sizeof(cmd),
+ 				 SYSTEMQUOTE "diff %s \"%s\" \"%s\" > \"%s\"" SYSTEMQUOTE,
+ 				 basic_diff_opts, expectfile, resultsfile, diff);
+ 		run_diff(cmd);
+ 
+ 		if (file_size(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.
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to