[Bps-public-commit] r17766 - in Shipwright/trunk: t t/hello

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jan 16 04:09:22 EST 2009


Author: sunnavy
Date: Fri Jan 16 04:09:21 2009
New Revision: 17766

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/t/01.repo_check.t
   Shipwright/trunk/t/10.flags.t
   Shipwright/trunk/t/21.perl_in_build.t
   Shipwright/trunk/t/71.script_cmds.t
   Shipwright/trunk/t/hello/svk.t
   Shipwright/trunk/t/hello/svn.t

Log:
 r18811 at sunnavys-mb:  sunnavy | 2009-01-16 17:04:33 +0800
 update tests, mainly to make fs backend as main test backend


Modified: Shipwright/trunk/t/01.repo_check.t
==============================================================================
--- Shipwright/trunk/t/01.repo_check.t	(original)
+++ Shipwright/trunk/t/01.repo_check.t	Fri Jan 16 04:09:21 2009
@@ -2,18 +2,41 @@
 use warnings;
 
 use Shipwright;
-use Shipwright::Test qw/skip_svk create_svk_repo skip_svn create_svn_repo/;
+use Shipwright::Test;
 use File::Spec::Functions qw/catfile/;
 use File::Temp qw/tempdir/;
 
-use Test::More tests => 10;
+use Test::More tests => 28;
 
 Shipwright::Test->init;
 
+{
+
+    # fs backend test
+    my $repo       = 'fs:' . create_fs_repo();
+    my $shipwright = Shipwright->new(
+        log_level  => 'fatal',
+        repository => $repo,
+    );
+    $shipwright->backend->initialize;
+
+    my %map = (
+        create => {
+            $repo => 1,
+
+          # yeah, fs can create anywhere, but this may fail if permission denied
+            'fs:/noexists/blalba' => 1,
+        },
+        list => {
+            'fs:/noexists/bla' => undef,
+            $repo              => 1,
+        },
+    );
+    test_repo( 'FS', %map );
+}
+
 SKIP: {
-    skip
-"svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set",
-      5
+    skip "svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set", 10 
       if skip_svk();
 
     create_svk_repo();
@@ -34,21 +57,11 @@
         },
     );
 
-    for my $action ( keys %map ) {
-        for my $repo ( keys %{ $map{$action} } ) {
-            my $backend = Shipwright::Backend->new( repository => $repo );
-            is(
-                $backend->check_repository( action => $action ),
-                $map{$action}{$repo},
-                "$repo for action $action",
-            );
-        }
-    }
-
+    test_repo( 'SVK', %map );
 }
 
 SKIP: {
-    skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 5
+    skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 10 
       if skip_svn();
 
     my $valid   = create_svn_repo();
@@ -72,9 +85,16 @@
         },
     );
 
+    test_repo( 'SVN', %map );
+}
+
+sub test_repo {
+    my $bk_class = shift;
+    my %map      = @_;
     for my $action ( keys %map ) {
         for my $repo ( keys %{ $map{$action} } ) {
             my $backend = Shipwright::Backend->new( repository => $repo );
+            isa_ok( $backend, 'Shipwright::Backend::' . $bk_class );
             is(
                 $backend->check_repository( action => $action ),
                 $map{$action}{$repo},
@@ -82,5 +102,4 @@
             );
         }
     }
-
 }

Modified: Shipwright/trunk/t/10.flags.t
==============================================================================
--- Shipwright/trunk/t/10.flags.t	(original)
+++ Shipwright/trunk/t/10.flags.t	Fri Jan 16 04:09:21 2009
@@ -2,37 +2,16 @@
 use warnings;
 
 use Shipwright;
-use Shipwright::Test qw/skip_svk create_svk_repo skip_svn create_svn_repo/;
+use Shipwright::Test;
 use File::Spec::Functions qw/catfile catdir/;
 
-use Test::More tests => 6;
+use Test::More tests => 3;
 
 Shipwright::Test->init;
 
