You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by pb...@apache.org on 2011/01/24 19:38:39 UTC
svn commit: r1062916 - in /subversion/trunk: build/run_tests.py
subversion/tests/cmdline/svntest/main.py subversion/tests/svn_test.h
subversion/tests/svn_test_main.c win-tests.py
Author: pburba
Date: Mon Jan 24 18:38:38 2011
New Revision: 1062916
URL: http://svn.apache.org/viewvc?rev=1062916&view=rev
Log:
Add an option to the C and Python tests so we can run/list a subset of the
tests based on their mode (e.g. list only the XFAIL tests in the entire
suite).
* build/run_tests.py
(TestHarness.__init__): Add mode_filter argument.
(TestHarness.run): If listing rather than running the tests, summarize the
number of tests expected to pass. Adjust the expected log format for
SKIP and XFAIL when listing the test.
(TestHarness._run_c_test,
TestHarness._run_py_test): Accept --mode-filter option.
* subversion/tests/cmdline/svntest/main.py
(TestSpawningThread.run_one): Support --mode-filter option.
(TestRunner.list): Filter test listing based on --mode-filter option,
default to all tests. Adjust the spacing of the test information so it
lines up with the header printed in execute_tests().
(run_one_test): Filter tests run based on --mode-filter option, default
to all tests.
(TestRunner.get_mode): New.
(_create_parser): Handle --mode-filter.
(execute_tests): If listing tests, then don't print the test header if
all the tests in that list are filtered per --mode-filter.
* subversion/tests/svn_test.h
(svn_test_mode_t): Add svn_test_all enum.
* subversion/tests/svn_test_main.c
(mode_filter): New global svn_test_mode_t test option.
(mode_filter_opt): New option enum.
(cl_options): New --mode-filter option.
(do_test_num): Support printing an optional header and communicating back
to the caller that we did so. If we specified a --mode-filter, only
run/list the tests that match the filter. Adjust the spacing of the
test list output to match that of the Python test listing.
(main): Parse --mode-filter. Move printing of test headers for --list
option into do_test_num().
* win-tests.py
(_usage_exit): Add --mode-filter to usage text.
(mode_filter): New global variable.
(global): Accept --mode-filter as a valid option, pass it to
run_tests.TestHarness().
Modified:
subversion/trunk/build/run_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/main.py
subversion/trunk/subversion/tests/svn_test.h
subversion/trunk/subversion/tests/svn_test_main.c
subversion/trunk/win-tests.py
Modified: subversion/trunk/build/run_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/run_tests.py?rev=1062916&r1=1062915&r2=1062916&view=diff
==============================================================================
--- subversion/trunk/build/run_tests.py (original)
+++ subversion/trunk/build/run_tests.py Mon Jan 24 18:38:38 2011
@@ -79,7 +79,7 @@ class TestHarness:
server_minor_version=None, verbose=None,
cleanup=None, enable_sasl=None, parallel=None, config_file=None,
fsfs_sharding=None, fsfs_packing=None,
- list_tests=None, svn_bin=None):
+ list_tests=None, svn_bin=None, mode_filter=None):
'''Construct a TestHarness instance.
ABS_SRCDIR and ABS_BUILDDIR are the source and build directories.
@@ -91,6 +91,8 @@ class TestHarness:
HTTP_LIBRARY is the HTTP library for DAV-based communications.
SERVER_MINOR_VERSION is the minor version of the server being tested.
SVN_BIN is the path where the svn binaries are installed.
+ mode_filter restricts the TestHarness to tests with the expected mode
+ XFail, Skip, Pass, or All tests (default).
'''
self.srcdir = abs_srcdir
self.builddir = abs_builddir
@@ -113,6 +115,7 @@ class TestHarness:
self.config_file = os.path.abspath(config_file)
self.list_tests = list_tests
self.svn_bin = svn_bin
+ self.mode_filter = mode_filter
self.log = None
if not sys.stdout.isatty() or sys.platform == 'win32':
TextColors.disable()
@@ -151,10 +154,13 @@ class TestHarness:
sys.stdout.write('%s\n [[%s'
% (x[:wip], x[wip + len(wimptag):]))
- passed = [x for x in log_lines if x[:6] == 'PASS: ']
+ if self.list_tests:
+ passed = [x for x in log_lines if x[8:13] == ' ']
+ else:
+ passed = [x for x in log_lines if x[:6] == 'PASS: ']
if self.list_tests:
- skipped = [x for x in log_lines if x[9:13] == 'SKIP']
+ skipped = [x for x in log_lines if x[8:12] == 'SKIP']
else:
skipped = [x for x in log_lines if x[:6] == 'SKIP: ']
@@ -164,7 +170,7 @@ class TestHarness:
sys.stdout.write(x)
if self.list_tests:
- xfailed = [x for x in log_lines if x[9:14] == 'XFAIL']
+ xfailed = [x for x in log_lines if x[8:13] == 'XFAIL']
else:
xfailed = [x for x in log_lines if x[:6] == 'XFAIL:']
if xfailed and not self.list_tests:
@@ -190,8 +196,12 @@ class TestHarness:
else:
print('Summary of test results:')
if passed:
- print(' %d test%s PASSED'
- % (len(passed), 's'*min(len(passed) - 1, 1)))
+ if self.list_tests:
+ print(' %d test%s are set to PASS'
+ % (len(passed), 's'*min(len(passed) - 1, 1)))
+ else:
+ print(' %d test%s PASSED'
+ % (len(passed), 's'*min(len(passed) - 1, 1)))
if skipped:
if self.list_tests:
print(' %d test%s are set as SKIP'
@@ -292,6 +302,8 @@ class TestHarness:
cmdline.append('--server-minor-version=' + self.server_minor_version)
if self.list_tests is not None:
cmdline.append('--list')
+ if self.mode_filter is not None:
+ cmdline.append('--mode-filter=' + self.mode_filter)
if test_nums:
test_nums = test_nums.split(',')
@@ -343,6 +355,8 @@ class TestHarness:
svntest.main.options.fsfs_sharding = self.fsfs_sharding
if self.fsfs_packing is not None:
svntest.main.options.fsfs_packing = self.fsfs_packing
+ if self.mode_filter is not None:
+ svntest.main.options.mode_filter = self.mode_filter
svntest.main.options.srcdir = self.srcdir
Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1062916&r1=1062915&r2=1062916&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Mon Jan 24 18:38:38 2011
@@ -1130,6 +1130,8 @@ class TestSpawningThread(threading.Threa
args.append('--http-library=' + options.http_library)
if options.server_minor_version:
args.append('--server-minor-version=' + str(options.server_minor_version))
+ if options.mode_filter:
+ args.append('--mode-filter=' + options.mode_filter)
result, stdout_lines, stderr_lines = spawn_process(command, 0, 0, None,
*args)
@@ -1151,17 +1153,24 @@ class TestRunner:
self.index = index
def list(self):
- if options.verbose and self.pred.inprogress:
- print(" %3d %-5s %s [[%s]]" % (self.index,
- self.pred.list_mode(),
- self.pred.description,
- self.pred.inprogress))
- else:
- print(" %3d %-5s %s" % (self.index,
- self.pred.list_mode(),
- self.pred.description))
+ if options.mode_filter.upper() == 'ALL' \
+ or options.mode_filter.upper() == self.pred.list_mode().upper() \
+ or (options.mode_filter.upper() == 'PASS' \
+ and self.pred.list_mode() == ''):
+ if options.verbose and self.pred.inprogress:
+ print(" %3d %-5s %s [[%s]]" % (self.index,
+ self.pred.list_mode(),
+ self.pred.description,
+ self.pred.inprogress))
+ else:
+ print(" %3d %-5s %s" % (self.index,
+ self.pred.list_mode(),
+ self.pred.description))
sys.stdout.flush()
+ def get_mode(self):
+ return self.pred.list_mode()
+
def get_function_name(self):
return self.pred.get_function_name()
@@ -1276,9 +1285,15 @@ def run_one_test(n, test_list, finished_
if n < 0:
n += 1+num_tests
- # Run the test.
- exit_code = TestRunner(test_list[n], n).run()
- return exit_code
+ test_mode = TestRunner(test_list[n], n).get_mode().upper()
+ if options.mode_filter.upper() == 'ALL' \
+ or options.mode_filter.upper() == test_mode \
+ or (options.mode_filter.upper() == 'PASS' and test_mode == ''):
+ # Run the test.
+ exit_code = TestRunner(test_list[n], n).run()
+ return exit_code
+ else:
+ return 0
def _internal_run_tests(test_list, testnums, parallel, srcdir, progress_func):
"""Run the tests from TEST_LIST whose indices are listed in TESTNUMS.
@@ -1300,6 +1315,7 @@ def _internal_run_tests(test_list, testn
if not parallel:
for i, testnum in enumerate(testnums):
+
if run_one_test(testnum, test_list) == 1:
exit_code = 1
# signal progress
@@ -1369,6 +1385,9 @@ def _create_parser():
parser.add_option('-c', action='store_true', dest='is_child_process',
help='Flag if we are running this python test as a ' +
'child process')
+ parser.add_option('--mode-filter', action='store', dest='mode_filter',
+ default='ALL',
+ help='Limit tests to those with type specified (e.g. XFAIL)')
parser.add_option('--url', action='store',
help='Base url to the repos (e.g. svn://localhost)')
parser.add_option('--fs-type', action='store',
@@ -1565,11 +1584,18 @@ def execute_tests(test_list, serial_only
testnums = list(range(1, len(test_list)))
if options.list_tests:
- print("Test # Mode Test Description")
- print("------ ----- ----------------")
+ header = "Test # Mode Test Description\n" \
+ "------ ----- ----------------"
+ printed_header = False
for testnum in testnums:
- TestRunner(test_list[testnum], testnum).list()
-
+ test_mode = TestRunner(test_list[testnum], testnum).get_mode().upper()
+ if options.mode_filter.upper() == 'ALL' \
+ or options.mode_filter.upper() == test_mode \
+ or (options.mode_filter.upper() == 'PASS' and test_mode == ''):
+ if not printed_header:
+ print header
+ printed_header = True
+ TestRunner(test_list[testnum], testnum).list()
# We are simply listing the tests so always exit with success.
return 0
Modified: subversion/trunk/subversion/tests/svn_test.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test.h?rev=1062916&r1=1062915&r2=1062916&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test.h (original)
+++ subversion/trunk/subversion/tests/svn_test.h Mon Jan 24 18:38:38 2011
@@ -95,7 +95,8 @@ enum svn_test_mode_t
{
svn_test_pass,
svn_test_xfail,
- svn_test_skip
+ svn_test_skip,
+ svn_test_all
};
/* Each test gets a test descriptor, holding the function and other
Modified: subversion/trunk/subversion/tests/svn_test_main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/svn_test_main.c?rev=1062916&r1=1062915&r2=1062916&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/svn_test_main.c (original)
+++ subversion/trunk/subversion/tests/svn_test_main.c Mon Jan 24 18:38:38 2011
@@ -68,6 +68,10 @@ static svn_boolean_t cleanup_mode = FALS
/* Test option: Allow segfaults */
static svn_boolean_t allow_segfaults = FALSE;
+/* Test option: Limit testing to a given mode (i.e. XFail, Skip,
+ Pass, All). */
+enum svn_test_mode_t mode_filter = svn_test_all;
+
/* Option parsing enums and structures */
enum {
cleanup_opt = SVN_OPT_FIRST_LONGOPT_ID,
@@ -79,7 +83,8 @@ enum {
config_opt,
server_minor_version_opt,
allow_segfault_opt,
- srcdir_opt
+ srcdir_opt,
+ mode_filter_opt
};
static const apr_getopt_option_t cl_options[] =
@@ -92,6 +97,9 @@ static const apr_getopt_option_t cl_opti
N_("specify a filesystem backend type ARG")},
{"list", list_opt, 0,
N_("lists all the tests with their short description")},
+ {"mode-filter", mode_filter_opt, 1,
+ N_("only run/list tests with expected mode ARG = PASS, "
+ "XFAIL, SKIP, or ALL (default)\n")},
{"verbose", verbose_opt, 0,
N_("print extra information")},
{"server-minor-version", server_minor_version_opt, 1,
@@ -199,12 +207,15 @@ crash_handler(int signum)
/* Execute a test number TEST_NUM. Pretty-print test name and dots
- according to our test-suite spec, and return the result code. */
+ according to our test-suite spec, and return the result code.
+ If HEADER_MSG and *HEADER_MSG are not NULL, print *HEADER_MSG prior
+ to pretty-printing the test information, then set *HEADER_MSG to NULL. */
static svn_boolean_t
do_test_num(const char *progname,
int test_num,
svn_boolean_t msg_only,
svn_test_opts_t *opts,
+ const char **header_msg,
apr_pool_t *pool)
{
svn_boolean_t skip, xfail, wimp;
@@ -213,12 +224,15 @@ do_test_num(const char *progname,
const char *msg = NULL; /* the message this individual test prints out */
const struct svn_test_descriptor_t *desc;
const int array_size = get_array_size();
+ svn_boolean_t run_this_test; /* This test's mode matches DESC->MODE. */
/* Check our array bounds! */
if (test_num < 0)
test_num += array_size + 1;
if ((test_num > array_size) || (test_num <= 0))
{
+ if (header_msg && *header_msg)
+ printf(*header_msg);
printf("FAIL: %s: THERE IS NO TEST NUMBER %2d\n", progname, test_num);
skip_cleanup = TRUE;
return TRUE; /* BAIL, this test number doesn't exist. */
@@ -229,6 +243,13 @@ do_test_num(const char *progname,
xfail = desc->mode == svn_test_xfail;
wimp = xfail && desc->wip;
msg = desc->msg;
+ run_this_test = mode_filter == svn_test_all || mode_filter == desc->mode;
+
+ if (run_this_test && header_msg && *header_msg)
+ {
+ printf(*header_msg);
+ *header_msg = NULL;
+ }
if (!allow_segfaults)
{
@@ -245,7 +266,7 @@ do_test_num(const char *progname,
if (setjmp(jump_buffer) == 0)
{
/* Do test */
- if (msg_only || skip)
+ if (msg_only || skip || !run_this_test)
; /* pass */
else if (desc->func2)
err = (*desc->func2)(pool);
@@ -282,15 +303,16 @@ do_test_num(const char *progname,
if (msg_only)
{
- printf(" %2d %-5s %s%s%s%s\n",
- test_num,
- (xfail ? "XFAIL" : (skip ? "SKIP" : "")),
- msg ? msg : "(test did not provide name)",
- (wimp && verbose_mode) ? " [[" : "",
- (wimp && verbose_mode) ? desc->wip : "",
- (wimp && verbose_mode) ? "]]" : "");
+ if (run_this_test)
+ printf(" %3d %-5s %s%s%s%s\n",
+ test_num,
+ (xfail ? "XFAIL" : (skip ? "SKIP" : "")),
+ msg ? msg : "(test did not provide name)",
+ (wimp && verbose_mode) ? " [[" : "",
+ (wimp && verbose_mode) ? desc->wip : "",
+ (wimp && verbose_mode) ? "]]" : "");
}
- else if ((! quiet_mode) || test_failed)
+ else if (run_this_test && ((! quiet_mode) || test_failed))
{
printf("%s %s %d: %s%s%s%s\n",
(err
@@ -407,6 +429,22 @@ main(int argc, const char *argv[])
case list_opt:
list_mode = TRUE;
break;
+ case mode_filter_opt:
+ if (svn_cstring_casecmp(opt_arg, "PASS") == 0)
+ mode_filter = svn_test_pass;
+ else if (svn_cstring_casecmp(opt_arg, "XFAIL") == 0)
+ mode_filter = svn_test_xfail;
+ else if (svn_cstring_casecmp(opt_arg, "SKIP") == 0)
+ mode_filter = svn_test_skip;
+ else if (svn_cstring_casecmp(opt_arg, "ALL") == 0)
+ mode_filter = svn_test_all;
+ else
+ {
+ fprintf(stderr, "FAIL: Invalid --mode-filter option. Try ");
+ fprintf(stderr, " PASS, XFAIL, SKIP or ALL.\n");
+ exit(1);
+ }
+ break;
case verbose_opt:
verbose_mode = TRUE;
break;
@@ -456,15 +494,16 @@ main(int argc, const char *argv[])
{
if (! strcmp(argv[1], "list") || list_mode)
{
+ const char *header_msg;
ran_a_test = TRUE;
/* run all tests with MSG_ONLY set to TRUE */
-
- printf("Test # Mode Test Description\n"
- "------ ----- ----------------\n");
+ header_msg = "Test # Mode Test Description\n"
+ "------ ----- ----------------\n";
for (i = 1; i <= array_size; i++)
{
- if (do_test_num(prog_name, i, TRUE, &opts, test_pool))
+ if (do_test_num(prog_name, i, TRUE, &opts, &header_msg,
+ test_pool))
got_error = TRUE;
/* Clear the per-function pool */
@@ -484,7 +523,8 @@ main(int argc, const char *argv[])
continue;
ran_a_test = TRUE;
- if (do_test_num(prog_name, test_num, FALSE, &opts, test_pool))
+ if (do_test_num(prog_name, test_num, FALSE, &opts, NULL,
+ test_pool))
got_error = TRUE;
/* Clear the per-function pool */
@@ -500,7 +540,7 @@ main(int argc, const char *argv[])
/* just run all tests */
for (i = 1; i <= array_size; i++)
{
- if (do_test_num(prog_name, i, FALSE, &opts, test_pool))
+ if (do_test_num(prog_name, i, FALSE, &opts, NULL, test_pool))
got_error = TRUE;
/* Clear the per-function pool */
Modified: subversion/trunk/win-tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/win-tests.py?rev=1062916&r1=1062915&r2=1062916&view=diff
==============================================================================
--- subversion/trunk/win-tests.py (original)
+++ subversion/trunk/win-tests.py Mon Jan 24 18:38:38 2011
@@ -79,6 +79,8 @@ def _usage_exit():
print(" --http-library : dav library to use, neon (default) or serf")
print(" --javahl : Run the javahl tests instead of the normal tests")
print(" --list : print test doc strings only")
+ print(" --mode-filter=TYPE : limit tests to expected TYPE = XFAIL, SKIP, PASS,")
+ print(" or 'ALL' (default)")
print(" --enable-sasl : enable Cyrus SASL authentication for")
print(" svnserve")
print(" -p, --parallel : run multiple tests in parallel")
@@ -121,7 +123,7 @@ opts, args = my_getopt(sys.argv[1:], 'hr
'fsfs-packing', 'fsfs-sharding=', 'javahl',
'list', 'enable-sasl', 'bin=', 'parallel',
'config-file=', 'server-minor-version=',
- 'log-to-stdout'])
+ 'log-to-stdout', 'mode-filter='])
if len(args) > 1:
print('Warning: non-option arguments after the first one will be ignored')
@@ -147,6 +149,7 @@ fsfs_packing = None
server_minor_version = None
config_file = None
log_to_stdout = None
+mode_filter=None
tests_to_run = []
for opt, val in opts:
@@ -192,6 +195,8 @@ for opt, val in opts:
test_javahl = 1
elif opt == '--list':
list_tests = 1
+ elif opt == '--mode-filter':
+ mode_filter = val
elif opt == '--enable-sasl':
enable_sasl = 1
base_url = "svn://localhost/"
@@ -683,7 +688,7 @@ if not test_javahl:
server_minor_version, not quiet,
cleanup, enable_sasl, parallel, config_file,
fsfs_sharding, fsfs_packing,
- list_tests, svn_bin)
+ list_tests, svn_bin, mode_filter)
old_cwd = os.getcwd()
try:
os.chdir(abs_builddir)