Changeset 17103 for util

Show
Ignore:
Timestamp:
07/20/07 01:34:50 (16 months ago)
Author:
szbalint
Message:

Neatening run-smoke.pl up a bit.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/run-smoke.pl

    r16026 r17103  
    33use strict; 
    44use warnings; 
    5 use Shell qw(svn); 
    65use Config; 
    76use File::Spec; 
     
    98use lib File::Spec->catdir($FindBin::Bin, "..", "inc"); 
    109use PugsBuild::Config; 
     10 
     11# 
     12# run-smoke.pl /some/sandbox/dir /some/www/file.html 
     13# 
     14my $pugs_sandbox    = $ARGV[0] or die "Need pugs sandbox location"; 
     15my $html_location   = $ARGV[1] or die "Need HTML output file location"; 
     16my $optional_args   = $ARGV[2] || ""; 
     17 
     18 
     19sub check_prereq { 
     20    my ($mod) = @_; 
     21    (my $file = $mod) =~ s,::,/,g; 
     22    if (eval { require "$file.pm"; 1 }) { 
     23        return 1; 
     24    } 
     25    else { 
     26        warn "$mod - missing dependency\n"; 
     27        warn "($@)\n" if $@ and $@ !~ /Can't locate \Q$file\E/; 
     28        return 0; 
     29    } 
     30} 
    1131 
    1232my $failed = 0; 
     
    2444  cpan Task::Smoke 
    2545EOF 
    26 #' 
    2746 
    28 # 
    29 # run-smoke.pl /some/sandbox/dir /some/www/file.html 
    30 # 
    31 my $pugs_sandbox    = $ARGV[0] or die "Need pugs sandbox location"; 
    32 my $html_location   = $ARGV[1] or die "Need HTML output file location"; 
    33 my $optional_args   = $ARGV[2] || ""; 
    34  
    35 my $smoke_upload     = PugsBuild::Config->lookup('smoke_upload'); 
    36 my $smoke_upload_script = File::Spec->canonpath('./util/smokeserv/smokeserv-client.pl');  
    37  
    38 chdir($pugs_sandbox) or die "Could change directory: $!"; 
     47chdir($pugs_sandbox) or die "Could not change directory to '$pugs_sandbox': $!"; 
    3948 
    4049# '.' needs to be at the front of the path for everything to find the correct 
     
    4655 
    4756$ENV{HARNESS_PERL}  = "$ENV{HARNESS_PUGS} $optional_args"; 
    48 $ENV{HARNESS_PERL}  = "$^X $FindBin::Bin/../perl5/PIL2JS/pugs-smokejs.pl ./pugs $optional_args" 
    49     if $ENV{PUGS_RUNTIME} and $ENV{PUGS_RUNTIME} eq 'JS'; 
     57if ($ENV{PUGS_RUNTIME}) { 
     58  if ($ENV{PUGS_RUNTIME} eq 'JS') { 
    5059# XXX: hack to be identified by smokeserv 
    51 $ENV{HARNESS_PERL}  = "$^X -I/tmp/JSPERL5 $FindBin::Bin/../perl5/PIL2JS/pugs-smokejs.pl ./pugs $optional_args" 
    52     if $ENV{PUGS_RUNTIME} and $ENV{PUGS_RUNTIME} eq 'JSPERL5'; 
    53 if ($ENV{PUGS_RUNTIME} and $ENV{PUGS_RUNTIME} eq 'PERL5') { 
    54     $ENV{PERL5LIB} = 'blib6/pugs/perl5/lib:blib6/pugs/perl5/arch'; 
    55     $ENV{HARNESS_PERL} = $^X; 
    56 #    $ENV{HARNESS_PERL_SWITCHES} = "blib6/pugs/perl5/lib/v6.pm"; 
    57 } 
    58 if ($ENV{PUGS_RUNTIME} and $ENV{PUGS_RUNTIME} eq 'REDSIX') { 
    59     $ENV{HARNESS_PERL}  = "./pugs -Bredsix"; 
     60      $ENV{HARNESS_PERL}  = "$^X $FindBin::Bin/../perl5/PIL2JS/pugs-smokejs.pl ./pugs $optional_args" 
     61  } elsif ($ENV{PUGS_RUNTIME} eq 'JSPERL5') { 
     62      $ENV{HARNESS_PERL}  = "$^X -I/tmp/JSPERL5 $FindBin::Bin/../perl5/PIL2JS/pugs-smokejs.pl ./pugs $optional_args" 
     63  } elsif ($ENV{PUGS_RUNTIME} eq 'PERL5') { 
     64      $ENV{PERL5LIB} = 'blib6/pugs/perl5/lib:blib6/pugs/perl5/arch'; 
     65      $ENV{HARNESS_PERL} = $^X; 
     66     #$ENV{HARNESS_PERL_SWITCHES} = "blib6/pugs/perl5/lib/v6.pm"; 
     67  } elsif ($ENV{PUGS_RUNTIME} eq 'REDSIX') { 
     68      $ENV{HARNESS_PERL}  = "./pugs -Bredsix"; 
     69  } 
    6070} 
    6171 
    62  
    63 $ENV{PERL6LIB}      = join $Config{path_sep}, 
    64         qw<ext/Test/lib blib6/lib>, $ENV{PERL6LIB}||""; 
     72$ENV{PERL6LIB} = join $Config{path_sep}, qw<ext/Test/lib blib6/lib>, $ENV{PERL6LIB}||""; 
    6573 
    6674my @yaml_harness_args; 
     
    7179                   $ENV{PUGS_RUNTIME} eq 'PERL5' or $ENV{PUGS_RUNTIME} eq 'JSPERL5')); 
    7280 
    73 sub make { return `$Config{make} @_` }; 
    7481my $dev_null = File::Spec->devnull; 
    7582 
    76 my $output ;# = svn("up") or die "Could not update pugs tree: $!"; 
     83my $output; 
    7784my $yml_location = $html_location; 
    7885$yml_location =~ s/(\.html?(\+)?)?$/'.yml'.($2||'')/e; 
     86push @yaml_harness_args, ('--output-file', $yml_location); 
    7987 
    8088# Save backups of prior html and yaml 
     
    8997} 
    9098 
    91 push @yaml_harness_args, ('--output-file', $yml_location); 
    92 system($^X, qw(-w ./util/yaml_harness.pl), 
    93             @yaml_harness_args) == 0 or die "Could not run yaml harness: $!"; 
    94 system($^X, qw(-w ./util/testgraph.pl), ('--inlinecss', $yml_location), $html_location) == 0 or die "Could not convert .yml to testgraph: $!"; 
    95 upload_smoke($html_location, $yml_location); 
     99# Attempting the smoke 
     100system($^X, qw(-w ./util/yaml_harness.pl), @yaml_harness_args) == 0  
     101    or die "Could not run yaml harness: $!"; 
     102system($^X, qw(-w ./util/testgraph.pl), ('--inlinecss', $yml_location), $html_location) == 0 
     103    or die "Could not convert .yml to testgraph: $!"; 
     104 
     105if (defined $ENV{PUGS_SMOKE_UPLOAD}) { 
     106    system("$^X $ENV{PUGS_SMOKE_UPLOAD} $html_location $yml_location") == 0 
     107        or die "Couldn't run user smoke upload command: $!"; 
     108} 
     109my $smoke_upload = PugsBuild::Config->lookup('smoke_upload'); 
     110my $smoke_upload_script = File::Spec->canonpath('./util/smokeserv/smokeserv-client.pl');  
    96111if ($smoke_upload) { 
    97112  if (defined $smoke_upload_script) { 
    98     system($^X => $smoke_upload_script, $html_location, $yml_location) == 0 
    99         or die "Couln't run smoke upload script: $!"; 
     113    system($^X, $smoke_upload_script, $html_location, $yml_location) == 0 
     114        or die "Couldn't run smoke upload script: $!"; 
    100115  } 
    101116} else { 
     
    116131    } 
    117132} 
    118 sub upload_smoke { 
    119     my ($html, $yml) = @_; 
    120     return unless defined $ENV{PUGS_SMOKE_UPLOAD}; 
    121     system("$^X $ENV{PUGS_SMOKE_UPLOAD} $html $yml") == 0 or die "couldn't run user smoke upload command: $!"; 
    122 } 
    123  
    124 sub check_prereq { 
    125     my ($mod) = @_; 
    126     (my $file = $mod) =~ s,::,/,g; 
    127     if (eval { require "$file.pm"; 1 }) { 
    128         return 1; 
    129     } 
    130     else { 
    131         warn "$mod - missing dependency\n"; 
    132         warn "($@)\n" if $@ and $@ !~ /Can't locate \Q$file\E/; 
    133         return 0; 
    134     } 
    135 } 
    136 # END