#
# $HopeName: SWIGtests!Hqbuild.pm(swigtools_4_0.16) $
# $Id: Hqbuild.pm,v 1.2.1.16 2006/06/19 12:39:39 rday Exp $
#
package Tests::Hqbuild;
use strict;
use lib qw(autobuild autobuild/makedist/bt/perl5libs);
use Cwd;

use Hqbuild;
use File::Path;
use File::Temp ();
use Universalfile;
use Platform;
use Fileutil;
use Net::Domain;

use Test::Unit::TestSuite;

use base "Test::Unit::TestCase";

use Log::Log4perl qw(get_logger :levels);

my $homeuf  = UniversalFile->new(cwd);
my $logconf = $homeuf->append(qw/autobuild log.conf/)->convert;
Log::Log4perl->init($logconf);

sub new 
{
  my $self = shift()->SUPER::new(@_);
  return($self);
};

sub suite 
{
    my $class = shift;
    my $logger = get_logger("Tests::Hqbuild");
    my ($suite, $ALL);
    $ALL=1;
    if ($ALL) 
    {
      $suite = Test::Unit::TestSuite->new(__PACKAGE__);
    }
    else 
    {
      $suite = Test::Unit::TestSuite->empty_new();

      $suite->add_test(Tests::Hqbuild->new('test_CompoundWithChildDirTheSame'));

    }
    return $suite;
}

sub set_up
{
  my $self = shift;
  
  my $logger = get_logger("Tests::Hqbuild");
  #
  $logger->info();
  #
  # Set up the area where we will do all the testing
  #
  # this assumes we run in the directory *above autobuild
  my $homeuf  = UniversalFile->new(cwd);
  $self->{homeuf} = $homeuf;
  $logger->debug("homeuf: ".$self->{homeuf}->convert);
  my $tmpdir = $homeuf->append( qw( autobuild Tests tmp) );
  $self->{tmpdir} = $tmpdir;
  $logger->debug("tmpdir: ".$self->{tmpdir}->convert);
  my $return = mkpath( $tmpdir->convert  );
  $logger->debug("return from mkpath: ".$return);
  my $schedule = $tmpdir->append(qw(schedule.xml))->convert;
  $logger->debug($schedule);
  my $test_image_ext='';
  my $platform ='';
  if ($^O eq "MSWin32")
  {
    $schedule =~ tr/[A-Z]/[a-z]/ ;
    $test_image_ext = ".exe";
    $platform = "win_32-pentium";
  }
  else 
  {
    $schedule =~ s/\\/\//g;
  }
  $platform = "linux_2-pentium" if $^O eq "linux";
  $platform = "macos_x-ppc" if $^O eq "darwin";

  $self->{schedule} = $schedule;
  $self->{test_image} = "test".$test_image_ext;
  $self->{platform} = $platform;
  #
  # temporary HOPECACHE
  $ENV{HOPECACHE}= $tmpdir->append( qw/HOPECACHE/ )->convert;
  mkpath( $ENV{HOPECACHE} );

  #
  # set up the warehouse file system
  $self->{warehouse} = $tmpdir->append( qw(warehouse))->convert;
  mkpath($self->{warehouse});
  $self->{build} = $tmpdir->append( qw(build) )->convert;
  mkpath($self->{build});
  my $sentinel= $tmpdir->append( qw(warehouse iamwarehousedonotdelete))->convert;
  open(FILE, ">".$sentinel);
  print FILE "\n\n";
  close FILE;

  $self->{tmpfile} = new File::Temp( SUFFIX => '.dat' );

  #
  # set up the ISO date
  my $day=sprintf("%02d",(localtime())[3]);
  my $year= (localtime())[5]+1900;
  my $month=sprintf("%02d",(localtime())[4]+1);
  $self->{isodate}= $year.$month.$day;
  $self->{ymddate} = $year."/".$month."/".$day;
  $self->{hostname} = Net::Domain::hostname;
  $self->{autobuild} = Hqbuild->new();
}

sub tear_down
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $logger->info("remove_file_system");
  my $tmpdir = $self->{tmpdir}->convert;
  Fileutil::Erase('--force' => 1, '--ignore-missing' => 1, 'name' => $tmpdir, '--verbose' => 1);
}

sub test_SimpleBuild
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $self->make_schedule(name=>'SWIGtest_simple_build',
                       version=>'trunk',
                       recursive=>'1',
                       var=>'<VAR n="build" v="good"/>');
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  my $buildfile=$self->{tmpdir}->append(qw/build SWIG Tests SWIGtest_simple_build trunk/)->append($isodate)->append(qw/source simple_build distrib rel/)->append($self->{platform})->append($self->{test_image});  

  $self->assert(-e $buildfile->convert);
 
  my $whhead = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_simple_build trunk/)->append($self->{isodate});

  my $buildxml= $whhead->append(qw/build.xml/);
  $logger->debug("buildxml: ".$buildxml->convert);
  $self->assert(-e $buildxml->convert);
 
  my $partlistxml = $whhead->append(qw/partlist.xml/);
  $self->assert(-e $partlistxml->convert);

  my $productxml = $whhead->append(qw/product.xml/);

  $self->assert(-e $productxml->convert);
  
  my $logfile = $whhead->append($self->{hostname}.".txt");
  $self->assert( -e $logfile->convert);

  my $testexe = $whhead->append($self->{platform})->append('rel')->append($self->{test_image});
  $self->assert( -e $testexe->convert);
  
}

sub test_SimpleBuildFail
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $logger->info("start test");
  $self->make_schedule(name=>'SWIGtest_simple_build',
                       version=>'trunk',
                       recursive=>'1',
                       var=>'<VAR n="build" v="broken"/>');
  my $scheduleURI = "file:///".$self->{schedule};
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  $self->assert($errors=~ m/^Build failure: system error 256 executing /);
}
sub test_SimpleBuildDateCheckout
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  $hour = $hour + 5;
  my $cotime = "$hour:00:00";
  $self->make_schedule(name=>'SWIGtest_simple_build',
                       version=>'trunk',
                       recursive=>'1',
                       var=>'<VAR n="build" v="good"/>');
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1, 
                                                        time=>$cotime,
                                                        notrapout=>1);
  $year = $year+1900;
  $mon = sprintf( "%02d",$mon+1);
  $mday = sprintf("%02d",$mday);
  my $coisodate = $year.$mon.$mday.".".$hour."0000";
  $logger->debug("coisodate: ".$coisodate);
  my $buildfile=$self->{tmpdir}->append(qw/build SWIG Tests SWIGtest_simple_build trunk/)->append($coisodate)->append(qw/source simple_build distrib rel/)->append($self->{platform})->append($self->{test_image});  

  $self->assert(-e $buildfile->convert);
 
  my $whhead = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_simple_build trunk/)->append($coisodate);

  my $buildxml= $whhead->append(qw/build.xml/);
  $logger->debug("buildxml: ".$buildxml->convert);
  $self->assert(-e $buildxml->convert);
 
  my $partlistxml = $whhead->append(qw/partlist.xml/);
  $self->assert(-e $partlistxml->convert);

  my $productxml = $whhead->append(qw/product.xml/);

  $self->assert(-e $productxml->convert);
  
  my $logfile = $whhead->append($self->{hostname}.".txt");
  $self->assert( -e $logfile->convert);

  my $testexe = $whhead->append($self->{platform})->append(qw/rel/)->append($self->{test_image});
  $self->assert( -e $testexe->convert); 
}
sub test_SimpleBuildCollectOnly
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $self->make_schedule(name=>'SWIGtest_simple_build',
                       version=>'trunk',
                       recursive=>'1',
                       var=>'<VAR n="build" v="good"/>');
  my $scheduleURI = "file:///".$self->{schedule};
  $logger->debug("schedule ".$scheduleURI. " P4CACHE ".$ENV{P4CACHE});
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  my $buildfile=$self->{tmpdir}->append(qw/build SWIG Tests SWIGtest_simple_build trunk/)->append($isodate)->append(qw/source simple_build distrib rel/)->append($self->{platform})->append($self->{test_image});  
  
  my $whhead = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_simple_build trunk/)->append($self->{isodate});
  
  my $partlistxml = $whhead->append(qw/partlist.xml/)->convert;
  my ($plmod_1) = (stat($partlistxml))[8];

  my $productxml = $whhead->append(qw/product.xml/)->convert;
  my ($pdmod_1) = (stat($productxml))[8];

  my $logfile = $whhead->append($self->{hostname}.".txt")->convert;
  my ($logf_1) = (stat($logfile))[8];
  
  my $testexe = $whhead->append($self->{platform})->append('rel')->append($self->{test_image})->convert;
  my ($te_1) = (stat($testexe))[8];

  #
  # do a collect-only phase
  my($status_2,$errors_2) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                            nonotify=>1, 
                                                            collect=>1,
                                                            notrapout=>1);
 
  #
  # We use the access time because we don't actually modify the files in question
  my ($plmod_2) = (stat($partlistxml))[8];
  $self->assert( $plmod_2 >  $plmod_1);

  my ($pdmod_2) = (stat($productxml))[8];
  $self->assert( $pdmod_2 >  $pdmod_1);

  my ($logf_2) =  (stat($logfile))[8];
  $self->assert( $logf_2 > $logf_1);

  my ($te_2) = (stat($testexe))[8];
  $self->assert( $te_2 >  $te_1);
  
 }
sub test_PartlistXMLWithPerforce
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $self->make_schedule(name=>'SWIGtest_super',
                       version=>'trunk',
                       recursive=>'1'
                      );
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  #
  # check the warehouse
  my $whdir = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_perforce_product trunk/)->append($self->{isodate});
  my $partlist = $whdir->append(qw/partlist.xml/)->convert;
  $self->assert(-e $partlist);
  my $product = $whdir->append(qw/product.xml/)->convert;
  $self->assert(-e $product);
  my $logfile = $whdir->append($self->{hostname}.".txt")->convert;
  $self->assert(-e $logfile);
  my $distrib = $whdir->append($self->{platform})->append(qw/rel token/)->convert;
  $self->assert(-e $distrib);
}
sub test_ScheduleXMLWithPerforce
{
  my $self = shift;
  
  $self->make_schedule(name=>'SWIGtest_perforce_product',
                       version=>'trunk',
                       recursive=>'1',
                       url=>'url="p4:///depot/SWIG/SWIGtest_perforce_product/shelllink_1_3/"');
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  #
  # check the warehouse
  my $whdir = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_perforce_product trunk/)->append($self->{isodate});
  my $partlist = $whdir->append(qw/partlist.xml/)->convert;
  $self->assert(-e $partlist);
  my $product = $whdir->append(qw/product.xml/)->convert;
  $self->assert(-e $product);
  my $logfile = $whdir->append($self->{hostname}.".txt")->convert;
  $self->assert(-e $logfile);
  my $distrib = $whdir->append($self->{platform})->append(qw/rel token/)->convert;
  $self->assert(-e $distrib);
}
sub test_RecursiveCheckoutOfHopeCompoundWithNoChildren
{
  my $self = shift;
  $self->make_schedule(name=>'SWIGtest_super',
                       version=>'trunk',
                       recursive=>'1');
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  #
  # check the warehouse
  my $whdir = $self->{tmpdir}->append(qw/warehouse SWIG Tests SWIGtest_super trunk/)->append($self->{isodate});
  my $partlist = $whdir->append(qw/partlist.xml/)->convert;
  $self->assert(-e $partlist);
  my $product = $whdir->append(qw/product.xml/)->convert;
  $self->assert(-e $product);
  my $logfile = $whdir->append($self->{hostname}.".txt")->convert;
  $self->assert(-e $logfile);
}
sub test_UnsafeProductXML 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");

  $self->make_schedule(name=>'SWIGtest_unsafe_productxml',
                       version=>'trunk', 
                       recursive=>'1');
  my $scheduleURI = "file:///".$self->{schedule};
  $logger->debug("schedule ".$scheduleURI);
  my($status,$errortxt) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                          nonotify=>1,
                                                          notrapout=>1);
  chop($errortxt);
  my $product = $self->{tmpdir}->append(qw/build SWIG Tests SWIGtest_unsafe_productxml trunk/)->append($self->{isodate})->append(qw/source product.xml/);
  my $msg = "unable to parse ".$product->convert." for ".$self->{ymddate}." 00:00:00 GMT for SWIGtest_unsafe_productxml (trunk)   file://isambard.cam/build/warehouse/SWIG/Tests/SWIGtest_unsafe_productxml/trunk/".$self->{isodate}."/".$self->{hostname}.".txt";
  $logger->debug("errors from call: ".$errortxt." length ".length($errortxt));
  $logger->debug("errors to test  : ".$msg." length ".length($msg));
  $self->assert($errortxt eq $msg);
}
sub test_UnsafePartlistXML 
{
  my $self = shift; 
  my $logger = get_logger("Tests::Hqbuild");
  my $test_name = "unsafe partlist xml";

  my $compound = 'SWIGtest_unsafe_partlistxml';
  $self->make_schedule(name=>'SWIGtest_unsafe_partlistxml',
                       version=>'trunk',
                       recursive=>0);
  my $scheduleURI = "file:///".$self->{schedule};
  $logger->debug("schedule ".$scheduleURI);
  my($status,$errortxt) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                          nonotify=>1,
                                                          notrapout=>1);
  chop $errortxt;
  my $partlist = $self->{tmpdir}->append(qw/build SWIG Tests SWIGtest_unsafe_partlistxml trunk/)->append($self->{isodate})->append(qw/source partlist.xml/);
  my $msg = "unable to parse ".$partlist->convert." for ".$self->{ymddate}." 00:00:00 GMT for $compound (trunk)   file://isambard.cam/build/warehouse/SWIG/Tests/".$compound."/trunk/".$self->{isodate}."/".$self->{hostname}.".txt";
  $logger->debug("to test : ".$errortxt);
  $logger->debug("measure : ".$msg);

  $self->assert($errortxt eq $msg);
}
sub test_NoCategory 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");

  $self->make_schedule(name=>'SWIGtest_no_category',
                       version=>'trunk', 
                       recursive=>'0');
  my $scheduleURI = "file:///".$self->{schedule};
  $logger->debug("schedule ".$scheduleURI);
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  chop $errors;
  $logger->debug("errors: ".$errors." ".length($errors));
  my $msg ="no category defined for SWIGtest_no_category (trunk)   file://isambard.cam/build/warehouse//SWIGtest_no_category/trunk/".$self->{isodate}."/".$self->{hostname}.".txt";
  $logger->debug($msg."    ".length($msg));

  $self->assert($errors eq $msg);
};