-SKIP: {
-    skip "svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set", 3
-      if skip_svk();
-
-    create_svk_repo();
-    my $repo = '//__shipwright/foo';
-
-    my $shipwright = Shipwright->new(
-        repository => "svk:$repo",
-        log_level  => 'FATAL',
-    );
-
-    test_flags( shipwright => $shipwright, name => 'foo' );
-
-}
-
-SKIP: {
-    skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 3
-      if skip_svn();
-
-    my $repo = create_svn_repo . '/foo';
-
+{
     my $shipwright = Shipwright->new(
-        repository => "svn:$repo",
+        repository => 'fs:' . create_fs_repo,
         log_level  => 'FATAL',
     );
 

Modified: Shipwright/trunk/t/21.perl_in_build.t
==============================================================================
--- Shipwright/trunk/t/21.perl_in_build.t	(original)
+++ Shipwright/trunk/t/21.perl_in_build.t	Fri Jan 16 04:09:21 2009
@@ -2,85 +2,77 @@
 use warnings;
 
 use Shipwright;
-use Shipwright::Test qw/skip_svk create_svk_repo skip_svn create_svn_repo/;
+use Shipwright::Test;
 use File::Spec::Functions qw/catfile catdir/;
 use File::Temp qw/tempdir/;
 
 use Test::More tests => 8;
 Shipwright::Test->init;
 
-SKIP: {
-    skip "svk: no svk found or env SHIPWRIGHT_TEST_BACKEND_SVK not set", 8
-      if skip_svk();
-
-    create_svk_repo();
-
-    my $repo = '//__shipwright/foo';
-
-    my $install_base =
-      tempdir( 'shipwright_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
-
-    my $sw = Shipwright->new(
-        repository   => "svk:$repo",
-        log_level    => 'FATAL',
-        perl         => '/noexist',
-        install_base => $install_base,
-    );
-    $sw->backend->initialize();
-
-    $sw->backend->export( target => $sw->build->build_base );
-    $sw->build->run();
-
-    is( $sw->build->perl, $^X, 'nonexist perl is changed to $^X' );
-
-    my $bin  = catfile( $install_base, 'bin' );
-    my $perl = catfile( $bin,          'perl' );
-    mkdir $bin unless -e $bin;
-
-    open my $fh, '>', $perl;
-    close $fh;
-    chmod 0755, $perl;
-    ok( -e $perl, 'found bin/perl in installed_base' );
-
-    $sw->build->perl(undef);
-    ok( !defined $sw->build->perl, 'make sure perl is undef' );
-
-    $sw->build->run;
-    is( $sw->build->perl, $perl,
-        'set $build->perl to the one in install_base if that exists' );
-
-    $sw->build->perl(undef);
-    ok( !defined $sw->build->perl, 'make sure perl is undef' );
-
-    $sw->build->build_base(
-        catdir( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'build' ) );
-
-    # import a fake perl dist
-    my $source = catfile( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'perl' );
-    mkdir $source;
-    my $script_dir = tempdir( 'shipwright_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
-    my $build_script = catfile( $script_dir, 'build' );
-    open $fh, '>', $build_script;
-    close $fh;
-
-    $sw->backend->import( source => $source );
-    $sw->backend->import(
-        source       => $source,
-        build_script => $script_dir,
-    );
-    $sw->backend->export( target => $sw->build->build_base );
-    $sw->build->run;
-    is( $sw->build->perl, $perl,
+my $repo = 'fs:' . create_fs_repo();
+
+my $install_base = tempdir( 'shipwright_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
+
+my $sw = Shipwright->new(
+    repository   => $repo,
+    log_level    => 'FATAL',
+    perl         => '/noexist',
+    install_base => $install_base,
+);
+$sw->backend->initialize();
+
+$sw->backend->export( target => $sw->build->build_base );
+$sw->build->run();
+
+is( $sw->build->perl, $^X, 'nonexist perl is changed to $^X' );
+
+my $bin  = catfile( $install_base, 'bin' );
+my $perl = catfile( $bin,          'perl' );
+mkdir $bin unless -e $bin;
+
+open my $fh, '>', $perl;
+close $fh;
+chmod 0755, $perl;
+ok( -e $perl, 'found bin/perl in installed_base' );
+
+$sw->build->perl(undef);
+ok( !defined $sw->build->perl, 'make sure perl is undef' );
+
+$sw->build->run;
+is( $sw->build->perl, $perl,
+    'set $build->perl to the one in install_base if that exists' );
+
+$sw->build->perl(undef);
+ok( !defined $sw->build->perl, 'make sure perl is undef' );
+
+$sw->build->build_base(
+    catdir( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'build' ) );
+
+# import a fake perl dist
+my $source = catfile( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'perl' );
+mkdir $source;
+my $script_dir = tempdir( 'shipwright_XXXXXX', CLEANUP => 1, TMPDIR => 1 );
+my $build_script = catfile( $script_dir, 'build' );
+open $fh, '>', $build_script;
+close $fh;
+
+$sw->backend->import( source => $source );
+$sw->backend->import(
+    source       => $source,
+    build_script => $script_dir,
+);
+$sw->backend->export( target => $sw->build->build_base );
+$sw->build->run;
+is( $sw->build->perl, $perl,
 'set $build->perl to the one that will be in installed_dir if there is a dist with name perl'
-    );
+);
 
-    $sw->build->perl(undef);
-    ok( !defined $sw->build->perl, 'make sure perl is undef' );
-    $sw->build->skip( { perl => 1 } );
-    $sw->build->install_base(
-        catdir( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'install' ) );
-    $sw->build->run;
-    is( $sw->build->perl, $^X,
-        'install with --skip perl will not change $build->perl' );
-}
+$sw->build->perl(undef);
+ok( !defined $sw->build->perl, 'make sure perl is undef' );
+$sw->build->skip( { perl => 1 } );
+$sw->build->install_base(
+    catdir( tempdir( CLEANUP => 1, TMPDIR => 1 ), 'install' ) );
+$sw->build->run;
+is( $sw->build->perl, $^X,
+    'install with --skip perl will not change $build->perl' );
 

Modified: Shipwright/trunk/t/71.script_cmds.t
==============================================================================
--- Shipwright/trunk/t/71.script_cmds.t	(original)
+++ Shipwright/trunk/t/71.script_cmds.t	Fri Jan 16 04:09:21 2009
@@ -11,11 +11,14 @@
 
 Shipwright::Test->init;
 
-my $repo         = 'fs:' . create_fs_repo();
 my $install_base = catdir( tmpdir(), 'vessel_71_scripts_cmds' );
 my $build_base   = catdir( tmpdir(), 'shipwright_build_71_scripts_cmds' );
 
-start_test($repo);
+{
+    # fs backend
+    start_test('fs:' . create_fs_repo() );
+}
+
 
 SKIP: {
     skip "svn: no svn found or env SHIPWRIGHT_TEST_BACKEND_SVN not set", 36 if skip_svn();

Modified: Shipwright/trunk/t/hello/svk.t
==============================================================================
--- Shipwright/trunk/t/hello/svk.t	(original)
+++ Shipwright/trunk/t/hello/svk.t	Fri Jan 16 04:09:21 2009
@@ -9,8 +9,8 @@
 use File::Path qw/rmtree/;
 use Cwd qw/getcwd abs_path/;
 
-use Test::More tests => 41;
-use Shipwright::Test qw/skip_svk create_svk_repo/;
+use Test::More tests => 17;
+use Shipwright::Test;
 Shipwright::Test->init;
 
 SKIP: {
@@ -23,27 +23,6 @@
 
     my $repo = '//__shipwright/hello';
 
-    my %source = (
-        'http://example.com/hello.tar.gz'    => 'HTTP',
-        'ftp://example.com/hello.tar.gz'     => 'FTP',
-        'svn:file:///home/sunnavy/svn/hello' => 'SVN',
-        'svk://local/hello'                  => 'SVK',
-        'cpan:Acme::Hello'                   => 'CPAN',
-        'file:'
-          . catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ) => 'Compressed',
-        'dir:' . catfile( 't', 'hello' ) => 'Directory',
-    );
-
-    for ( keys %source ) {
-        my $shipwright = Shipwright->new(
-            repository => "svk:$repo",
-            source     => $_,
-            log_level  => 'FATAL',
-        );
-        isa_ok( $shipwright, 'Shipwright' );
-        isa_ok( $shipwright->source, "Shipwright::Source::$source{$_}" );
-    }
-
     my $shipwright = Shipwright->new(
         repository => "svk:$repo",
         source => 'file:' . catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ),
@@ -51,11 +30,7 @@
         log_level => 'FATAL',
         force => 1,
     );
-
-    isa_ok( $shipwright,          'Shipwright' );
     isa_ok( $shipwright->backend, 'Shipwright::Backend::SVK' );
-    isa_ok( $shipwright->source,  'Shipwright::Source::Compressed' );
-    isa_ok( $shipwright->build,   'Shipwright::Build' );
 
     # init
     $shipwright->backend->initialize();
@@ -69,16 +44,6 @@
 
     # source
     my $source_dir = $shipwright->source->run();
-    like( $source_dir, qr/\bAcme-Hello\b/, 'source name looks ok' );
-
-    for (qw/source backend build/) {
-        isa_ok( $shipwright->$_->log, 'Log::Log4perl::Logger' );
-    }
-
-    ok( -e catfile( $source_dir, 'lib', 'Acme', 'Hello.pm' ),
-        'lib/Acme/Hello.pm exists in the source' );
-    ok( -e catfile( $source_dir, 'META.yml' ),
-        'META.yml exists in the source' );
 
     # import
 
@@ -197,27 +162,5 @@
         'updated order works'
     );
 
-    # build with 0 packages
-
-    {
-        my $shipwright = Shipwright->new(
-            repository => "svk:$repo",
-            log_level  => 'FATAL',
-        );
-
-        # init
-        $shipwright->backend->initialize();
-        $shipwright->backend->export(
-            target => $shipwright->build->build_base );
-        $shipwright->build->run();
-        ok(
-            -e catfile(
-                $shipwright->build->install_base, 'etc',
-                'shipwright-script-wrapper'
-            ),
-            'build with 0 packages ok'
-        );
-        rmtree( abs_path(catdir( $shipwright->build->install_base, updir() )) );
-    }
 }
 

Modified: Shipwright/trunk/t/hello/svn.t
==============================================================================
--- Shipwright/trunk/t/hello/svn.t	(original)
+++ Shipwright/trunk/t/hello/svn.t	Fri Jan 16 04:09:21 2009
@@ -8,7 +8,7 @@
 use File::Spec::Functions qw/catfile catdir updir/;
 use Cwd qw/getcwd abs_path/;
 use Test::More tests => 17;
-use Shipwright::Test qw/skip_svn create_svn_repo/;
+use Shipwright::Test;
 use File::Path qw/rmtree/;
 Shipwright::Test->init;
 
@@ -56,7 +56,6 @@
         name         => 'hello',
         source       => $source_dir,
         build_script => $script_dir,
-        log_level    => 'FATAL',
     );
     ok( grep( {/Build\.PL/} `svn cat $repo/scripts/Acme-Hello/build` ),
         'build script ok' );



More information about the Bps-public-commit mailing list