Created
August 19, 2013 10:01
-
-
Save zarezadeh/6267606 to your computer and use it in GitHub Desktop.
a perl script to convert cunit output to teamcity service messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
$suite_re = qr/Suite:\s(\w+)/; | |
$test_re = qr/\s*Test:\s(.+)\s\.\.\.\s(\w+)/; | |
$endTest_re = qr/--Run\sSummary/; | |
my $current_suite = ""; | |
my $current_test = ""; | |
@userinput = <STDIN>; | |
foreach (@userinput) { | |
if (/$suite_re/) { | |
if(!$current_suite eq "") { | |
print "##teamcity[testSuiteFinished name='$current_suite']\n"; | |
print; | |
} | |
$current_suite = $1; | |
print "##teamcity[testSuiteStarted name='$current_suite']\n"; | |
print; | |
} | |
elsif (/$endTest_re/) { | |
if ($current_test ne "") { | |
print "##teamcity[testFinished name='$current_test']\n"; | |
} | |
if (!$current_suite eq "") { | |
print "##teamcity[testSuiteFinished name='$current_suite']\n"; | |
print; | |
} | |
} | |
elsif (/$test_re/) { | |
if ($current_test ne "") { | |
print "##teamcity[testFinished name='$current_test']\n"; | |
} | |
$current_test = $1; | |
print "##teamcity[testStarted name='$current_test' captureStandardOutput='true' ]\n"; | |
print; | |
if ( !($2 eq "passed")) { | |
print "##teamcity[testFailed name='$current_test' message='$2']\n"; | |
} | |
} | |
else { | |
print; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment