From ea2fa683020eeb7c7882ab539ea287e80784920e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 8 Jul 2015 10:37:43 +1000 Subject: [PATCH 1/7] tools: expose skip output to test runner In the TAP protocol, skips are flagged as ok. Expose more information so we can understand if the test was skipped or not. --- tools/test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/test.py b/tools/test.py index 4d6337037aa7f2..c05dc246e86396 100755 --- a/tools/test.py +++ b/tools/test.py @@ -255,6 +255,9 @@ def HasRun(self, output): logger.info('#' + l) for l in output.output.stdout.splitlines(): logger.info('#' + l) + elif output.HasSkipped(): + logger.info('ok %i - %s # skip %s' % (self._done, command, + output.output.stdout.replace('1..0 # Skipped:', '').strip())) else: logger.info('ok %i - %s' % (self._done, command)) @@ -471,6 +474,10 @@ def UnexpectedOutput(self): outcome = PASS return not outcome in self.test.outcomes + def HasSkipped(self): + s = '1..0 # Skipped:' + return self.store_unexpected_output and self.output.stdout.startswith(s) + def HasPreciousOutput(self): return self.UnexpectedOutput() and self.store_unexpected_output From b673537576d729f03cf9ce514ae2d8e996bcdbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 8 Jul 2015 17:00:23 +1000 Subject: [PATCH 2/7] fix: use regex instead of string matching --- tools/test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/test.py b/tools/test.py index c05dc246e86396..9abc575247feb8 100755 --- a/tools/test.py +++ b/tools/test.py @@ -27,7 +27,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - import imp import logging import optparse @@ -256,8 +255,9 @@ def HasRun(self, output): for l in output.output.stdout.splitlines(): logger.info('#' + l) elif output.HasSkipped(): - logger.info('ok %i - %s # skip %s' % (self._done, command, - output.output.stdout.replace('1..0 # Skipped:', '').strip())) + skip = re.findall('# SKIP\S+ (.+)', output.output.stdout.strip(), + re.IGNORECASE) + logger.info('ok %i - %s # skip %s' % (self._done, command, skip[0])) else: logger.info('ok %i - %s' % (self._done, command)) @@ -475,8 +475,9 @@ def UnexpectedOutput(self): return not outcome in self.test.outcomes def HasSkipped(self): - s = '1..0 # Skipped:' - return self.store_unexpected_output and self.output.stdout.startswith(s) + skip = re.search('# SKIP\S+ (.+)', self.output.stdout.strip(), + re.IGNORECASE) + return self.store_unexpected_output and skip def HasPreciousOutput(self): return self.UnexpectedOutput() and self.store_unexpected_output From de4e4d08214a8f893e646b32f14a6d922dccea3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 8 Jul 2015 17:02:32 +1000 Subject: [PATCH 3/7] fix: avoid calling strip `re` only matches on the first line unless told to do multiline. --- tools/test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/test.py b/tools/test.py index 9abc575247feb8..e0f1e003f4c245 100755 --- a/tools/test.py +++ b/tools/test.py @@ -27,6 +27,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + import imp import logging import optparse @@ -255,7 +256,7 @@ def HasRun(self, output): for l in output.output.stdout.splitlines(): logger.info('#' + l) elif output.HasSkipped(): - skip = re.findall('# SKIP\S+ (.+)', output.output.stdout.strip(), + skip = re.findall('# SKIP\S+ (.+)', output.output.stdout, re.IGNORECASE) logger.info('ok %i - %s # skip %s' % (self._done, command, skip[0])) else: @@ -475,7 +476,7 @@ def UnexpectedOutput(self): return not outcome in self.test.outcomes def HasSkipped(self): - skip = re.search('# SKIP\S+ (.+)', self.output.stdout.strip(), + skip = re.search('# SKIP\S+ (.+)', self.output.stdout, re.IGNORECASE) return self.store_unexpected_output and skip From 3014572ee51f5a88171ac41c98c0121d94ab501f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 8 Jul 2015 17:41:54 +1000 Subject: [PATCH 4/7] fix: use raw text and compile regex --- tools/test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/test.py b/tools/test.py index e0f1e003f4c245..71b3762faa187a 100755 --- a/tools/test.py +++ b/tools/test.py @@ -49,6 +49,7 @@ from Queue import Queue, Empty logger = logging.getLogger('testrunner') +is_skipped = re.compile(r"# SKIP\S+ (.+)", re.IGNORECASE) VERBOSE = False @@ -256,8 +257,7 @@ def HasRun(self, output): for l in output.output.stdout.splitlines(): logger.info('#' + l) elif output.HasSkipped(): - skip = re.findall('# SKIP\S+ (.+)', output.output.stdout, - re.IGNORECASE) + skip = is_skipped.findall(output.output.stdout) logger.info('ok %i - %s # skip %s' % (self._done, command, skip[0])) else: logger.info('ok %i - %s' % (self._done, command)) @@ -476,8 +476,7 @@ def UnexpectedOutput(self): return not outcome in self.test.outcomes def HasSkipped(self): - skip = re.search('# SKIP\S+ (.+)', self.output.stdout, - re.IGNORECASE) + skip = is_skipped.search(self.output.stdout) return self.store_unexpected_output and skip def HasPreciousOutput(self): From 4d6b0b53fcf7056ef56f7ff8e1f8a3aea1e94fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Thu, 9 Jul 2015 08:45:26 +1000 Subject: [PATCH 5/7] fix: use 'official' regex and rename var --- tools/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/test.py b/tools/test.py index 71b3762faa187a..75497817861877 100755 --- a/tools/test.py +++ b/tools/test.py @@ -49,7 +49,7 @@ from Queue import Queue, Empty logger = logging.getLogger('testrunner') -is_skipped = re.compile(r"# SKIP\S+ (.+)", re.IGNORECASE) +skip_regex = re.compile(r'# SKIP\S*\s+(.*)', re.IGNORECASE) VERBOSE = False @@ -257,7 +257,7 @@ def HasRun(self, output): for l in output.output.stdout.splitlines(): logger.info('#' + l) elif output.HasSkipped(): - skip = is_skipped.findall(output.output.stdout) + skip = skip_regex.findall(output.output.stdout) logger.info('ok %i - %s # skip %s' % (self._done, command, skip[0])) else: logger.info('ok %i - %s' % (self._done, command)) @@ -476,7 +476,7 @@ def UnexpectedOutput(self): return not outcome in self.test.outcomes def HasSkipped(self): - skip = is_skipped.search(self.output.stdout) + skip = skip_regex.search(self.output.stdout) return self.store_unexpected_output and skip def HasPreciousOutput(self): From 9cd5da66819d4a429632badb50f369c4f86f9947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Thu, 9 Jul 2015 08:47:07 +1000 Subject: [PATCH 6/7] fix: switch to re.search --- tools/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test.py b/tools/test.py index 75497817861877..7020d1d1aa584c 100755 --- a/tools/test.py +++ b/tools/test.py @@ -257,8 +257,8 @@ def HasRun(self, output): for l in output.output.stdout.splitlines(): logger.info('#' + l) elif output.HasSkipped(): - skip = skip_regex.findall(output.output.stdout) - logger.info('ok %i - %s # skip %s' % (self._done, command, skip[0])) + skip = skip_regex.search(output.output.stdout).group(1) + logger.info('ok %i - %s # skip %s' % (self._done, command, skip)) else: logger.info('ok %i - %s' % (self._done, command)) From 3749544b0ae1df7a64c8b74f3265ace945d705f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Mon, 13 Jul 2015 10:45:04 +1000 Subject: [PATCH 7/7] fix: simplify logic by avoiding classes --- tools/test.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/test.py b/tools/test.py index 7020d1d1aa584c..6b0a4d693fe4fd 100755 --- a/tools/test.py +++ b/tools/test.py @@ -256,11 +256,13 @@ def HasRun(self, output): logger.info('#' + l) for l in output.output.stdout.splitlines(): logger.info('#' + l) - elif output.HasSkipped(): - skip = skip_regex.search(output.output.stdout).group(1) - logger.info('ok %i - %s # skip %s' % (self._done, command, skip)) else: - logger.info('ok %i - %s' % (self._done, command)) + skip = skip_regex.search(output.output.stdout) + if skip: + logger.info('ok %i - %s # skip %s' % + (self._done, command, skip.group(1))) + else: + logger.info('ok %i - %s' % (self._done, command)) duration = output.test.duration @@ -475,10 +477,6 @@ def UnexpectedOutput(self): outcome = PASS return not outcome in self.test.outcomes - def HasSkipped(self): - skip = skip_regex.search(self.output.stdout) - return self.store_unexpected_output and skip - def HasPreciousOutput(self): return self.UnexpectedOutput() and self.store_unexpected_output