If someone with the requisite linux skills/hardware could tweak
makefile.in so it can take advantage of the --milestone-filter option,
well that would be fabulous.
Paul
On Thu, Feb 17, 2011 at 5:09 PM, <pburba_at_apache.org> wrote:
> Author: pburba
> Date: Thu Feb 17 22:09:02 2011
> New Revision: 1071809
>
> URL: http://svn.apache.org/viewvc?rev=1071809&view=rev
> Log:
> Add an option (--milestone-filter=REGEX) to the Python tests so we can list a
> subset of the tests based on their associated issues' target milestone.
>
> This option is currently only available to win-tests.py and
> subversion/tests/cmdline/svntest/main.py. Â So it isn't quite as useful
> on non-Windows platforms just yet.
>
> Now we can easily answer questions like, "What xfailing merge tests need to
> be fixed before we can release 1.7?"
>
> Â C:\SVN\src-trunk>win-tests.py --list --milestone-filter="(1.7.*)|(---)"
> Â --mode-filter xfail --log-to-stdout --test merge
> Â Listing Debug configuration on local repository.
> Â LISTING: merge_tests.py
>  Test #  Mode  Test Description
> Â ------ Â ----- Â ----------------
> Â Â 64 Â Â XFAIL Â merge target with non inheritable mergeinfo
> Â [#2970(blue-sky),#3642(1.7.0)]
> Â Â 75 Â Â XFAIL Â merge added subtree [#1962(1.7-consider)]
>
> * build/run_tests.py
>
> Â (TestHarness.__init__): Add mode_filter argument.
>
> Â (TestHarness._run_c_test): Issue warning that --milestone-filter doesn't
> Â work when listing C tests.
>
> Â (TestHarness._run_py_test): Accept --milestone-filter option.
>
> * subversion/tests/cmdline/svntest/main.py
>
> Â (global): Import xml and urllib.
>
> Â (TestSpawningThread.run_one): Support --milestone-filter option.
>
> Â (TestRunner.list): Add optional argument mapping issues to target
> Â milestones.
>
> Â (TestRunner.get_issues): New.
>
> Â (_create_parser): Handle --milestone-filter.
>
> Â (get_target_milestones_for_issues): New.
>
> Â (execute_tests): Handle --milestone-filter.
>
> * win-tests.py
>
> Â (_usage_exit): Add --milestone-filter to usage text.
>
> Â (milestone_filter): New global variable.
>
> Â (global): Accept --milestone-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/win-tests.py
>
> Modified: subversion/trunk/build/run_tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/build/run_tests.py?rev=1071809&r1=1071808&r2=1071809&view=diff
> ==============================================================================
> --- subversion/trunk/build/run_tests.py (original)
> +++ subversion/trunk/build/run_tests.py Thu Feb 17 22:09:02 2011
> @@ -79,7 +79,8 @@ 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, mode_filter=None):
> + Â Â Â Â Â Â Â list_tests=None, svn_bin=None, mode_filter=None,
> + Â Â Â Â Â Â Â milestone_filter=None):
> Â Â '''Construct a TestHarness instance.
>
> Â Â ABS_SRCDIR and ABS_BUILDDIR are the source and build directories.
> @@ -91,8 +92,12 @@ 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).
> + Â Â MODE_FILTER restricts the TestHarness to tests with the expected mode
> + Â Â XFail, Skip, Pass, or All tests (default). Â MILESTONE_FILTER is a
> + Â Â string representation of a valid regular expression pattern; when used
> + Â Â in conjunction with LIST_TESTS, the only tests that are listed are
> + Â Â those with an associated issue in the tracker which has a target
> + Â Â milestone that matches the regex.
> Â Â '''
> Â Â self.srcdir = abs_srcdir
> Â Â self.builddir = abs_builddir
> @@ -114,6 +119,7 @@ class TestHarness:
> Â Â if config_file is not None:
> Â Â Â self.config_file = os.path.abspath(config_file)
> Â Â self.list_tests = list_tests
> + Â Â self.milestone_filter = milestone_filter
> Â Â self.svn_bin = svn_bin
> Â Â self.mode_filter = mode_filter
> Â Â self.log = None
> @@ -280,6 +286,8 @@ class TestHarness:
> Â Â if not self.list_tests:
> Â Â Â sys.stdout.write('.' * dot_count)
> Â Â Â sys.stdout.flush()
> + Â Â elif self.milestone_filter:
> + Â Â Â print 'WARNING: --milestone-filter option does not currently work with C tests'
>
> Â Â if os.access(progbase, os.X_OK):
> Â Â Â progname = './' + progbase
> @@ -349,6 +357,8 @@ class TestHarness:
> Â Â Â svntest.main.options.server_minor_version = self.server_minor_version
> Â Â if self.list_tests is not None:
> Â Â Â svntest.main.options.list_tests = True
> + Â Â if self.milestone_filter is not None:
> + Â Â Â svntest.main.options.milestone_filter = self.milestone_filter
> Â Â if self.svn_bin is not None:
> Â Â Â svntest.main.options.svn_bin = self.svn_bin
> Â Â if self.fsfs_sharding is not None:
>
> Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1071809&r1=1071808&r2=1071809&view=diff
> ==============================================================================
> --- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
> +++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu Feb 17 22:09:02 2011
> @@ -34,6 +34,8 @@ import time   # for time()
> Â import traceback # for print_exc()
> Â import threading
> Â import optparse # for argument parsing
> +import xml
> +import urllib
>
> Â try:
> Â # Python >=3.0
> @@ -1132,6 +1134,8 @@ class TestSpawningThread(threading.Threa
> Â Â Â args.append('--server-minor-version=' + str(options.server_minor_version))
> Â Â if options.mode_filter:
> Â Â Â args.append('--mode-filter=' + options.mode_filter)
> + Â Â if options.milestone_filter:
> + Â Â Â args.append('--milestone-filter=' + options.milestone_filter)
>
> Â Â result, stdout_lines, stderr_lines = spawn_process(command, 0, 0, None,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *args)
> @@ -1152,26 +1156,61 @@ class TestRunner:
> Â Â self.pred = svntest.testcase.create_test_case(func)
> Â Â self.index = index
>
> - Â def list(self):
> + Â def list(self, milestones_dict=None):
> + Â Â """Print test doc strings. Â MILESTONES_DICT is an optional mapping
> + Â Â of issue numbers to target milestones."""
> Â Â 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() == ''):
> + Â Â Â issues = []
> Â Â Â tail = ''
> Â Â Â if self.pred.issues:
> - Â Â Â Â tail += " [%s]" % ','.join(['#%d' % i for i in self.pred.issues])
> - Â Â Â if options.verbose and self.pred.inprogress:
> - Â Â Â Â tail += " [[%s]]" % self.pred.inprogress
> - Â Â Â else:
> -     print(" %3d   %-5s  %s%s" % (self.index,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.pred.list_mode(),
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.pred.description,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tail))
> + Â Â Â Â if not options.milestone_filter or milestones_dict is None:
> + Â Â Â Â Â issues = self.pred.issues
> + Â Â Â Â else: # Limit listing by requested target milestone(s).
> + Â Â Â Â Â filter_issues = []
> + Â Â Â Â Â matches_filter = False
> +
> + Â Â Â Â Â # Get the milestones for all the issues associated with this test.
> + Â Â Â Â Â # If any one of them matches the MILESTONE_FILTER then we'll print
> + Â Â Â Â Â # them all.
> + Â Â Â Â Â for issue in self.pred.issues:
> + Â Â Â Â Â Â # A safe starting assumption.
> + Â Â Â Â Â Â milestone = 'unknown'
> + Â Â Â Â Â Â if milestones_dict:
> + Â Â Â Â Â Â Â if milestones_dict.has_key(str(issue)):
> + Â Â Â Â Â Â Â Â milestone = milestones_dict[str(issue)]
> +
> + Â Â Â Â Â Â filter_issues.append(str(issue) + '(' + milestone + ')')
> + Â Â Â Â Â Â pattern = re.compile(options.milestone_filter)
> + Â Â Â Â Â Â if pattern.match(milestone):
> + Â Â Â Â Â Â Â matches_filter = True
> +
> + Â Â Â Â Â # Did at least one of the associated issues meet our filter?
> + Â Â Â Â Â if matches_filter:
> + Â Â Â Â Â Â issues = filter_issues
> +
> + Â Â Â Â tail += " [%s]" % ','.join(['#%s' % str(i) for i in issues])
> +
> + Â Â Â # If there is no filter or this test made if through
> + Â Â Â # the filter then print it!
> + Â Â Â if options.milestone_filter is None or len(issues):
> + Â Â Â Â if options.verbose and self.pred.inprogress:
> + Â Â Â Â Â tail += " [[%s]]" % self.pred.inprogress
> + Â Â Â Â else:
> +      print(" %3d   %-5s  %s%s" % (self.index,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.pred.list_mode(),
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.pred.description,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tail))
> Â Â sys.stdout.flush()
>
> Â def get_mode(self):
> Â Â return self.pred.list_mode()
>
> + Â def get_issues(self):
> + Â Â return self.pred.issues
> +
> Â def get_function_name(self):
> Â Â return self.pred.get_function_name()
>
> @@ -1376,6 +1415,8 @@ def _create_parser():
> Â parser = optparse.OptionParser(usage=usage)
> Â parser.add_option('-l', '--list', action='store_true', dest='list_tests',
> Â Â Â Â Â Â Â Â Â Â help='Print test doc strings instead of running them')
> + Â parser.add_option('--milestone-filter', action='store', dest='milestone_filter',
> + Â Â Â Â Â Â Â Â Â Â help='Limit --list to those with target milestone specified')
> Â parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
> Â Â Â Â Â Â Â Â Â Â help='Print binary command-lines (not with --quiet)')
> Â parser.add_option('-q', '--quiet', action='store_true',
> @@ -1470,6 +1511,47 @@ def run_tests(test_list, serial_only = F
>
> Â sys.exit(execute_tests(test_list, serial_only))
>
> +def get_target_milestones_for_issues(issue_numbers):
> + Â xml_url = "http://subversion.tigris.org/issues/xml.cgi?id="
> + Â issue_dict = {}
> +
> + Â if isinstance(issue_numbers, int):
> + Â Â issue_numbers = [str(issue_numbers)]
> + Â elif isinstance(issue_numbers, str):
> + Â Â issue_numbers = [issue_numbers]
> +
> + Â if issue_numbers is None or len(issue_numbers) == 0:
> + Â Â return issue_dict
> +
> + Â for num in issue_numbers:
> + Â Â xml_url += str(num) + ','
> + Â Â issue_dict[str(num)] = 'unknown'
> +
> + Â try:
> + Â Â # Parse the xml for ISSUE_NO from the issue tracker into a Document.
> + Â Â issue_xml_f = urllib.urlopen(xml_url)
> + Â except:
> + Â Â print "WARNING: Unable to contact issue tracker; " \
> + Â Â Â Â Â "milestones defaulting to 'unknown'."
> + Â Â return issue_dict
> +
> + Â try:
> + Â Â xmldoc = xml.dom.minidom.parse(issue_xml_f)
> + Â Â issue_xml_f.close()
> +
> + Â Â # Get the target milestone for each issue.
> + Â Â issue_element = xmldoc.getElementsByTagName('issue')
> + Â Â for i in issue_element:
> + Â Â Â issue_id_element = i.getElementsByTagName('issue_id')
> + Â Â Â issue_id = issue_id_element[0].childNodes[0].nodeValue
> + Â Â Â milestone_element = i.getElementsByTagName('target_milestone')
> + Â Â Â milestone = milestone_element[0].childNodes[0].nodeValue
> + Â Â Â issue_dict[issue_id] = milestone
> + Â except:
> + Â Â print "ERROR: Unable to parse target milestones from issue tracker"
> + Â Â raise
> +
> + Â return issue_dict
>
> Â # Main func. Â This is the "entry point" that all the test scripts call
> Â # to run their list of tests.
> @@ -1586,6 +1668,23 @@ def execute_tests(test_list, serial_only
> Â Â testnums = list(range(1, len(test_list)))
>
> Â if options.list_tests:
> +
> + Â Â # If we want to list the target milestones, then get all the issues
> + Â Â # associated with all the individual tests.
> + Â Â milestones_dict = None
> + Â Â if options.milestone_filter:
> + Â Â Â issues_dict = {}
> + Â Â Â for testnum in testnums:
> + Â Â Â Â issues = TestRunner(test_list[testnum], testnum).get_issues()
> + Â Â Â Â test_mode = TestRunner(test_list[testnum], testnum).get_mode().upper()
> + Â Â Â Â if issues:
> + Â Â Â Â Â for issue in issues:
> + Â Â Â Â Â Â if (options.mode_filter.upper() == 'ALL' or
> + Â Â Â Â Â Â Â Â options.mode_filter.upper() == test_mode or
> + Â Â Â Â Â Â Â Â (options.mode_filter.upper() == 'PASS' and test_mode == '')):
> + Â Â Â Â Â Â Â issues_dict[issue]=issue
> + Â Â Â milestones_dict = get_target_milestones_for_issues(issues_dict.keys())
> +
>   header = "Test #  Mode  Test Description\n" \
> Â Â Â Â Â Â Â "------ Â ----- Â ----------------"
> Â Â printed_header = False
> @@ -1597,7 +1696,7 @@ def execute_tests(test_list, serial_only
> Â Â Â Â if not printed_header:
> Â Â Â Â Â print header
> Â Â Â Â Â printed_header = True
> - Â Â Â Â TestRunner(test_list[testnum], testnum).list()
> + Â Â Â Â TestRunner(test_list[testnum], testnum).list(milestones_dict)
> Â Â # We are simply listing the tests so always exit with success.
> Â Â return 0
>
>
> Modified: subversion/trunk/win-tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/win-tests.py?rev=1071809&r1=1071808&r2=1071809&view=diff
> ==============================================================================
> --- subversion/trunk/win-tests.py (original)
> +++ subversion/trunk/win-tests.py Thu Feb 17 22:09:02 2011
> @@ -79,6 +79,10 @@ 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(" Â --milestone-filter=RE Â : RE is a regular expression pattern that (when")
> + Â print(" Â Â Â Â Â Â Â Â Â Â Â Â Â used with --list) limits the tests listed to")
> + Â print(" Â Â Â Â Â Â Â Â Â Â Â Â Â those with an associated issue in the tracker")
> + Â print(" Â Â Â Â Â Â Â Â Â Â Â Â Â which has a target milestone that matches RE.")
> Â print(" Â --mode-filter=TYPE Â Â : limit tests to expected TYPE = XFAIL, SKIP, PASS,")
> Â print(" Â Â Â Â Â Â Â Â Â Â Â Â Â or 'ALL' (default)")
>  print("  --enable-sasl      : enable Cyrus SASL authentication for")
> @@ -123,7 +127,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', 'mode-filter='])
> + Â Â Â Â Â Â Â Â Â Â Â Â 'log-to-stdout', 'mode-filter=', 'milestone-filter='])
> Â if len(args) > 1:
> Â print('Warning: non-option arguments after the first one will be ignored')
>
> @@ -140,6 +144,7 @@ httpd_port = None
> Â httpd_service = None
> Â http_library = 'neon'
> Â list_tests = None
> +milestone_filter = None
> Â test_javahl = None
> Â enable_sasl = None
> Â svn_bin = None
> @@ -195,6 +200,8 @@ for opt, val in opts:
> Â Â test_javahl = 1
> Â elif opt == '--list':
> Â Â list_tests = 1
> + Â elif opt == '--milestone-filter':
> + Â Â milestone_filter = val
> Â elif opt == '--mode-filter':
> Â Â mode_filter = val
> Â elif opt == '--enable-sasl':
> @@ -688,7 +695,8 @@ if not test_javahl:
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â server_minor_version, not quiet,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cleanup, enable_sasl, parallel, config_file,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fsfs_sharding, fsfs_packing,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â list_tests, svn_bin, mode_filter)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â list_tests, svn_bin, mode_filter,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â milestone_filter)
> Â old_cwd = os.getcwd()
> Â try:
> Â Â os.chdir(abs_builddir)
>
>
>
Received on 2011-02-17 23:21:36 CET