On Wed, Feb 25, 2015 at 4:27 AM, Peter Eisentraut <pete...@gmx.net> wrote:
> On 2/23/15 1:27 AM, Michael Paquier wrote:
>>> I would like to have an extension in tree that also does this, so we
>>> > have a regression test of this functionality.
>> Sure. Here is one in the patch attached added as a test module. The
>> name of the module is regress_dynamic. Perhaps the name could be
>> better..
>
> I was more thinking like we could use an existing module like file_fdw.

Right. I forgot this one. A patch is attached to do so.
-- 
Michael
From 65ccaf61a4c298a79747ec39a8dd75ec998a1125 Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@otacoo.com>
Date: Mon, 23 Feb 2015 15:02:14 +0900
Subject: [PATCH 1/2] Enforce creation of input and output paths in pg_regress

This is particularly useful for extensions that have only regression tests
in input/ and output/ dynamically generated when running the tests to keep
the code tree of such extensions clean without empty folders containing as
only content a .gitignore ignoring everything else other than its own
existence.
---
 src/test/regress/pg_regress.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 3af0e57..a7aa580 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -496,6 +496,7 @@ convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
 {
 	char		testtablespace[MAXPGPATH];
 	char		indir[MAXPGPATH];
+	char		result_dir[MAXPGPATH];
 	struct stat st;
 	int			ret;
 	char	  **name;
@@ -520,6 +521,14 @@ convert_sourcefiles_in(char *source_subdir, char *dest_dir, char *dest_subdir, c
 		/* 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,7 +574,7 @@ 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,
+		snprintf(destfile, MAXPGPATH, "%s/%s.%s", result_dir,
 				 prefix, suffix);
 
 		infile = fopen(srcfile, "r");
-- 
2.3.0

From 7f290ab2a4ffb6b59bdd836d5d61167f31a4845e Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@otacoo.com>
Date: Thu, 26 Feb 2015 14:26:01 +0900
Subject: [PATCH 2/2] Remove expected/ and sql/ in file_fdw

pg_regress is in charge of creating those folders if they do not exist.
---
 contrib/file_fdw/.gitignore          | 2 ++
 contrib/file_fdw/expected/.gitignore | 1 -
 contrib/file_fdw/sql/.gitignore      | 1 -
 3 files changed, 2 insertions(+), 2 deletions(-)
 delete mode 100644 contrib/file_fdw/expected/.gitignore
 delete mode 100644 contrib/file_fdw/sql/.gitignore

diff --git a/contrib/file_fdw/.gitignore b/contrib/file_fdw/.gitignore
index 5dcb3ff..9834c6d 100644
--- a/contrib/file_fdw/.gitignore
+++ b/contrib/file_fdw/.gitignore
@@ -1,4 +1,6 @@
 # Generated subdirectories
+/expected/
 /log/
 /results/
+/sql/
 /tmp_check/
diff --git a/contrib/file_fdw/expected/.gitignore b/contrib/file_fdw/expected/.gitignore
deleted file mode 100644
index a464ad1..0000000
--- a/contrib/file_fdw/expected/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/file_fdw.out
diff --git a/contrib/file_fdw/sql/.gitignore b/contrib/file_fdw/sql/.gitignore
deleted file mode 100644
index ebf16fe..0000000
--- a/contrib/file_fdw/sql/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/file_fdw.sql
-- 
2.3.0

-- 
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