[Bps-public-commit] r10302 - in bpsbuilder/BPB/lib/BPB: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Jan 13 13:51:54 EST 2008


Author: sunnavy
Date: Sun Jan 13 13:51:54 2008
New Revision: 10302

Modified:
   bpsbuilder/BPB/lib/BPB/Backend.pm
   bpsbuilder/BPB/lib/BPB/Build.pm
   bpsbuilder/BPB/lib/BPB/Script/Build.pm

Log:
added only-test cli arg for build

Modified: bpsbuilder/BPB/lib/BPB/Backend.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Backend.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Backend.pm	Sun Jan 13 13:51:54 2008
@@ -68,7 +68,8 @@
 my $build_base = getcwd;
 
 my %args;
-GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s', 'skip-test' );
+GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s', 'skip-test',
+    'only-test' );
 
 unlink 'build.log' if -e 'build.log';
 open my $log, '>', 'build.log' or die $!;
@@ -95,27 +96,35 @@
     $ENV{PERL_MM_USE_DEFAULT} = 1;
 }
 
+if ( $args{'only-test'} ) {
+    test();
+}
+else {
+    mkdir $args{'install-base'} unless -e $args{'install-base'};
 
-mkdir $args{'install-base'} unless -e $args{'install-base'};
-
-mkdir File::Spec->catfile( $args{'install-base'},       'etc' )
-  unless -e File::Spec->catfile( $args{'install-base'}, 'etc' );
+    mkdir File::Spec->catfile( $args{'install-base'},       'etc' )
+      unless -e File::Spec->catfile( $args{'install-base'}, 'etc' );
 
-copy( File::Spec->catfile( 'etc', 'bpb-script-wrapper' ),
-    File::Spec->catfile( $args{'install-base'}, 'etc', 'bpb-script-wrapper' ) );
+    copy(
+        File::Spec->catfile( 'etc', 'bpb-script-wrapper' ),
+        File::Spec->catfile(
+            $args{'install-base'}, 'etc', 'bpb-script-wrapper'
+        )
+    );
 
-my $order = parse_order( File::Spec->catfile( 'bpb', 'order.yml' ) );
+    my $order = parse_order( File::Spec->catfile( 'bpb', 'order.yml' ) );
 
-for my $dist (@$order) {
-    unless ( grep { $dist eq $_ } @{ $args{skip} } ) {
-        install($dist);
+    for my $dist (@$order) {
+        unless ( grep { $dist eq $_ } @{ $args{skip} } ) {
+            install($dist);
+        }
+        chdir $build_base;
     }
-    chdir $build_base;
-}
 
-wrap_bin();
-print "install finished, the dists are at $args{'install-base'}\n";
-print $log "install finished, the dists are at $args{'install-base'}\n";
+    wrap_bin();
+    print "install finished, the dists are at $args{'install-base'}\n";
+    print $log "install finished, the dists are at $args{'install-base'}\n";
+}
 
 sub install {
     my $dir = shift;
@@ -237,6 +246,12 @@
     return $order;
 }
 
+sub test {
+    substitute(File::Spec->catfile( 't', 'test' ));
+    print "run tests: \n";
+    system( File::Spec->catfile( 't', 'test' ) );
+}
+
 EOF
   ;
 1;

Modified: bpsbuilder/BPB/lib/BPB/Build.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Build.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Build.pm	Sun Jan 13 13:51:54 2008
@@ -7,7 +7,9 @@
 use base qw/Class::Accessor::Fast/;
 
 __PACKAGE__->mk_accessors(
-    qw/install_base perl build_base skip_test commands log skip skip_test/);
+    qw/install_base perl build_base skip_test commands log
+      skip skip_test only_test/
+);
 
 use File::Spec;
 use File::Temp qw/tempdir/;
@@ -57,21 +59,28 @@
 
     chdir $self->build_base;
 
-    dircopy( 'etc', File::Spec->catfile( $self->install_base, 'etc' ) );
+    if ( $self->only_test ) {
+        $self->test;
+    }
+    else {
+        dircopy( 'etc', File::Spec->catfile( $self->install_base, 'etc' ) );
 
-    my $order =
-      BPB::Config::LoadFile( File::Spec->catfile( 'bpb', 'order.yml' ) );
+        my $order =
+          BPB::Config::LoadFile( File::Spec->catfile( 'bpb', 'order.yml' ) );
 
-    for my $dist (@$order) {
-        unless ( grep { $dist eq $_ } @{ $self->skip } ) {
-            $self->_install($dist);
+        for my $dist (@$order) {
+            unless ( grep { $dist eq $_ } @{ $self->skip } ) {
+                $self->_install($dist);
+            }
+            chdir $self->build_base;
         }
-        chdir $self->build_base;
-    }
 
-    $self->_wrapper();
+        $self->_wrapper();
+
+        $self->log->info(
+            "install finished. the dists are at " . $self->install_base );
+    }
 
-    $self->log->info( "install finished. the dists are at " . $self->install_base );
 }
 
 sub _install {
@@ -166,6 +175,15 @@
     write_file( $file, $text );
 }
 
+
+sub test {
+    my $self = shift;
+
+    $self->_substitute(File::Spec->catfile( 't', 'test' ));
+    $self->log->info( 'run tests:' );
+    BPB::Util->run( [ File::Spec->catfile( 't', 'test' ) ]);
+}
+
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Script/Build.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Script/Build.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Script/Build.pm	Sun Jan 13 13:51:54 2008
@@ -6,7 +6,7 @@
 
 use base qw/App::CLI::Command Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
-    qw/config name install_base build_base skip skip_test/);
+    qw/config name install_base build_base skip skip_test only_test/);
 
 use BPB;
 
@@ -17,6 +17,7 @@
         'i|install-base=s' => 'install_base',
         'skip=s'           => 'skip',
         'skip-test'        => 'skip_test',
+        'only-test'        => 'only_test',
     );
 }
 
@@ -36,7 +37,7 @@
     );
     $bpb->backend->export( target => $bpb->build->build_base );
     $bpb->build->skip_test(1) if $self->skip_test;
-    $bpb->build->run( map { $_ => $self->$_ } qw/install_base/ );
+    $bpb->build->run( map { $_ => $self->$_ } qw/install_base only_test/ );
 }
 
 1;



More information about the Bps-public-commit mailing list