未验证 提交 79e199b3 编写于 作者: C Cleber Rosa 提交者: Lukáš Doktor

TAP support: add functional test to parse TAP with external library

One of the most important points of having TAP support is allowing
other tools to parse the results of the Avocado tests.  IMHO the best
way to test that we're producing sound TAP support is to use stable
implementations for that.

AFAIK, Perl is where TAP was born, and its TAP library is kind of a
reference implementation.  Let's use that, if available, to check if
our tap generation is sound.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 a0920f26
......@@ -14,11 +14,26 @@ else:
from avocado.core import exit_codes
from avocado.core.output import TermSupport
from avocado.utils import process
from avocado.utils import script
basedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')
basedir = os.path.abspath(basedir)
PERL_TAP_PARSER_SNIPPET = """#!/bin/env perl
use TAP::Parser;
my $parser = TAP::Parser->new( { exec => ['./scripts/avocado', 'run', 'passtest.py', 'errortest.py', 'warntest.py', '--tap', '-'] } );
while ( my $result = $parser->next ) {
$result->is_unknown && die "Unknown line \\"" . $result->as_string . "\\" in the TAP output!\n";
}
$parser->parse_errors == 0 || die "Parser errors!\n";
$parser->is_good_plan || die "Plan is not a good plan!\n";
$parser->plan eq '1..3' || die "Plan does not match what was expected!\n";
"""
def image_output_uncapable():
try:
import PIL
......@@ -27,6 +42,10 @@ def image_output_uncapable():
return True
def perl_tap_parser_uncapable():
return os.system("perl -e 'use TAP::Parser;'") != 0
class OutputTest(unittest.TestCase):
def setUp(self):
......@@ -371,6 +390,15 @@ class OutputPluginTest(unittest.TestCase):
except OSError:
pass
@unittest.skipIf(perl_tap_parser_uncapable(),
"Uncapable of using Perl TAP::Parser library")
def test_tap_parser(self):
perl_script = script.TemporaryScript("tap_parser.pl",
PERL_TAP_PARSER_SNIPPET)
perl_script.save()
os.chdir(basedir)
process.run("perl %s" % perl_script)
def tearDown(self):
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册