[Bps-public-commit] r10301 - bpsbuilder/BPB/lib/BPB/Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Jan 13 13:33:41 EST 2008


Author: sunnavy
Date: Sun Jan 13 13:33:40 2008
New Revision: 10301

Modified:
   bpsbuilder/BPB/lib/BPB/Script/Import.pm

Log:
added extra-tests and test-script cli args for import

Modified: bpsbuilder/BPB/lib/BPB/Script/Import.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Script/Import.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Script/Import.pm	Sun Jan 13 13:33:40 2008
@@ -7,7 +7,7 @@
 use base qw/App::CLI::Command Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
     qw/config name comment source no_follow build_script require_yml
-      source_name/
+      source_name test_script extra_tests/
 );
 
 use BPB;
@@ -27,6 +27,8 @@
         'no-follow'      => 'no_follow',
         'build-script=s' => 'build_script',
         'require-yml=s'  => 'require_yml',
+        'test-script=s'  => 'test_script',
+        'extra-tests=s'  => 'extra_tests',
     );
 }
 
@@ -38,10 +40,6 @@
 
     $self->source($source) if $source;
 
-    for (qw/name source/) {
-        die "need $_ arg" unless $self->$_();
-    }
-
     my $bpb = BPB->new(
         config      => $self->config,
         name        => $self->name,
@@ -50,34 +48,55 @@
         follow      => !$self->no_follow,
     );
 
-    $self->source( $bpb->source->run( '__require.yml' => $self->require_yml ) );
+    if ( $self->source ) {
 
-    $self->import_req( $self->source, $bpb );
+        for (qw/name source/) {
+            die "need $_ arg" unless $self->$_();
+        }
 
-    my $script_dir = tempdir( CLEANUP => 1 );
+        $self->source(
+            $bpb->source->run( '__require.yml' => $self->require_yml ) );
 
-    if ( my $script = $self->build_script ) {
-        copy( $self->build_script,
-            File::Spec->catfile( $script_dir, 'build' ) );
-    }
-    else {
-        $self->generate_build( $self->source, $script_dir, $bpb );
+        $self->import_req( $self->source, $bpb );
+
+        my $script_dir = tempdir( CLEANUP => 1 );
+
+        if ( my $script = $self->build_script ) {
+            copy( $self->build_script,
+                File::Spec->catfile( $script_dir, 'build' ) );
+        }
+        else {
+            $self->generate_build( $self->source, $script_dir, $bpb );
+        }
+
+        move(
+            File::Spec->catfile( $self->source, '__require.yml' ),
+            File::Spec->catfile( $script_dir,   'require.yml' )
+        );
+
+        $bpb->backend->import(
+            source  => $self->source,
+            comment => $self->comment || 'import ' . $self->source,
+        );
+        $bpb->backend->import(
+            source       => $self->source,
+            comment      => 'import scripts for' . $self->source,
+            build_script => $script_dir,
+        );
     }
 
-    move(
-        File::Spec->catfile( $self->source, '__require.yml' ),
-        File::Spec->catfile( $script_dir,   'require.yml' )
-    );
+# import tests
+    if ( $self->extra_tests ) {
+        $bpb->backend->import(
+            source  => $self->extra_tests,
+            comment => 'import extra tests',
+            _extra_tests => 1,
+        );
+    }
 
-    $bpb->backend->import(
-        source  => $self->source,
-        comment => $self->comment || 'import ' . $self->source,
-    );
-    $bpb->backend->import(
-        source       => $self->source,
-        comment      => 'import scripts for' . $self->source,
-        build_script => $script_dir,
-    );
+    if ( $self->test_script ) {
+        $bpb->backend->test_script( source => $self->test_script );
+    }
 }
 
 sub import_req {



More information about the Bps-public-commit mailing list