Remove dynamic translation of regression test scripts, step 2.
authorTom Lane <[email protected]>
Mon, 20 Dec 2021 19:15:52 +0000 (14:15 -0500)
committerTom Lane <[email protected]>
Mon, 20 Dec 2021 19:15:52 +0000 (14:15 -0500)
"git mv" all the input/*.source and output/*.source files into
the corresponding sql/ and expected/ directories.  Then remove
the pg_regress and Makefile infrastructure associated with
dynamic translation.

Discussion: https://postgr.es/m/1655733.1639871614@sss.pgh.pa.us

38 files changed:
contrib/dblink/Makefile
contrib/dblink/expected/.gitignore [deleted file]
contrib/dblink/expected/paths.out [moved from contrib/dblink/output/paths.source with 100% similarity]
contrib/dblink/sql/.gitignore [deleted file]
contrib/dblink/sql/paths.sql [moved from contrib/dblink/input/paths.source with 100% similarity]
contrib/file_fdw/Makefile
contrib/file_fdw/expected/.gitignore [deleted file]
contrib/file_fdw/expected/file_fdw.out [moved from contrib/file_fdw/output/file_fdw.source with 100% similarity]
contrib/file_fdw/sql/.gitignore [deleted file]
contrib/file_fdw/sql/file_fdw.sql [moved from contrib/file_fdw/input/file_fdw.source with 100% similarity]
src/interfaces/ecpg/test/pg_regress_ecpg.c
src/pl/plpgsql/src/Makefile
src/pl/plpgsql/src/expected/.gitignore [deleted file]
src/pl/plpgsql/src/expected/plpgsql_copy.out [moved from src/pl/plpgsql/src/output/plpgsql_copy.source with 100% similarity]
src/pl/plpgsql/src/sql/.gitignore [deleted file]
src/pl/plpgsql/src/sql/plpgsql_copy.sql [moved from src/pl/plpgsql/src/input/plpgsql_copy.source with 100% similarity]
src/test/regress/GNUmakefile
src/test/regress/expected/.gitignore [deleted file]
src/test/regress/expected/constraints.out [moved from src/test/regress/output/constraints.source with 100% similarity]
src/test/regress/expected/copy.out [moved from src/test/regress/output/copy.source with 100% similarity]
src/test/regress/expected/create_function_0.out [moved from src/test/regress/output/create_function_0.source with 100% similarity]
src/test/regress/expected/create_function_1.out [moved from src/test/regress/output/create_function_1.source with 100% similarity]
src/test/regress/expected/create_function_2.out [moved from src/test/regress/output/create_function_2.source with 100% similarity]
src/test/regress/expected/largeobject.out [moved from src/test/regress/output/largeobject.source with 100% similarity]
src/test/regress/expected/largeobject_1.out [moved from src/test/regress/output/largeobject_1.source with 100% similarity]
src/test/regress/expected/misc.out [moved from src/test/regress/output/misc.source with 100% similarity]
src/test/regress/expected/tablespace.out [moved from src/test/regress/output/tablespace.source with 100% similarity]
src/test/regress/pg_regress.c
src/test/regress/pg_regress.h
src/test/regress/sql/.gitignore [deleted file]
src/test/regress/sql/constraints.sql [moved from src/test/regress/input/constraints.source with 100% similarity]
src/test/regress/sql/copy.sql [moved from src/test/regress/input/copy.source with 100% similarity]
src/test/regress/sql/create_function_0.sql [moved from src/test/regress/input/create_function_0.source with 100% similarity]
src/test/regress/sql/create_function_1.sql [moved from src/test/regress/input/create_function_1.source with 100% similarity]
src/test/regress/sql/create_function_2.sql [moved from src/test/regress/input/create_function_2.source with 100% similarity]
src/test/regress/sql/largeobject.sql [moved from src/test/regress/input/largeobject.source with 100% similarity]
src/test/regress/sql/misc.sql [moved from src/test/regress/input/misc.source with 100% similarity]
src/test/regress/sql/tablespace.sql [moved from src/test/regress/input/tablespace.source with 100% similarity]

index b008c8c4c4ba0146cf518a9a4759cc83d33e245f..6bb3ece38c8fd2fb54f611b97993e478a4636ea8 100644 (file)
@@ -13,7 +13,6 @@ PGFILEDESC = "dblink - connect to other PostgreSQL databases"
 
 REGRESS = paths dblink
 REGRESS_OPTS = --dlpath=$(top_builddir)/src/test/regress
-EXTRA_CLEAN = sql/paths.sql expected/paths.out
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
diff --git a/contrib/dblink/expected/.gitignore b/contrib/dblink/expected/.gitignore
deleted file mode 100644 (file)
index d9c7942..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/paths.out
diff --git a/contrib/dblink/sql/.gitignore b/contrib/dblink/sql/.gitignore
deleted file mode 100644 (file)
index d175078..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/paths.sql
index 4da9f2d697a2802429810b52902c10af1a9e0117..885459d3c16e938b6f38fcc3f72f3326d0b6f16e 100644 (file)
@@ -8,8 +8,6 @@ PGFILEDESC = "file_fdw - foreign data wrapper for files"
 
 REGRESS = file_fdw
 
-EXTRA_CLEAN = sql/file_fdw.sql expected/file_fdw.out
-
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/file_fdw/expected/.gitignore b/contrib/file_fdw/expected/.gitignore
deleted file mode 100644 (file)
index a464ad1..0000000
+++ /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 (file)
index ebf16fe..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/file_fdw.sql
index 15f588a8023095dd4acadba9a57a503a67a2d472..9465ba7845a29603c4da31f292e8912413b6c5ca 100644 (file)
@@ -166,9 +166,14 @@ ecpg_start_test(const char *testname,
        snprintf(inprg, sizeof(inprg), "%s/%s", inputdir, testname);
        snprintf(insource, sizeof(insource), "%s.c", testname);
 
+       /* make a version of the test name that has dashes in place of slashes */
        initStringInfo(&testname_dash);
        appendStringInfoString(&testname_dash, testname);