sub test_MalScheduleURI 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my $test_name = "malformed schedule URI";

  my $scheduleFile = 'xxxxxxxxxxxxxxxxxxx';
  my $scheduleURI = "file:///".$scheduleFile;
  $logger->debug("schedule ".$scheduleURI);
  my($status,$error) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                       nonotify=>1,
                                                       notrapout=>1);
  my $schedule_fp = $self->{homeuf}->append(qw(autobuild-data schedules),$scheduleFile);
  $logger->debug("error f: ".$error); 

  my $test_err = "Schedule file ".$schedule_fp->convert." does not exist";
  $logger->debug("error t: ".$test_err);
  $self->assert($error eq $test_err);
}
sub test_MalScheduleURIWithErrorFile 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my $test_name = "malformed schedule URI, error in error file";

  my $scheduleFile = 'xxxxxxxxxxxxxxxxxxx';
  my $scheduleURI = "file:///".$scheduleFile;
  $logger->debug("schedule ".$scheduleURI);
  my $tmpfile = $self->{tmpfile}->filename;
  my($status,$error) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                       nonotify=>1, 
                                                       errorfile=>$tmpfile,
                                                       notrapout=>1);
  my $errortxt = $self->read_errorfile();
  my $schedule_fp = $self->{homeuf}->append(qw(autobuild-data schedules),$scheduleFile);
  my $test_err = "Schedule file ".$schedule_fp->convert." does not exist";
  $logger->debug("error t: ".$test_err);

  $self->assert($errortxt eq $test_err);
}

