diff --git a/contrib/dblink/Makefile b/contrib/dblink/Makefile index b008c8c4c4..6bb3ece38c 100644 --- a/contrib/dblink/Makefile +++ b/contrib/dblink/Makefile @@ -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 index d9c7942c64..0000000000 --- a/contrib/dblink/expected/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/paths.out diff --git a/contrib/dblink/output/paths.source b/contrib/dblink/expected/paths.out similarity index 100% rename from contrib/dblink/output/paths.source rename to contrib/dblink/expected/paths.out diff --git a/contrib/dblink/sql/.gitignore b/contrib/dblink/sql/.gitignore deleted file mode 100644 index d17507846d..0000000000 --- a/contrib/dblink/sql/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/paths.sql diff --git a/contrib/dblink/input/paths.source b/contrib/dblink/sql/paths.sql similarity index 100% rename from contrib/dblink/input/paths.source rename to contrib/dblink/sql/paths.sql diff --git a/contrib/file_fdw/Makefile b/contrib/file_fdw/Makefile index 4da9f2d697..885459d3c1 100644 --- a/contrib/file_fdw/Makefile +++ b/contrib/file_fdw/Makefile @@ -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 index a464ad144f..0000000000 --- a/contrib/file_fdw/expected/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_fdw.out diff --git a/contrib/file_fdw/output/file_fdw.source b/contrib/file_fdw/expected/file_fdw.out similarity index 100% rename from contrib/file_fdw/output/file_fdw.source rename to contrib/file_fdw/expected/file_fdw.out diff --git a/contrib/file_fdw/sql/.gitignore b/contrib/file_fdw/sql/.gitignore deleted file mode 100644 index ebf16fed94..0000000000 --- a/contrib/file_fdw/sql/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/file_fdw.sql diff --git a/contrib/file_fdw/input/file_fdw.source b/contrib/file_fdw/sql/file_fdw.sql similarity index 100% rename from contrib/file_fdw/input/file_fdw.source rename to contrib/file_fdw/sql/file_fdw.sql diff --git a/src/interfaces/ecpg/test/pg_regress_ecpg.c b/src/interfaces/ecpg/test/pg_regress_ecpg.c index 15f588a802..9465ba7845 100644 --- a/src/interfaces/ecpg/test/pg_regress_ecpg.c +++ b/src/interfaces/ecpg/test/pg_regress_ecpg.c @@ -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", diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile index 9946abbc1d..f7eb42d54f 100644 --- a/src/pl/plpgsql/src/Makefile +++ b/src/pl/plpgsql/src/Makefile @@ -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 index 13e5918721..0000000000 --- a/src/pl/plpgsql/src/expected/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/plpgsql_copy.out diff --git a/src/pl/plpgsql/src/output/plpgsql_copy.source b/src/pl/plpgsql/src/expected/plpgsql_copy.out similarity index 100% rename from src/pl/plpgsql/src/output/plpgsql_copy.source rename to src/pl/plpgsql/src/expected/plpgsql_copy.out diff --git a/src/pl/plpgsql/src/sql/.gitignore b/src/pl/plpgsql/src/sql/.gitignore deleted file mode 100644 index 210bee188e..0000000000 --- a/src/pl/plpgsql/src/sql/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/plpgsql_copy.sql diff --git a/src/pl/plpgsql/src/input/plpgsql_copy.source b/src/pl/plpgsql/src/sql/plpgsql_copy.sql similarity index 100% rename from src/pl/plpgsql/src/input/plpgsql_copy.source rename to src/pl/plpgsql/src/sql/plpgsql_copy.sql diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index fe6e0c98aa..330eca2b83 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -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 index b99caf5f40..0000000000 --- a/src/test/regress/expected/.gitignore +++ /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 diff --git a/src/test/regress/output/constraints.source b/src/test/regress/expected/constraints.out similarity index 100% rename from src/test/regress/output/constraints.source rename to src/test/regress/expected/constraints.out diff --git a/src/test/regress/output/copy.source b/src/test/regress/expected/copy.out similarity index 100% rename from src/test/regress/output/copy.source rename to src/test/regress/expected/copy.out diff --git a/src/test/regress/output/create_function_0.source b/src/test/regress/expected/create_function_0.out similarity index 100% rename from src/test/regress/output/create_function_0.source rename to src/test/regress/expected/create_function_0.out diff --git a/src/test/regress/output/create_function_1.source b/src/test/regress/expected/create_function_1.out similarity index 100% rename from src/test/regress/output/create_function_1.source rename to src/test/regress/expected/create_function_1.out diff --git a/src/test/regress/output/create_function_2.source b/src/test/regress/expected/create_function_2.out similarity index 100% rename from src/test/regress/output/create_function_2.source rename to src/test/regress/expected/create_function_2.out diff --git a/src/test/regress/output/largeobject.source b/src/test/regress/expected/largeobject.out similarity index 100% rename from src/test/regress/output/largeobject.source rename to src/test/regress/expected/largeobject.out diff --git a/src/test/regress/output/largeobject_1.source b/src/test/regress/expected/largeobject_1.out similarity index 100% rename from src/test/regress/output/largeobject_1.source rename to src/test/regress/expected/largeobject_1.out diff --git a/src/test/regress/output/misc.source b/src/test/regress/expected/misc.out similarity index 100% rename from src/test/regress/output/misc.source rename to src/test/regress/expected/misc.out diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/expected/tablespace.out similarity index 100% rename from src/test/regress/output/tablespace.source rename to src/test/regress/expected/tablespace.out diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index c2fcff55bf..589357ba59 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -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(); } diff --git a/src/test/regress/pg_regress.h b/src/test/regress/pg_regress.h index c6d015c840..ad91dfb858 100644 --- a/src/test/regress/pg_regress.h +++ b/src/test/regress/pg_regress.h @@ -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 index fe14af6ae7..0000000000 --- a/src/test/regress/sql/.gitignore +++ /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 diff --git a/src/test/regress/input/constraints.source b/src/test/regress/sql/constraints.sql similarity index 100% rename from src/test/regress/input/constraints.source rename to src/test/regress/sql/constraints.sql diff --git a/src/test/regress/input/copy.source b/src/test/regress/sql/copy.sql similarity index 100% rename from src/test/regress/input/copy.source rename to src/test/regress/sql/copy.sql diff --git a/src/test/regress/input/create_function_0.source b/src/test/regress/sql/create_function_0.sql similarity index 100% rename from src/test/regress/input/create_function_0.source rename to src/test/regress/sql/create_function_0.sql diff --git a/src/test/regress/input/create_function_1.source b/src/test/regress/sql/create_function_1.sql similarity index 100% rename from src/test/regress/input/create_function_1.source rename to src/test/regress/sql/create_function_1.sql diff --git a/src/test/regress/input/create_function_2.source b/src/test/regress/sql/create_function_2.sql similarity index 100% rename from src/test/regress/input/create_function_2.source rename to src/test/regress/sql/create_function_2.sql diff --git a/src/test/regress/input/largeobject.source b/src/test/regress/sql/largeobject.sql similarity index 100% rename from src/test/regress/input/largeobject.source rename to src/test/regress/sql/largeobject.sql diff --git a/src/test/regress/input/misc.source b/src/test/regress/sql/misc.sql similarity index 100% rename from src/test/regress/input/misc.source rename to src/test/regress/sql/misc.sql diff --git a/src/test/regress/input/tablespace.source b/src/test/regress/sql/tablespace.sql similarity index 100% rename from src/test/regress/input/tablespace.source rename to src/test/regress/sql/tablespace.sql