From 11470c63662bffe68b6b5fbfccdf5f34d208bcb6 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Sun, 2 Dec 2018 05:36:55 +0000 Subject: Import Upstream version 6.5 --- tests/compare.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'tests/compare.py') diff --git a/tests/compare.py b/tests/compare.py index cdbcc5d..7927467 100644 --- a/tests/compare.py +++ b/tests/compare.py @@ -1,7 +1,8 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- # # compare.py -- High-level tests for dtrx. -# Copyright (c) 2006, 2007, 2008 Brett Smith . +# Copyright © 2006-2009 Brett Smith . # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -54,8 +55,13 @@ class ExtractorTest(object): setattr(self, 'options', kwargs.get('options', '-n').split()) setattr(self, 'filenames', kwargs.get('filenames', '').split()) for key in ('directory', 'prerun', 'posttest', 'baseline', 'error', - 'grep', 'antigrep', 'input', 'output', 'cleanup'): + 'input', 'output', 'cleanup'): setattr(self, key, kwargs.get(key, None)) + for key in ('grep', 'antigrep'): + value = kwargs.get(key, []) + if isinstance(value, str): + value = [value] + setattr(self, key, value) def get_results(self, commands, stdin=None): print >>output_buffer, "Output from %s:" % (' '.join(commands),) @@ -165,12 +171,13 @@ class ExtractorTest(object): return None def grep_output(self, output): - if self.grep and (not re.search(self.grep.replace(' ', '\\s+'), - output, re.MULTILINE)): - return "output did not match %s" % (self.grep) - elif self.antigrep and re.search(self.antigrep.replace(' ', '\\s+'), - output, re.MULTILINE): - return "output matched antigrep %s" % (self.antigrep) + for pattern in self.grep: + if not re.search(pattern.replace(' ', '\\s+'), output, + re.MULTILINE): + return "output did not match %s" % (pattern) + for pattern in self.antigrep: + if re.search(pattern.replace(' ', '\\s+'), output, re.MULTILINE): + return "output matched antigrep %s" % (self.antigrep) return None def check_output(self, output): -- cgit v1.2.3