sub test_MalScheduleXML 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my $test_name = "malformed Schedule XML";

  $self->make_broken_schedule();
  my $scheduleURI = "file:///".$self->{schedule};
  my($status,$error) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                       nonotify=>1,
                                                       notrapout=>1);
  $logger->debug("error: ".$error);
  my $isodate = $self->{isodate};
  my $hostname = $self->{hostname};
  my $schedule = "file:///".$self->{schedule};
  my $msg = "Could not read schedule $schedule on $hostname. Possibly invalid XML.";
  $logger->debug("msg: ".$msg);

  $self->assert( $error eq $msg );
}
sub test_MalScheduleXMLWithErrorFile 
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my $test_name = "malformed Schedule XML, error in errorfile";

  $self->make_broken_schedule();
  my $scheduleURI = "file:///".$self->{schedule};
  my $tmpfile = $self->{tmpfile}->filename;
  my($status,$error) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                       nonotify=>1, 
                                                       errorfile=>$tmpfile,
                                                       notrapout=>1);
  $logger->debug("error: ".$error);
  my $errortxt = $self->read_errorfile();
  my $isodate = $self->{isodate};
  my $hostname = $self->{hostname};
  my $schedule = "file:///".$self->{schedule};
  my $msg = "Could not read schedule $schedule on $hostname. Possibly invalid XML.";
  $logger->debug("msg: ".$msg);

  $self->assert( $errortxt eq $msg );
}

#
#
# This tests a recursive build where the childcompound has the same codir as the parent
sub test_CompoundWithChildDirTheSame
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $self->make_schedule(name=>'DPPprod_shelllink',
                       version=>'shelllink_1_4_br',
                       recursive=>'1'
                       );
  my $scheduleURI = "file:///".$self->{schedule};
  
  my($status,$errors) = $self->{autobuild}->hqautobuild(schedule=>$scheduleURI,
                                                        nonotify=>1,
                                                        notrapout=>1);
  my $isodate = $self->{isodate};
  my $image = "shelllink";
  $image .= ".exe" if ($^O eq "MSWin32");
  my $buildfile=$self->{tmpdir}->append(qw/build Utilities DPPprod_shelllink shelllink_1_4_br/)->append($isodate)->append(qw/source shelllink distrib/)->append($self->{platform})->append('rel')->append($image);  

  $self->assert(-e $buildfile->convert);
 
  my $whhead = $self->{tmpdir}->append(qw/warehouse Utilities DPPprod_shelllink shelllink_1_4_br/)->append($self->{isodate});

  my $buildxml= $whhead->append(qw/build.xml/);
  $logger->debug("buildxml: ".$buildxml->convert);
  $self->assert(-e $buildxml->convert);
 
  my $partlistxml = $whhead->append(qw/partlist.xml/);
  $self->assert(-e $partlistxml->convert);

  my $productxml = $whhead->append(qw/product.xml/);

  $self->assert(-e $productxml->convert);
  
  my $logfile = $whhead->append($self->{hostname}.".txt");
  $self->assert( -e $logfile->convert);

  my $testexe = $whhead->append($self->{platform})->append('rel')->append($image);
  $self->assert( -e $testexe->convert);
}

sub make_schedule
{
  my $self = shift;
  my (%args) = @_;
  my $name = $args{name};
  my $version = $args{version};
  my $recursive = '0';
  $recursive = $args{recursive} if (exists $args{recursive});
  my $var = '';
  $var = $args{var} if exists $args{var};
  my $url = '';
  $url = $args{url} if exists $args{url};

  my $logger = get_logger("Tests::Hqbuild");
  $logger->debug("name: ".$name." version ".$version);
  open(SCHEDULE, ">".$self->{schedule});
  my $warehouse = $self->{warehouse};
  my $builddir = $self->{build};
  print SCHEDULE <<EOF;
<?xml version="1.0"?>
<!DOCTYPE SCHEDULE SYSTEM "http://isambard.cam.harlequin.co.uk/warehouse-DTDs/autobuild-02.dtd" [
]>
<SCHEDULE tag="warehouse" warehouse="$warehouse" notify="local" dir="$builddir">
  <JOB>  
     <Compound name="$name" branch="$version" $url recurse="$recursive">
        <MATCH>
          $var
        </MATCH>
     </Compound>
  </JOB>
 </SCHEDULE>
EOF
  close SCHEDULE;
};
sub make_broken_schedule
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  $logger->info("make_broken_schedule");
  open(SCHEDULE, ">".$self->{schedule});
  print SCHEDULE <<EOF;
