]> granicus.if.org Git - postgresql/blobdiff - src/test/regress/pg_regress.c
Update copyright for the year 2010.
[postgresql] / src / test / regress / pg_regress.c
index 3f27dbfec17ffb704d029347d0b357952691627a..551b626d3c6b0ab33ad5570768cc37db14afb08b 100644 (file)
@@ -8,10 +8,10 @@
  *
  * This code is released under the terms of the PostgreSQL License.
  *
- * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.64 2009/08/18 10:30:41 teodor Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.69 2010/01/02 16:58:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,9 +65,18 @@ static char *makeprog = MAKEPROG;
 static char *shellprog = SHELLPROG;
 #endif
 
-/* currently we can use the same diff switches on all platforms */
+/*
+ * On Windows we use -w in diff switches to avoid problems with inconsistent
+ * newline representation.  The actual result files will generally have
+ * Windows-style newlines, but the comparison files might or might not.
+ */
+#ifndef WIN32
+const char *basic_diff_opts = "";
+const char *pretty_diff_opts = "-C3";
+#else
 const char *basic_diff_opts = "-w";
 const char *pretty_diff_opts = "-w -C3";
+#endif
 
 /* options settable from command line */
 _stringlist *dblist = NULL;
@@ -84,6 +93,7 @@ static char *temp_install = NULL;
 static char *temp_config = NULL;
 static char *top_builddir = NULL;
 static bool nolocale = false;
+static bool use_existing = false;
 static char *hostname = NULL;
 static int     port = -1;
 static bool port_specified_by_user = false;
@@ -1021,6 +1031,10 @@ spawn_process(const char *cmdline)
        cmdline2 = malloc(strlen(cmdline) + 8);
        sprintf(cmdline2, "cmd /c %s", cmdline);
 
+#ifndef __CYGWIN__
+       AddUserToTokenDacl(restrictedToken);
+#endif
+
        if (!CreateProcessAsUser(restrictedToken,
                                                         NULL,
                                                         cmdline2,
@@ -1038,10 +1052,6 @@ spawn_process(const char *cmdline)
                exit_nicely(2);
        }
 
-#ifndef __CYGWIN__
-       AddUserToDacl(pi.hProcess);
-#endif
-
        free(cmdline2);
 
        ResumeThread(pi.hThread);
@@ -1536,7 +1546,7 @@ run_schedule(const char *schedule, test_function tfunc)
 
                if (num_tests == 1)
                {
-                       status(_("test %-20s ... "), tests[0]);
+                       status(_("test %-24s ... "), tests[0]);
                        pids[0] = (tfunc) (tests[0], &resultfiles[0], &expectfiles[0], &tags[0]);
                        wait_for_tests(pids, statuses, NULL, 1);
                        /* status line is finished below */
@@ -1581,7 +1591,7 @@ run_schedule(const char *schedule, test_function tfunc)
                        bool            differ = false;
 
                        if (num_tests > 1)
-                               status(_("     %-20s ... "), tests[i]);
+                               status(_("     %-24s ... "), tests[i]);
 
                        /*
                         * Advance over all three lists simultaneously.
@@ -1909,6 +1919,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                {"dlpath", required_argument, NULL, 17},
                {"create-role", required_argument, NULL, 18},
                {"temp-config", required_argument, NULL, 19},
+               {"use-existing", no_argument, NULL, 20},
                {NULL, 0, NULL, 0}
        };
 
@@ -1999,6 +2010,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                        case 19:
                                temp_config = strdup(optarg);
                                break;
+                       case 20:
+                               use_existing = true;
+                               break;
                        default:
                                /* getopt_long already emitted a complaint */
                                fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
@@ -2245,19 +2259,25 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
                 * Using an existing installation, so may need to get rid of
                 * pre-existing database(s) and role(s)
                 */
-               for (sl = dblist; sl; sl = sl->next)
-                       drop_database_if_exists(sl->str);
-               for (sl = extraroles; sl; sl = sl->next)
-                       drop_role_if_exists(sl->str);
+               if (!use_existing)
+               {
+                       for (sl = dblist; sl; sl = sl->next)
+                               drop_database_if_exists(sl->str);
+                       for (sl = extraroles; sl; sl = sl->next)
+                               drop_role_if_exists(sl->str);
+               }
        }
 
        /*
         * Create the test database(s) and role(s)
         */
-       for (sl = dblist; sl; sl = sl->next)
-               create_database(sl->str);
-       for (sl = extraroles; sl; sl = sl->next)
-               create_role(sl->str, dblist);
+       if (!use_existing)
+       {
+               for (sl = dblist; sl; sl = sl->next)
+                       create_database(sl->str);
+               for (sl = extraroles; sl; sl = sl->next)
+                       create_role(sl->str, dblist);
+       }
 
        /*
         * Ready to run the tests