Changeset 1a300b9 in git


Ignore:
Timestamp:
Sep 23, 2011, 9:56:00 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
617c42754f9beacefcc608d79a6205d4f5c48938
Parents:
1d50ea3cd9b2f2e4957a9f15c782e61d03d0cc2b
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-09-23 21:56:00+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 16:13:25+01:00
Message:
ADD: (optional!) test reporting for team city
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Tst/regress.cmd

    r1d50ea r1a300b9  
    1 #!/usr/bin/perl
     1#!/usr/bin/perl -CS
    22
    33#################################################################
     
    88# AUTHOR:  obachman@mathematik.uni-kl.de
    99
     10use Env;
     11 
    1012#################################################################
    1113#
     
    2931  [-t]              -- compute and call system("mtrack", 1) at the end, no diffs
    3032  [-A num]          -- set timeout [in sec.] for executed Singular
     33  [-C name]         -- be TeamCity friendly, use "name" as a test-suite name
    3134  [-tt max]         -- compute and call system("mtrack", max) at the end
    3235  [-T]              -- simply compute and determine timmings, no diffs
     
    129132chop $hostname;
    130133
     134# flag indicating whether to produce TeamCity output ("" - no):
     135$teamcity = "";
     136# current argument: test file name?
     137$test_file = "";
     138
     139
     140
     141
     142#################################################################
     143#
     144# teamcity helpers:
     145#
     146sub myGetTCprop
     147{
     148  local($prop) = $_[0];
     149  return( &mysystem_catch("cat \"\$TEAMCITY_BUILD_PROPERTIES_FILE\"|grep \"$prop=\"|sed \"s/$prop=//\"") );
     150}
     151
     152sub tc_filter
     153{
     154  local($t) = $_[0];
     155
     156  $t =~ s/\|/|\|/g;
     157 
     158  $t =~ s/\n/|n/g;
     159  $t =~ s/\r/|r/g;
     160
     161  $t =~ s/\u0085/|x/g;
     162  $t =~ s/\u2028/|l/g;
     163  $t =~ s/\u2029/|p/g;
     164
     165  ## \x{263A}
     166
     167  $t =~ s/\'/|\'/g;
     168  $t =~ s/\[/|\[/g;
     169  $t =~ s/\]/|\]/g;
     170  return ($t);
     171}
     172sub putTCmsg
     173{
     174  if( length($teamcity) > 0 )
     175  {
     176    local($message) = $_[0];
     177    local($text) = $_[1];
     178
     179    print( "\n##teamcity[$message $text]\n" );
     180  }
     181}
     182sub putTCmsgV
     183{
     184  local($message) = $_[0];
     185  local($unquotedValue) = tc_filter($_[1]);
     186   
     187  putTCmsg( $message, "\'$unquotedValue\'");
     188}
     189sub putTCmsgNV
     190{
     191  local($m) = $_[0];
     192  local($p) = $_[1];
     193  local($v) = tc_filter($_[2]);
     194  putTCmsg( $m, "$p=\'$v\'" );
     195}
     196sub putTCmsgNV2
     197{
     198  local($m) = $_[0];
     199  local($p) = $_[1];
     200  local($v) = tc_filter($_[2]);
     201  local($pp) = $_[3];
     202  local($vv) = tc_filter($_[4]);
     203  putTCmsg( $m, "$p='$v' $pp='$vv'" );
     204}
     205
     206#################################################################
     207#
     208# teamcity routines:
     209#
     210sub blockOpened
     211{
     212  local($v) = $_[0];
     213  putTCmsgNV( "blockOpened", "name", $v);
     214}
     215sub blockClosed
     216{
     217  local($v) = $_[0];
     218  putTCmsgNV( "blockClosed", "name", $v);
     219}
     220sub tcLog
     221{
     222  local($text) = $_[0];
     223  putTCmsgNV2( "message", "text", $text, "status", "NORMAL");
     224}
     225sub tcError
     226{
     227  local($n) = tc_filter($_[0]);
     228  local($m) = tc_filter($_[1]);
     229  local($t) = tc_filter($_[2]);
     230  # The status attribute may take following values:
     231  # NORMAL, WARNING, FAILURE, ERROR.
     232  # The default value is NORMAL.
     233  # The errorDetails attribute is used only if status is ERROR, in other cases it is ignored.
     234  # This message fails the build in case its status is ERROR and "Fail build if an error message is logged by build runner" checkbox is checked on build configuration general settings page.
     235 
     236  ##teamcity[message text='<message text>' errorDetails='<error details>' status='<status value>']
     237  putTCmsg( "message", "text=\'$n\' errorDetails=\'$m\' status=\'$t\'");
     238}
     239
     240sub testSuiteStarted
     241{
     242  local($v) = $_[0];
     243  putTCmsgNV( "testSuiteStarted", "name", $v);
     244}
     245sub testSuiteFinished
     246{
     247  local($v) = $_[0];
     248  putTCmsgNV( "testSuiteFinished", "name", $v);
     249}
     250sub testStarted
     251{
     252  local($v) = $_[0];       
     253  putTCmsgNV2( "testStarted", "name", $v, "captureStandardOutput", "true");
     254}
     255sub testFinished
     256{
     257  local($v) = $_[0];
     258  local($d) = $_[1];
     259  putTCmsgNV2( "testFinished", "name", $v, "duration", $d);
     260}
     261sub testFailed
     262{
     263  local($n) = $_[0];
     264  local($m) = $_[1];
     265  putTCmsgNV2( "testFailed", "name", $n, "message", $m);
     266}
     267sub testFailed2
     268{
     269  local($n) = tc_filter($_[0]);
     270  local($m) = tc_filter($_[1]);
     271  local($t) = tc_filter($_[2]);
     272  putTCmsg( "testFailed", "name=\'$n\' message=\'$m\' details=\'$t\'");
     273}
     274sub testFailedCMP
     275{
     276  local($n) = tc_filter($_[0]);
     277  local($m) = tc_filter($_[1]);
     278  local($d) = tc_filter($_[2]);
     279  local($e) = tc_filter($_[3]);
     280  local($a) = tc_filter($_[4]);
     281  putTCmsg( "testFailed", "type=\'comparisonFailure\' name=\'$n\' message=\'$m\' details=\'$d\' expected=\'$e\' actual=\'$a\'");
     282}
     283
     284##teamcity[testFailed type='comparisonFailure' name='test2' message='failure message' details='message and stack trace' expected='expected value' actual='actual value']
     285sub testIgnored
     286{
     287  local($n) = $_[0];
     288  local($m) = $_[1];
     289  putTCmsgNV2( "testIgnored", "name", $n, "message", $m);
     290}
     291
     292
     293
    131294#################################################################
    132295#
     
    147310  }
    148311  close(FD);
     312  &mysystem("if [ -e /proc/cpuinfo ]; then cat /proc/cpuinfo >> SingularVersionDate; fi ");
     313  &mysystem("sysctl -a  >> SingularVersionDate");
     314  &mysystem("uname -a >> SingularVersionDate");
     315  &mysystem("if [ -e /proc/meminfo ]; then cat /proc/meminfo >> SingularVersionDate; fi ");
     316  &mysystem("free -h >> SingularVersionDate");
    149317}
    150318
     
    308476      if (/(\d+) >> (\w+) :: /)
    309477      {
    310         s/$hostname:(\d+)/$this_time:$singular_date:$singular_version:$singular_uname:$hostname:$1/g;
    311         print RES_FILE $_;
     478        s/$hostname:(\d+)/$this_time:$singular_date:$singular_version:$singular_uname:$hostname:$1/g;
     479        print RES_FILE $_;
    312480      }
    313481    }
     
    374542  {
    375543    print (STDERR "Can not read $root.tst\n");
     544    testIgnored($test_file, "Can not read $root.tst");
    376545    return (1);
    377546  }
     
    381550  {
    382551    print "Warning: $root not tested: needs MP\n";
     552    testIgnored($test_file, "Warning: $root not tested: needs MP");
    383553    return (0);
    384554  }
     
    393563      {
    394564        print (STDERR "Can not decode $root.res.gz.uu\n");
     565        testIgnored($test_file, "Can not decode $root.res.gz.uu");
    395566        return ($exit_status);
    396567      }
     
    399570    {
    400571      print (STDERR "Can not read $root.res[.gz.uu]\n");
     572      testIgnored($test_file, "Can not read $root.res[.gz.uu]");
    401573      return (1);
    402574    }
    403575  }
    404576
     577  testStarted($test_file);
     578 
    405579  my $resfile = "\"$root.new.res\"";
    406580  $resfile = "\"$root.mtrack.res\"" if (defined($mtrack));
    407581  my $statfile = "$root.new.stat";
    408582  &mysystem("$rm -f \"$statfile\"");
     583 
    409584  if (defined($mtrack))
    410585  {
     
    434609  $cuser_t = $cuser_t2 - $cuser_t;
    435610  $csystem_t = $csystem_t2 - $csystem_t;
     611 
    436612  if ($exit_status != 0)
    437613  {
    438     $error_cause = "Singular call exited with status != 0";
     614    $error_cause = "Singular call exited with status != 0";   
    439615  }
    440616  else
     
    504680    }
    505681    print STDERR "!!! $root : $error_cause\n";
     682    testFailed($test_file, $error_cause);
    506683  }
    507684  else
     
    552729  $total_checks_pass++ unless $exit_status;
    553730
    554   mysystem("mv gmon.out \"gmon.$root.out\"")
    555     if (-e "gmon.out");
    556 
     731  mysystem("mv gmon.out \"gmon.$root.out\"") if (-e "gmon.out");
     732
     733  testFinished($test_file, $cuser_t + $csystem_t);
     734 
    557735  return ($exit_status);
    558736}
     
    595773  {
    596774    $timeout = shift;
     775  }
     776  elsif (/^-C$/)
     777  {
     778    $teamcity = shift;
    597779  }
    598780  elsif(/^-t$/)
     
    725907
    726908
     909if( length($teamcity) > 0 )
     910{
     911  #  tcLog("|Hi|\r I\'m [Alex]|\nHow are You?|");
     912
     913  blockOpened ("init");
     914 
     915  local($TEAMCITY_BUILD_PROPERTIES_FILE) = $ENV{TEAMCITY_BUILD_PROPERTIES_FILE};
     916 
     917  tcLog("TEAMCITY_BUILD_PROPERTIES_FILE: $TEAMCITY_BUILD_PROPERTIES_FILE");
     918 
     919  if ( length($TEAMCITY_BUILD_PROPERTIES_FILE) > 0 )
     920  {
     921    print( "teamcity.tests.runRiskGroupTestsFirst: " . myGetTCprop("teamcity.tests.runRiskGroupTestsFirst") . "\n" );
     922    print( "teamcity.tests.recentlyFailedTests.file: " . myGetTCprop("teamcity.tests.recentlyFailedTests.file") . "\n" );
     923    print( "teamcity.build.changedFiles.file: " . myGetTCprop("teamcity.build.changedFiles.file") . "\n" );
     924    print( "teamcity.build.properties.file: " . myGetTCprop("teamcity.build.properties.file") . "\n" );
     925    print( "teamcity.configuration.properties.file: " . myGetTCprop("teamcity.configuration.properties.file") . "\n" );
     926    print( "teamcity.runner.properties.file  : " . myGetTCprop("teamcity.runner.properties.file  ") . "\n" );
     927  }
     928  blockClosed ("init");
     929}
     930
    727931if ($timeout > 0)
    728932{
    729   $singular = "perl -e 'alarm $timeout; exec \@ARGV' $singular";
    730   print ("Set exec timeout to $timeout sec.\n") if ($verbosity > 1);
     933  $singular = "PERL_SIGNALS=unsafe perl -e 'alarm($timeout); exec(\@ARGV); ' $singular";
     934  tcLog ("Set exec timeout to $timeout sec.\n");
    731935  # die;
    732936}
     937
     938testSuiteStarted($teamcity);
     939
    733940# now do the work
    734941foreach (@ARGV)
    735942{
    736 
     943  $test_file = $_;
     944
     945  tcLog("test_file: $test_file");
     946 
    737947  if ( /^(.*)\.([^\.\/]*)$/ )
    738948  {
     
    753963    $base = $_;
    754964  }
     965
     966  tcLog("path: $path, base: $base, extension: $extension");
     967
    755968  $file = "$base.$extension";
    756969  chop ($tst_curr_dir = `pwd`);
     
    762975  elsif ($extension eq "lst")
    763976  {
    764    
    765977    if (! open(LST_FILE, "<$file"))
    766978    {
    767979      print (STDERR "Can not open $path/$file for reading\n");
    768980      $exit_code = 1;
     981      testIgnored($test_file, "Can not open $path/$file for reading");
    769982      next;
    770983    }
     984
     985    local ($b) = $test_file;
     986    blockOpened ($b);
     987   
    771988    $lst_used_time = 0;
    772989    $lst_checks = 0;
     
    781998      next if (/^\s*$/); #ignore whitespaced lines
    782999      chop if (/\n$/);   #chop of \n
    783 
    784       $_ = $1 if (/^(.*)\.([^\.\/]*)$/ ); # chop of extension
     1000 
     1001      tcLog("path: $path, test_file: $_, file: $file");
     1002     
     1003      if (length($path) > 0)
     1004      {
     1005        $test_file = "$path/$_";
     1006      }
     1007      else
     1008      {
     1009        $test_file = $_;
     1010      }
     1011                     
     1012     
     1013      $_ = $1 if (/^(.*)\.([^\.\/]*)$/ ); # chop of extension (.tst!!!?)
    7851014      if ( /^(.*)\/([^\/]*)$/ )
    7861015      {
     
    7981027      $tst_base =~ s/(.*?)\s+.*/$1/;
    7991028      $lst_checks++;
     1029
     1030      tcLog("tst_path: $tst_path, tst_base: $tst_base");
     1031
     1032     
    8001033      my $this_exit_code = &tst_check($tst_base);
     1034
    8011035      $lst_checks_pass++ unless $this_exit_code;
    8021036      $exit_code = $this_exit_code || $exit_code;
     
    8101044    close (LST_FILE);
    8111045    printf("$base Summary: Checks:$lst_checks Failed:%d Time:%.2f\n", $lst_checks - $lst_checks_pass, $lst_used_time)
    812       unless ($verbosity < 2)
     1046      unless ($verbosity < 2);
     1047    blockClosed ($b);
    8131048  }
    8141049  else
     
    8291064}
    8301065
     1066if( length($teamcity) > 0 )
     1067{
     1068  testSuiteFinished($teamcity);
     1069
     1070
     1071
    8311072# Und Tschuess
    8321073exit $exit_code;
Note: See TracChangeset for help on using the changeset viewer.