Skip to content

Instantly share code, notes, and snippets.

@zarezadeh
Created August 19, 2013 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zarezadeh/6267606 to your computer and use it in GitHub Desktop.
Save zarezadeh/6267606 to your computer and use it in GitHub Desktop.
a perl script to convert cunit output to teamcity service messages
#!/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