-       replace_string(&testname_dash, "/", "-");
+       for (char *c = testname_dash.data; *c != '\0'; c++)
+       {
+               if (*c == '/')
+                       *c = '-';
+       }
 
        snprintf(expectfile_stdout, sizeof(expectfile_stdout),
                         "%s/expected/%s.stdout",
index 9946abbc1de6591e561a34743bca2dbb29415710..f7eb42d54fc51fdd94b59c2342fd647719e0ee47 100644 (file)
@@ -41,11 +41,6 @@ TOOLSDIR = $(top_srcdir)/src/tools
 GEN_KEYWORDLIST = $(PERL) -I $(TOOLSDIR) $(TOOLSDIR)/gen_keywordlist.pl
 GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
-# Test input and expected files.  These are created by pg_regress itself, so we
-# don't have a rule to create them.  We do need rules to clean them however.
-input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
-output_files := $(patsubst $(srcdir)/output/%.source,expected/%.out, $(wildcard $(srcdir)/output/*.source))
-
 all: all-lib
 
 # Shared library stuff
@@ -116,7 +111,6 @@ distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_
 # are not cleaned here.
 clean distclean: clean-lib
        rm -f $(OBJS)
-       rm -f $(output_files) $(input_files)
        rm -rf $(pg_regress_clean_files)
 
 maintainer-clean: distclean
diff --git a/src/pl/plpgsql/src/expected/.gitignore b/src/pl/plpgsql/src/expected/.gitignore
deleted file mode 100644 (file)
index 13e5918..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/plpgsql_copy.out
diff --git a/src/pl/plpgsql/src/sql/.gitignore b/src/pl/plpgsql/src/sql/.gitignore
deleted file mode 100644 (file)
index 210bee1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/plpgsql_copy.sql
index fe6e0c98aa2e03b6b6adebdc257176467ff9c963..330eca2b83961327a92bb80894dcffd62730e0eb 100644 (file)
@@ -69,19 +69,12 @@ all: all-lib
 # Ensure parallel safety if a build is started in this directory
 $(OBJS): | submake-libpgport submake-generated-headers
 
-# Test input and expected files.  These are created by pg_regress itself, so we
-# don't have a rule to create them.  We do need rules to clean them however.
-input_files = $(patsubst $(srcdir)/input/%.source,sql/%.sql, $(wildcard $(srcdir)/input/*.source))
-output_files := $(patsubst $(srcdir)/output/%.source,expected/%.out, $(wildcard $(srcdir)/output/*.source))
-
 
 # not installed by default
 
 regress_data_files = \
-       $(filter-out $(addprefix $(srcdir)/,$(output_files)),$(wildcard $(srcdir)/expected/*.out)) \
-       $(wildcard $(srcdir)/input/*.source) \
-       $(wildcard $(srcdir)/output/*.source) \
-       $(filter-out $(addprefix $(srcdir)/,$(input_files)),$(wildcard $(srcdir)/sql/*.sql)) \
+       $(wildcard $(srcdir)/sql/*.sql) \
+       $(wildcard $(srcdir)/expected/*.out) \
        $(wildcard $(srcdir)/data/*.data) \
        $(srcdir)/parallel_schedule $(srcdir)/resultmap
 
@@ -162,6 +155,5 @@ clean distclean maintainer-clean: clean-lib
        rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
        rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
 # things created by various check targets
-       rm -f $(output_files) $(input_files)
        rm -rf testtablespace
        rm -rf $(pg_regress_clean_files)
diff --git a/src/test/regress/expected/.gitignore b/src/test/regress/expected/.gitignore
deleted file mode 100644 (file)
index b99caf5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/constraints.out
-/copy.out
-/create_function_0.out
-/create_function_1.out
-/create_function_2.out
-/largeobject.out
-/largeobject_1.out
-/misc.out
-/security_label.out
-/tablespace.out
index c2fcff55bfb475aab9452806d227c2fb2e90956d..589357ba59c20171d0cb6ba800711263987004a8 100644 (file)
@@ -438,155 +438,6 @@ string_matches_pattern(const char *str, const char *pattern)
        return false;
 }
 
-/*
- * Replace all occurrences of "replace" in "string" with "replacement".
- * The StringInfo will be suitably enlarged if necessary.
- *
- * Note: this is optimized on the assumption that most calls will find
- * no more than one occurrence of "replace", and quite likely none.
- */
-void
-replace_string(StringInfo string, const char *replace, const char *replacement)
-{
-       int                     pos = 0;
-       char       *ptr;
-
-       while ((ptr = strstr(string->data + pos, replace)) != NULL)
-       {
-               /* Must copy the remainder of the string out of the StringInfo */
-               char       *suffix = pg_strdup(ptr + strlen(replace));
-
-               /* Truncate StringInfo at start of found string ... */
-               string->len = ptr - string->data;
-               /* ... and append the replacement (this restores the trailing '\0') */
-               appendStringInfoString(string, replacement);
-               /* Next search should start after the replacement */
-               pos = string->len;
-               /* Put back the remainder of the string */
-               appendStringInfoString(string, suffix);
-               free(suffix);
-       }
-}
-
-/*
- * Convert *.source found in the "source" directory, replacing certain tokens
- * in the file contents with their intended values, and put the resulting files
- * in the "dest" directory, replacing the ".source" prefix in their names with
- * the given suffix.
- */
-static void
-convert_sourcefiles_in(const char *source_subdir, const char *dest_dir, const char *dest_subdir, const char *suffix)
-{
-       char            testtablespace[MAXPGPATH];
-       char            indir[MAXPGPATH];
-       char            outdir_sub[MAXPGPATH];
-       char      **name;
-       char      **names;
-       int                     count = 0;
-
-       snprintf(indir, MAXPGPATH, "%s/%s", inputdir, source_subdir);
-
-       /* Check that indir actually exists and is a directory */
-       if (!directory_exists(indir))
-       {
-               /*
-                * No warning, to avoid noise in tests that do not have these
-                * directories; for example, ecpg, contrib and src/pl.
-                */
-               return;
-       }
-
-       names = pgfnames(indir);
-       if (!names)
-               /* Error logged in pgfnames */
-               exit(2);
-
-       /* Create the "dest" subdirectory if not present */
-       snprintf(outdir_sub, MAXPGPATH, "%s/%s", dest_dir, dest_subdir);
-       if (!directory_exists(outdir_sub))
-               make_directory(outdir_sub);
-
-       /* We might need to replace @testtablespace@ */
-       snprintf(testtablespace, MAXPGPATH, "%s/testtablespace", outputdir);
-
-       /* finally loop on each file and do the replacement */
-       for (name = names; *name; name++)
-       {
-               char            srcfile[MAXPGPATH];
-               char            destfile[MAXPGPATH];
-               char            prefix[MAXPGPATH];
-               FILE       *infile,
-                                  *outfile;
-               StringInfoData line;
-
-               /* reject filenames not finishing in ".source" */
-               if (strlen(*name) < 8)
-                       continue;
-               if (strcmp(*name + strlen(*name) - 7, ".source") != 0)
-                       continue;
-
-               count++;
-
-               /* 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");
-               if (!infile)
-               {
-                       fprintf(stderr, _("%s: could not open file \"%s\" for reading: %s\n"),
-                                       progname, srcfile, strerror(errno));
-                       exit(2);
-               }
-               outfile = fopen(destfile, "w");
-               if (!outfile)
-               {
-                       fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
-                                       progname, destfile, strerror(errno));
-                       exit(2);
-               }
-
-               initStringInfo(&line);
-
-               while (pg_get_line_buf(infile, &line))
-               {
-                       replace_string(&line, "@abs_srcdir@", inputdir);
-                       replace_string(&line, "@abs_builddir@", outputdir);
-                       replace_string(&line, "@testtablespace@", testtablespace);
-                       replace_string(&line, "@libdir@", dlpath);
-                       replace_string(&line, "@DLSUFFIX@", DLSUFFIX);
-                       fputs(line.data, outfile);
-               }
-
-               pfree(line.data);
-               fclose(infile);
-               fclose(outfile);
-       }
-
-       /*
-        * If we didn't process any files, complain because it probably means
-        * somebody neglected to pass the needed --inputdir argument.
-        */
-       if (count <= 0)
-       {
-               fprintf(stderr, _("%s: no *.source files found in \"%s\"\n"),
-                               progname, indir);
-               exit(2);
-       }
-
-       pgfnames_cleanup(names);
-}
-
-/* Create the .sql and .out files from the .source files, if any */
-static void
-convert_sourcefiles(void)
-{
-       convert_sourcefiles_in("input", outputdir, "sql", "sql");
-       convert_sourcefiles_in("output", outputdir, "expected", "out");
-}
-
 /*
  * Clean out the test tablespace dir, or create it if it doesn't exist.
  *
@@ -936,7 +787,6 @@ initialize_environment(void)
                        printf(_("(using postmaster on Unix socket, default port)\n"));
        }
 
-       convert_sourcefiles();
        load_resultmap();
 }
 
index c6d015c8402a2113778ad862e148becf40dde4d7..ad91dfb85872e425d92acca98bf62bc2a004a8f6 100644 (file)
@@ -65,6 +65,4 @@ int                   regression_main(int argc, char *argv[],
 
 void           add_stringlist_item(_stringlist **listhead, const char *str);
 PID_TYPE       spawn_process(const char *cmdline);
-void           replace_string(struct StringInfoData *string,
-                                                  const char *replace, const char *replacement);
 bool           file_exists(const char *file);
diff --git a/src/test/regress/sql/.gitignore b/src/test/regress/sql/.gitignore
deleted file mode 100644 (file)
index fe14af6..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/constraints.sql
-/copy.sql
-/create_function_0.sql
-/create_function_1.sql
-/create_function_2.sql
-/largeobject.sql
-/misc.sql
-/security_label.sql
-/tablespace.sql