<?xml version="1.0"?>
<!DOCTYPE BuildSystem SYSTEM "http://isambard.cam.harlequin.co.uk/warehouse-DTDs/autobuild.dtd" [
]>
<BuildSystem>
  <Configuration>
  
 </SCHEDULE>
</BuildSystem>
EOF
  close SCHEDULE;
}
sub read_errorfile
{
  my $self = shift;
  my $logger = get_logger("Tests::Hqbuild");
  my $errortxt="";
  if (-e $self->{tmpfile}->filename ) 
  {
    my $tmpfh = $self->{tmpfile};
    while (<$tmpfh>) 
    {
      chop;
      chop if $^O eq "MSWin32";
      if ($_ ne "")
      {
        $errortxt = $_;
        last;
      }
    }
    $logger->debug("errortxt: ".$errortxt." length: ".length($errortxt));
    return $errortxt;
  }
  else 
  {
    $logger->fatal("no error file " . $self->{tmpfile} . " exists");
  }
  
}



1;

#
# $Log: Hqbuild.pm,v $
# Revision 1.2.1.16  2006/06/19  12:39:39  rday
# [Bug #28746]
# add shelllink test
#
# Revision 1.2.1.15  2006/06/14  16:12:06  rday
# [Bug #28746]
# tell hqbuild not to trap stdout
#
# Revision 1.2.1.14  2006/06/13  14:00:42  rday
# [Bug #28746]
# change swig to SWIG in p4 URI
#
# Revision 1.2.1.13  2006/06/12  14:54:16  rday
# [Bug #28746]
# get rid of windows reference
#
# Revision 1.2.1.12  2006/06/12  14:53:19  rday
# [Bug #28746]
# correct typo
#
# Revision 1.2.1.11  2006/06/12  14:43:50  rday
# [Bug #28746]
# windows -> MSWin32
#
# Revision 1.2.1.10  2006/06/12  11:05:21  rday
# [Bug #28746]
# platform specific reading error file
#
# Revision 1.2.1.9  2006/06/12  10:41:49  rday
# [Bug #28746]
# get rid of COMPUTERNAME
#
# Revision 1.2.1.8  2006/06/12  10:29:57  rday
# [Bug #28746]
# more typo
#
# Revision 1.2.1.7  2006/06/12  10:28:58  rday
# [Bug #28746]
# more typo
#
# Revision 1.2.1.6  2006/06/12  10:27:57  rday
# [Bug #28746]
# more typo
#
# Revision 1.2.1.5  2006/06/12  10:22:36  rday
# [Bug #28746]
# more platform-specific stuff
#
# Revision 1.2.1.4  2006/06/12  09:52:32  rday
# [Bug #28746]
# remove platform-specific issues
#
# Revision 1.2.1.3  2006/06/09  09:44:01  rday
# [Bug #28746]
# make sure log init is platform specific
#
# Revision 1.2.1.2  2006/06/07  16:54:00  rday
# [Bug #28746]
# put the swig into it's right place
#
# Revision 1.2.1.1  2006/06/02  14:28:10  rday
# branched from trunk for label swigtools_4_0
#
# Revision 1.2  2006/05/31  17:43:47  rday
# [Bug #28746]
# add erase
#
# Revision 1.1  2006/05/31  16:48:43  rday
# new unit
# [Bug #28746]
# new units for testing
#
# Revision 1.1  2006/05/31  16:24:40  rday
# new unit
# New Test Suite
#
# Revision 1.3  2006/02/09  10:27:30  rday
# [Bug #27886]
# have a distinct logger for tests
#
# Revision 1.2  2005/11/08  15:26:46  rday
# [Bug #29708]
# change s/[A-Z]/[a-z]/ to tr/[A-Z]/[a-z]/
#
# Revision 1.1  2005/11/04  15:13:03  rday
# [Bug #29708]
# new unit
# [Bug #29708]
# add tests
#
#
