summaryrefslogtreecommitdiff
path: root/Lib/test/libregrtest/main.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-24 09:43:00 +0100
committerVictor Stinner <victor.stinner@gmail.com>2016-03-24 09:43:00 +0100
commitc160769c2af8a658c609cdd3c25b13697714aa56 (patch)
treeaa9d5f3ac7c5aaddca353eebd541a3d09c4732fd /Lib/test/libregrtest/main.py
parent7a22a8c0e4166ff97d95469b3d0070be88f36f6f (diff)
downloadcpython-c160769c2af8a658c609cdd3c25b13697714aa56.tar.gz
regrtest: fix --fromfile feature
* Update code for the name regrtest output format. * Enhance also test_regrtest test on --fromfile
Diffstat (limited to 'Lib/test/libregrtest/main.py')
-rw-r--r--Lib/test/libregrtest/main.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index b954db5c9d..de08f32d27 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -168,13 +168,21 @@ class Regrtest:
if self.ns.fromfile:
self.tests = []
+ # regex to match 'test_builtin' in line:
+ # '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec'
+ regex = (r'^(?:[0-9]+:[0-9]+:[0-9]+ *)?'
+ r'(?:\[[0-9/ ]+\] *)?'
+ r'(test_[a-zA-Z0-9_]+)')
+ regex = re.compile(regex)
with open(os.path.join(support.SAVEDCWD, self.ns.fromfile)) as fp:
- count_pat = re.compile(r'\[\s*\d+/\s*\d+\]')
for line in fp:
- line = count_pat.sub('', line)
- guts = line.split() # assuming no test has whitespace in its name
- if guts and not guts[0].startswith('#'):
- self.tests.extend(guts)
+ line = line.strip()
+ if line.startswith('#'):
+ continue
+ match = regex.match(line)
+ if match is None:
+ continue
+ self.tests.append(match.group(1))
removepy(self.tests)
@@ -194,7 +202,10 @@ class Regrtest:
else:
alltests = findtests(self.ns.testdir, stdtests, nottests)
- self.selected = self.tests or self.ns.args or alltests
+ if not self.ns.fromfile:
+ self.selected = self.tests or self.ns.args or alltests
+ else:
+ self.selected = self.tests
if self.ns.single:
self.selected = self.selected[:1]
try: