提交 c1417c9e 编写于 作者: J Jimmy Yih

Add pg_regress --exclude-tests option

When running pg_regress, sometimes you may want to exclude certain
tests from your schedule file from running. Before, you would have to
modify the schedule file to comment/ignore out the unwanted test. Now
we can do it from command line with --exclude-tests option that is
space and comma delimited.

Example:
./pg_regress --exclude-tests="test1 test2,test3 ... testN"

Authors: Abhijit Subramanya and Jimmy Yih
上级 f20c4cdd
...@@ -89,6 +89,7 @@ static _stringlist *loadlanguage = NULL; ...@@ -89,6 +89,7 @@ static _stringlist *loadlanguage = NULL;
static int max_connections = 0; static int max_connections = 0;
static char *encoding = NULL; static char *encoding = NULL;
static _stringlist *schedulelist = NULL; static _stringlist *schedulelist = NULL;
static _stringlist *exclude_tests = NULL;
static _stringlist *extra_tests = NULL; static _stringlist *extra_tests = NULL;
static char *temp_install = NULL; static char *temp_install = NULL;
static char *temp_config = NULL; static char *temp_config = NULL;
...@@ -128,6 +129,8 @@ static void drop_database_if_exists(const char *dbname); ...@@ -128,6 +129,8 @@ static void drop_database_if_exists(const char *dbname);
static int static int
run_diff(const char *cmd, const char *filename); run_diff(const char *cmd, const char *filename);
static bool should_exclude_test(char *test);
static void static void
header(const char *fmt,...) header(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
...@@ -1890,12 +1893,26 @@ run_schedule(const char *schedule, test_function tfunc) ...@@ -1890,12 +1893,26 @@ run_schedule(const char *schedule, test_function tfunc)
schedule, line_num); schedule, line_num);
exit_nicely(2); exit_nicely(2);
} }
if (num_tests - 1 >= 0 && should_exclude_test(tests[num_tests - 1]))
num_tests--;
tests[num_tests] = c; tests[num_tests] = c;
num_tests++; num_tests++;
inword = true; inword = true;
} }
} }
/* The last test in the line needs to be checked for exclusion */
if (num_tests - 1 >= 0 && should_exclude_test(tests[num_tests - 1]))
{
num_tests--;
/* All tests in this line are to be excluded, so go to the next line */
if (num_tests == 0)
continue;
}
if (num_tests == 0) if (num_tests == 0)
{ {
fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"), fprintf(stderr, _("syntax error in schedule file \"%s\" line %d: %s\n"),
...@@ -2284,6 +2301,22 @@ trim_white_space(char *str) ...@@ -2284,6 +2301,22 @@ trim_white_space(char *str)
return str; return str;
} }
/*
* Should the test be excluded from running
*/
static bool
should_exclude_test(char *test)
{
_stringlist *sl;
for (sl = exclude_tests; sl != NULL; sl = sl->next)
{
if (strcmp(test, sl->str) == 0)
return true;
}
return false;
}
/* /*
* @brief Check whether a feature (i.e., optimizer or codegen) is on or off. * @brief Check whether a feature (i.e., optimizer or codegen) is on or off.
* If the input feature is optimizer, then set the global * If the input feature is optimizer, then set the global
...@@ -2369,6 +2402,7 @@ help(void) ...@@ -2369,6 +2402,7 @@ help(void)
printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n")); printf(_(" --outputdir=DIR place output files in DIR (default \".\")\n"));
printf(_(" --schedule=FILE use test ordering schedule from FILE\n")); printf(_(" --schedule=FILE use test ordering schedule from FILE\n"));
printf(_(" (can be used multiple times to concatenate)\n")); printf(_(" (can be used multiple times to concatenate)\n"));
printf(_(" --exclude-tests=TEST command or space delimited tests to exclude from running\n"));
printf(_(" --srcdir=DIR absolute path to source directory (for VPATH builds)\n")); printf(_(" --srcdir=DIR absolute path to source directory (for VPATH builds)\n"));
printf(_(" --temp-install=DIR create a temporary installation in DIR\n")); printf(_(" --temp-install=DIR create a temporary installation in DIR\n"));
printf(_(" --init-file=GPD_INIT_FILE init file to be used for gpdiff\n")); printf(_(" --init-file=GPD_INIT_FILE init file to be used for gpdiff\n"));
...@@ -2428,6 +2462,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -2428,6 +2462,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
{"init-file", required_argument, NULL, 20}, {"init-file", required_argument, NULL, 20},
{"ao-dir", required_argument, NULL, 21}, {"ao-dir", required_argument, NULL, 21},
{"resgroup-dir", required_argument, NULL, 22}, {"resgroup-dir", required_argument, NULL, 22},
{"exclude-tests", required_argument, NULL, 23},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
...@@ -2534,6 +2569,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc ...@@ -2534,6 +2569,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
break; break;
case 22: case 22:
resgroupdir = strdup(optarg); resgroupdir = strdup(optarg);
break;
case 23:
split_to_stringlist(strdup(optarg), ", ", &exclude_tests);
break; break;
default: default:
/* getopt_long already emitted a complaint */ /* getopt_long already emitted a complaint */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册