Merge lp:~asc/fluidity/testharnessregex into lp:fluidity

Proposed by Adam Candy
Status: Work in progress
Proposed branch: lp:~asc/fluidity/testharnessregex
Merge into: lp:fluidity
Diff against target: 67 lines (+13/-9)
1 file modified
tools/testharness.py (+13/-9)
To merge this branch: bzr merge lp:~asc/fluidity/testharnessregex
Reviewer Review Type Date Requested Status
Fluidity Core Team Pending
Review via email: mp+73913@code.launchpad.net

Description of the change

New feature for the testharness - specify test cases to consider by a regex using the option -s.
For example, the following runs all tests beginning with 'iceshelf' or 'shallow':
  testharness.py -s '^(iceshelf|shallow).*\.xml

To post a comment you must log in.
lp:~asc/fluidity/testharnessregex updated
3571. By Adam Candy

Removal of ugly blank lines that had been allowed to creep in.

Revision history for this message
Patrick Farrell (pefarrell) wrote :

Is it possible to satisfy your use case with the test tag system instead?

Revision history for this message
Adam Candy (asc) wrote :

Ah yes, I did look at the tags feature but thought these were for more formal groupings such as 'parallel', 'zoltan' and 'flml', but I do now see there are some more informal groupings. I'll look at adding an iceshelf group. Thanks for the suggestion.

I think a pattern search on the test name is still a nice feature to include.

Revision history for this message
David Ham (david-ham) wrote :

I tend to disagree. Test names should be descriptive but they aren't
designed to categorise tests (which is what a pattern matching search
is effectively doing). Including this feature just encourages people
to misuse test names instead of using the proper tags.

On 5 September 2011 16:21, Adam Candy <email address hidden> wrote:
> Ah yes, I did look at the tags feature but thought these were for more formal groupings such as 'parallel', 'zoltan' and 'flml', but I do now see there are some more informal groupings.  I'll look at adding an iceshelf group.  Thanks for the suggestion.
>
> I think a pattern search on the test name is still a nice feature to include.
> --
> https://code.launchpad.net/~asc/fluidity/testharnessregex/+merge/73913
> Your team Fluidity Core Team is requested to review the proposed merge of lp:~asc/fluidity/testharnessregex into lp:fluidity.
>

--
Dr David Ham
Applied Modelling and Computation Group
Department of Earth Science and Engineering
Imperial College London

http://www.imperial.ac.uk/people/david.ham

Unmerged revisions

3571. By Adam Candy

Removal of ugly blank lines that had been allowed to creep in.

3570. By Adam Candy

New feature for the testharness - specify test cases to consider by a regex using the option -s.
For example, the following runs all tests beginning with 'iceshelf' or 'shallow':
  testharness.py -s '^(iceshelf|shallow).*\.xml

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/testharness.py'
2--- tools/testharness.py 2011-08-05 11:19:06 +0000
3+++ tools/testharness.py 2011-09-05 09:15:41 +0000
4@@ -4,6 +4,7 @@
5 import os
6 import os.path
7 import glob
8+import re
9 import time
10 import regressiontest
11 import traceback
12@@ -15,7 +16,7 @@
13 import elementtree.ElementTree as etree
14
15 class TestHarness:
16- def __init__(self, length="any", parallel=False, exclude_tags=None, tags=None, file="", verbose=True, justtest=False,
17+ def __init__(self, length="any", parallel=False, exclude_tags=None, tags=None, file="", search="", verbose=True, justtest=False,
18 valgrind=False):
19 self.tests = []
20 self.verbose = verbose
21@@ -38,6 +39,7 @@
22 print "parallel: ", parallel
23 print "tags to include: ", tags
24 print "tags to exclude: ", exclude_tags
25+ print "search: ", search
26 print "-" * 80
27 print
28
29@@ -84,13 +86,14 @@
30 prob_defn = p.findall("problem_definition")[0]
31 prob_length = prob_defn.attrib["length"]
32 prob_nprocs = int(prob_defn.attrib["nprocs"])
33- if prob_length == length or (length == "any" and prob_length not in ["special", "long"]):
34- if self.parallel is True:
35- if prob_nprocs > 1:
36- working_set.append(xml_file)
37- else:
38- if prob_nprocs == 1:
39- working_set.append(xml_file)
40+ if search is None or (search is not None and re.search(search, os.path.split(xml_file)[1]) is not None):
41+ if prob_length == length or (length == "any" and prob_length not in ["special", "long"]):
42+ if self.parallel is True:
43+ if prob_nprocs > 1:
44+ working_set.append(xml_file)
45+ else:
46+ if prob_nprocs == 1:
47+ working_set.append(xml_file)
48
49 def get_xml_file_tags(xml_file):
50 p = etree.parse(xml_file)
51@@ -325,6 +328,7 @@
52 parser.add_option("-e", "--exclude-tags", dest="exclude_tags", help="run only tests that do not have specific tags (takes precidence over -t)", default=[], action="append")
53 parser.add_option("-t", "--tags", dest="tags", help="run tests with specific tags", default=[], action="append")
54 parser.add_option("-f", "--file", dest="file", help="specific test case to run (by filename)", default="")
55+ parser.add_option("-s", "--search", dest="search", help="regex on test case filenames, e.g. -s '^(iceshelf|shallow).*\.xml'", default="")
56 parser.add_option("-n", "--threads", dest="thread_count", type="int",
57 help="number of tests to run at the same time", default=1)
58 parser.add_option("-v", "--valgrind", action="store_true", dest="valgrind")
59@@ -364,7 +368,7 @@
60 else:
61 tags = options.tags
62
63- testharness = TestHarness(length=options.length, parallel=para, exclude_tags=exclude_tags, tags=tags, file=options.file, verbose=True,
64+ testharness = TestHarness(length=options.length, parallel=para, exclude_tags=exclude_tags, tags=tags, file=options.file, search=options.search, verbose=True,
65 justtest=options.justtest, valgrind=options.valgrind)
66
67 if options.justlist: