Hi all,

pg_regress will fail with test suites using only source files if the
destination folders do not exist in the code tree. This is annoying
because this forces to maintain empty folders sql/ and expected/ with
a .gitignore ignoring everything. The issue has been discussed here
(http://www.postgresql.org/message-id/54935d9d.7010...@dunslane.net)
but nobody actually sent a patch, so here is one, and a thread for
this discussion.
Regards,
-- 
Michael
*** a/src/test/regress/pg_regress.c
--- b/src/test/regress/pg_regress.c
***************
*** 496,501 **** convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
--- 496,502 ----
  {
  	char		testtablespace[MAXPGPATH];
  	char		indir[MAXPGPATH];
+ 	char		result_dir[MAXPGPATH];
  	struct stat st;
  	int			ret;
  	char	  **name;
***************
*** 520,525 **** convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
--- 521,534 ----
  		/* Error logged in pgfnames */
  		exit(2);
  
+ 	/*
+ 	 * Enforce creation of destination directory if it does not exist yet.
+ 	 * This is useful for tests using only source files.
+ 	 */
+ 	snprintf(result_dir, MAXPGPATH, "%s/%s", dest_dir, dest_subdir);
+ 	if (!directory_exists(result_dir))
+ 		make_directory(result_dir);
+ 
  	snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
  
  #ifdef WIN32
***************
*** 565,571 **** convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
  		/* build the full actual paths to open */
  		snprintf(prefix, strlen(*name) - 6, "%s", *name);
  		snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name);
! 		snprintf(destfile, MAXPGPATH, "%s/%s/%s.%s", dest_dir, dest_subdir,
  				 prefix, suffix);
  
  		infile = fopen(srcfile, "r");
--- 574,580 ----
  		/* build the full actual paths to open */
  		snprintf(prefix, strlen(*name) - 6, "%s", *name);
  		snprintf(srcfile, MAXPGPATH, "%s/%s", indir, *name);
! 		snprintf(destfile, MAXPGPATH, "%s/%s.%s", result_dir,
  				 prefix, suffix);
  
  		infile = fopen(srcfile, "r");
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to