[Bps-public-commit] r10300 - bpsbuilder/BPB/lib/BPB/Backend

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Jan 13 13:32:49 EST 2008


Author: sunnavy
Date: Sun Jan 13 13:32:47 2008
New Revision: 10300

Modified:
   bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
   bpsbuilder/BPB/lib/BPB/Backend/SVN.pm

Log:
added extra-tests and extra test-script support

Modified: bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Backend/SVK.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Backend/SVK.pm	Sun Jan 13 13:32:47 2008
@@ -7,6 +7,7 @@
 use CPAN::DistnameInfo;
 use BPB::Config;
 use File::Temp qw/tempdir/;
+use File::Copy;
 
 # our project's own files will be in //local/test/main
 # all the dependance packages will be in //local/test/deps
@@ -31,7 +32,7 @@
 sub initialize {
     my $self = shift;
     my $dir = tempdir( CLEANUP => 1 );
-    for (qw/bpb dists etc bin scripts/) {
+    for (qw/bpb dists etc bin scripts t/) {
         mkdir File::Spec->catfile( $dir, $_ );
     }
     open my $order, '>', File::Spec->catfile( $dir, 'bpb', 'order.yml' );
@@ -46,6 +47,9 @@
     print $builder $BPB::Backend::BUILDER;
     close $builder;
 
+    open my $t, '>', File::Spec->catfile( $dir, 't', 'test' );
+    close $t;
+
     $self->delete;    # clean repository in case it exists
     $self->log->info( 'initialize ' . $self->repository );
     $self->import(
@@ -53,7 +57,7 @@
         _initialize => 1,
         comment     => 'created project',
     );
-    for ( 'bin/bpb-builder', 'etc/bpb-script-wrapper' ) {
+    for ( 'bin/bpb-builder', 'etc/bpb-script-wrapper', 't/test' ) {
         $self->propset(
             path  => $_,
             type  => 'svn:executable',
@@ -74,7 +78,7 @@
     $name =~ s{^.*/(.+)/?$}{$1.tar.gz};
     $name = CPAN::DistnameInfo->new($name)->dist;
 
-    unless ( $args{_initialize} ) {
+    unless ( $args{_initialize} || $args{_extra_tests} ) {
         if ( $args{build_script} ) {
             $self->delete("scripts/$name");
             $self->log->info(
@@ -154,6 +158,13 @@
                 '-m',          q{'} . $args{comment} . q{'},
             ];
         }
+        elsif ( $args{_extra_tests} ) {
+            $cmd = [
+                'svk', 'import',
+                $args{source}, join( '/', $self->repository, 't', 'extra' ),
+                '-m', q{'} . $args{comment} . q{'},
+            ];
+        }
         else {
             if ( my $script_dir = $args{build_script} ) {
                 $cmd = [
@@ -297,6 +308,26 @@
     $self->log->warn($err) if $err;
 }
 
+
+sub test_script {
+    my $self   = shift;
+    my %args   = @_;
+    my $script = $args{source};
+    croak 'need source option' unless $script;
+
+    my $dir = tempdir( CLEANUP => 1 );
+    my $file = File::Spec->catfile( $dir, 'test' );
+
+    $self->checkout(
+        path   => '/t/test',
+        target => $file,
+    );
+
+    copy( $args{source}, $file );
+    $self->commit( path => $file, comment => "update test script" );
+    $self->checkout( detach => 1, target => $file );
+}
+
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Backend/SVN.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Backend/SVN.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Backend/SVN.pm	Sun Jan 13 13:32:47 2008
@@ -7,6 +7,7 @@
 use CPAN::DistnameInfo;
 use BPB::Config;
 use File::Temp qw/tempdir/;
+use File::Copy;
 
 # our project's own files will be in //local/test/main
 # all the dependance packages will be in //local/test/deps
@@ -31,7 +32,7 @@
 sub initialize {
     my $self = shift;
     my $dir = tempdir( CLEANUP => 1 );
-    for (qw/bpb dists etc bin scripts/) {
+    for (qw/bpb dists etc bin scripts t/) {
         mkdir File::Spec->catfile( $dir, $_ );
     }
     open my $order, '>', File::Spec->catfile( $dir, 'bpb', 'order.yml' );
@@ -46,6 +47,9 @@
     print $builder $BPB::Backend::BUILDER;
     close $builder;
 
+    open my $t, '>', File::Spec->catfile( $dir, 't', 'test' );
+    close $t;
+
     $self->delete;    # clean repository in case it exists
     $self->log->info( 'initialize ' . $self->repository );
     $self->import(
@@ -54,7 +58,7 @@
         _initialize => 1,
     );
 
-    for ( 'bin/bpb-builder', 'etc/bpb-script-wrapper' ) {
+    for ( 'bin/bpb-builder', 'etc/bpb-script-wrapper', 't/test' ) {
         $self->propset(
             path  => $_,
             type  => 'svn:executable',
@@ -76,7 +80,12 @@
     $name = CPAN::DistnameInfo->new($name)->dist;
 
     unless ( $args{_initialize} ) {
-        if ( $args{build_script} ) {
+        if ( $args{_extra_tests} ) {
+            $self->delete("t/extra");
+            $self->log->info( "import extra tests to " . $self->repository );
+        }
+
+        elsif ( $args{build_script} ) {
             $self->delete("scripts/$name");
             $self->log->info(
                 "import $args{source}'s scripts to " . $self->repository );
@@ -151,6 +160,13 @@
                 '-m',          q{'} . $args{comment} . q{'}
             ];
         }
+        elsif ( $args{_extra_tests} ) {
+            $cmd = [
+                'svn', 'import',
+                $args{source}, join( '/', $self->repository, 't', 'extra' ),
+                '-m', q{'} . $args{comment} . q{'},
+            ];
+        }
         else {
             if ( my $script_dir = $args{build_script} ) {
                 $cmd = [
@@ -308,6 +324,25 @@
     );
 }
 
+sub test_script {
+    my $self   = shift;
+    my %args   = @_;
+    my $script = $args{source};
+    croak 'need source option' unless $script;
+
+    my $dir = tempdir( CLEANUP => 1 );
+
+    $self->checkout(
+        path   => '/t',
+        target => $dir,
+    );
+
+    my $file = File::Spec->catfile( $dir, 'test' );
+
+    copy( $args{source}, $file );
+    $self->commit( path => $file, comment => "update test script" );
+}
+
 1;
 
 __END__



More information about the Bps-public-commit mailing list