[Bps-public-commit] r10478 - in bpsbuilder/Shipwright/t/hello: . scripts

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jan 24 14:46:07 EST 2008


Author: sunnavy
Date: Thu Jan 24 14:46:07 2008
New Revision: 10478

Added:
   bpsbuilder/Shipwright/t/hello/scripts/howdy_require.yml
   bpsbuilder/Shipwright/t/hello/shipwright/
   bpsbuilder/Shipwright/t/hello/shipwright/order.yml
   bpsbuilder/Shipwright/t/hello/svn.t
   bpsbuilder/Shipwright/t/hello/svn.yml
Modified:
   bpsbuilder/Shipwright/t/hello/hello.t

Log:
more tests

Modified: bpsbuilder/Shipwright/t/hello/hello.t
==============================================================================
--- bpsbuilder/Shipwright/t/hello/hello.t	(original)
+++ bpsbuilder/Shipwright/t/hello/hello.t	Thu Jan 24 14:46:07 2008
@@ -1,85 +1,191 @@
 use strict;
 use warnings;
 
-use Test::More tests => 29;
-
 use Shipwright;
 use File::Temp qw/tempdir/;
 use File::Copy;
+use File::Copy::Recursive qw/dircopy/;
 use File::Spec;
+use Cwd;
 
+use Test::More tests => 41;
+SKIP: {
+    skip "can't find svn in PATH", 41,
+      unless `whereis svk`;
+
+    my $cwd  = getcwd;
+    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',
+        'Acme::Hello'                        => 'CPAN',
+        File::Spec->catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ) =>
+          'Compressed',
+        File::Spec->catfile( 't', 'hello' ) => 'Directory',
+    );
 
-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',
-    'Acme::Hello'                        => 'CPAN',
-    't/hello/Acme-Hello-0.03.tar.gz'     => 'Compressed',
-    't/hello'                            => 'Directory',
-);
+    for ( keys %source ) {
+        my $shipwright = Shipwright->new(
+            config => File::Spec->catfile( 't', 'hello', 'config.yml' ),
+            name   => 'hello',
+            source => $_,
+        );
+        isa_ok( $shipwright, 'Shipwright' );
+        isa_ok( $shipwright->source, "Shipwright::Source::$source{$_}" );
+    }
 
-for ( keys %source ) {
     my $shipwright = Shipwright->new(
-        config => 't/hello/config.yml',
+        config => File::Spec->catfile( 't', 'hello', 'config.yml' ),
         name   => 'hello',
-        source => $_,
+        source => File::Spec->catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ),
     );
-    isa_ok( $shipwright, 'Shipwright' );
-    isa_ok( $shipwright->source, "Shipwright::Source::$source{$_}" );
-}
 
-my $shipwright = Shipwright->new(
-    config => 't/hello/config.yml',
-    name   => 'hello',
-    source => 't/hello/Acme-Hello-0.03.tar.gz'
-);
-
-
-isa_ok( $shipwright,          'Shipwright' );
-isa_ok( $shipwright->config,  'Shipwright::Config' );
-isa_ok( $shipwright->backend, 'Shipwright::Backend::SVK' );
-isa_ok( $shipwright->source,  'Shipwright::Source::Compressed' );
-isa_ok( $shipwright->build,   'Shipwright::Build' );
-
-my $source_dir = $shipwright->source->run();
-for (qw/source backend build/) {
-    isa_ok( $shipwright->$_->log, 'Log::Log4perl::Logger' );
-}
+    isa_ok( $shipwright,          'Shipwright' );
+    isa_ok( $shipwright->config,  'Shipwright::Config' );
+    isa_ok( $shipwright->backend, 'Shipwright::Backend::SVK' );
+    isa_ok( $shipwright->source,  'Shipwright::Source::Compressed' );
+    isa_ok( $shipwright->build,   'Shipwright::Build' );
+
+    # init
+    $shipwright->backend->initialize( name => 'hello' );
+    my @dirs = sort `svk ls $repo`;
+    chomp @dirs;
+    is_deeply(
+        [@dirs],
+        [ 'bin/', 'dists/', 'etc/', 'scripts/', 'shipwright/', 't/' ],
+        'initialize works'
+    );
+
+    # 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 File::Spec->catfile( $source_dir, 'lib', 'Acme', 'Hello.pm' ),
+    ok( -e File::Spec->catfile( $source_dir, 'lib', 'Acme', 'Hello.pm' ),
         'lib/Acme/Hello.pm exists in the source' );
-ok( -e File::Spec->catfile( $source_dir, 'META.yml' ), 'META.yml exists in the source' );
+    ok( -e File::Spec->catfile( $source_dir, 'META.yml' ),
+        'META.yml exists in the source' );
 
-$shipwright->backend->initialize( name => 'hello' );
-my @dirs = sort `svk ls //__shipwright/hello`;
-chomp @dirs;
-is_deeply(
-    [@dirs],
-    [ 'bin/', 'dists/', 'etc/', 'scripts/', 'shipwright/', 't/' ],
-    'initialize works'
-);
-
-$shipwright->backend->import( name => 'hello', source => $source_dir );
-ok( grep( { /Build\.PL/ } `svk ls //__shipwright/hello/dists/Acme-Hello`),
-    'imported ok' );
-
-my $script_dir = tempdir( CLEANUP => 1 );
-copy('t/hello/scripts/build', $script_dir );
-copy('t/hello/scripts/require.yml', $script_dir );
-
-$shipwright->backend->import(
-    name         => 'hello',
-    source       => $source_dir,
-    build_script => $script_dir,
-);
-ok( grep( { /Build\.PL/ } `svk cat //__shipwright/hello/scripts/Acme-Hello/build`), 'build script ok' );
-
-$shipwright->backend->export( target => $shipwright->build->build_base );
-my $install_dir = tempdir;
-$shipwright->build->run( install_base => $install_dir ) ;
-ok( -e File::Spec->catfile($install_dir, 'lib', 'perl5', 'Acme', 'Hello.pm')
-        , 'Acme/Hello.pm exists');
-ok( -e File::Spec->catfile($install_dir, 'etc', 'shipwright-script-wrapper' ),
-        'etc/shipwright-script-wrapper exists' );
+    # import
 
+    $shipwright->backend->import( name => 'hello', source => $source_dir );
+    ok( grep( {/Build\.PL/} `svk ls $repo/dists/Acme-Hello` ), 'imported ok' );
+
+    my $script_dir = tempdir( CLEANUP => 1 );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'build' ),
+        $script_dir );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'require.yml' ),
+        $script_dir );
+
+    $shipwright->backend->import(
+        name         => 'hello',
+        source       => $source_dir,
+        build_script => $script_dir,
+    );
+    ok( grep( {/Build\.PL/} `svk cat $repo/scripts/Acme-Hello/build` ),
+        'build script ok' );
+
+    # export
+    $shipwright->backend->export( target => $shipwright->build->build_base );
+
+    for (
+        File::Spec->catfile(
+            $shipwright->build->build_base,
+            'shipwright', 'order.yml',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'etc',
+            'shipwright-script-wrapper'
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base,
+            'dists', 'Acme-Hello',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'dists',
+            'Acme-Hello',                   'MANIFEST',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'scripts',
+            'Acme-Hello',                   'build',
+        ),
+      )
+    {
+        ok( -e $_, "$_ exists" );
+    }
+
+    # install
+    my $install_dir = tempdir;
+    $shipwright->build->run( install_base => $install_dir );
+
+    for (
+        File::Spec->catfile( $install_dir, 'lib', 'perl5', 'Acme', 'Hello.pm' ),
+        File::Spec->catfile( $install_dir, 'etc', 'shipwright-script-wrapper' ),
+      )
+    {
+        ok( -e $_, "$_ exists" );
+    }
+
+    # import another dist
+
+    chdir $cwd;
+    $shipwright = Shipwright->new(
+        config => File::Spec->catfile( 't', 'hello', 'config.yml' ),
+        name   => 'hello',
+        source => File::Spec->catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ),
+        source_name => 'howdy',
+    );
+
+    $source_dir = $shipwright->source->run();
+    like( $source_dir, qr/\bhowdy\b/, 'source name looks ok' );
+    $shipwright->backend->import( name => 'hello', source => $source_dir );
+    ok( grep( {/Build\.PL/} `svk ls $repo/dists/howdy` ), 'imported ok' );
+    $script_dir = tempdir( CLEANUP => 1 );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'build' ),
+        $script_dir );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'howdy_require.yml' ),
+        File::Spec->catfile( $script_dir, 'require.yml' ) );
+
+    $shipwright->backend->import(
+        name         => 'hello',
+        source       => $source_dir,
+        build_script => $script_dir,
+    );
+    ok( grep( {/Build\.PL/} `svk cat $repo/scripts/howdy/build` ),
+        'build script ok' );
+
+    my $tempdir = tempdir( CLEANUP => 1 );
+    dircopy(
+        File::Spec->catfile( 't',      'hello', 'shipwright' ),
+        File::Spec->catfile( $tempdir, 'shipwright' )
+    );
+
+    # check to see if update_order works
+    like(
+        `svk cat $repo/shipwright/order.yml`,
+        qr/Acme-Hello.*howdy/s,
+        'original order is right'
+    );
+
+    system( 'svk import '
+          . File::Spec->catfile( $tempdir, 'shipwright' )
+          . " $repo/shipwright -m ''" );
+    like(
+        `svk cat $repo/shipwright/order.yml`,
+        qr/howdy.*Acme-Hello/s,
+        'imported wrong order works'
+    );
+
+    $shipwright->backend->update_order;
+    like(
+        `svk cat $repo/shipwright/order.yml`,
+        qr/Acme-Hello.*howdy/s,
+        'updated order works'
+    );
+}

Added: bpsbuilder/Shipwright/t/hello/scripts/howdy_require.yml
==============================================================================
--- (empty file)
+++ bpsbuilder/Shipwright/t/hello/scripts/howdy_require.yml	Thu Jan 24 14:46:07 2008
@@ -0,0 +1,4 @@
+--- 
+requires:
+    Acme-Hello:
+        version: 0

Added: bpsbuilder/Shipwright/t/hello/shipwright/order.yml
==============================================================================
--- (empty file)
+++ bpsbuilder/Shipwright/t/hello/shipwright/order.yml	Thu Jan 24 14:46:07 2008
@@ -0,0 +1,2 @@
+- howdy
+- Acme-Hello

Added: bpsbuilder/Shipwright/t/hello/svn.t
==============================================================================
--- (empty file)
+++ bpsbuilder/Shipwright/t/hello/svn.t	Thu Jan 24 14:46:07 2008
@@ -0,0 +1,161 @@
+use strict;
+use warnings;
+
+use Shipwright;
+use File::Temp qw/tempdir/;
+use File::Copy;
+use File::Copy::Recursive qw/dircopy/;
+use File::Spec;
+use Cwd;
+use Test::More tests => 17;
+
+SKIP: {
+    skip "can't find svn in PATH", 17,
+      unless `whereis svn` && `whereis svnadmin`;
+    my $cwd = getcwd;
+
+    my $repo = 'file:///tmp/shipwright_svn/hello';
+
+    system('rm -rf /tmp/shipwright_svn') && warn "delete repo failed: $!";
+    system('svnadmin create /tmp/shipwright_svn')
+      && die "create repo failed: $!";
+
+    my $shipwright = Shipwright->new(
+        config => File::Spec->catfile( 't', 'hello', 'svn.yml' ),
+        name   => 'hello',
+        source => File::Spec->catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ),
+    );
+
+    isa_ok( $shipwright->backend, 'Shipwright::Backend::SVN' );
+
+    # init
+    $shipwright->backend->initialize( name => 'hello' );
+    my @dirs = sort `svn ls $repo`;
+    chomp @dirs;
+    is_deeply(
+        [@dirs],
+        [ 'bin/', 'dists/', 'etc/', 'scripts/', 'shipwright/', 't/' ],
+        'initialize works'
+    );
+
+    # source
+    my $source_dir = $shipwright->source->run();
+
+    # import
+    $shipwright->backend->import( name => 'hello', source => $source_dir );
+    ok( grep( {/Build\.PL/} `svn ls $repo/dists/Acme-Hello` ), 'imported ok' );
+
+    my $script_dir = tempdir( CLEANUP => 1 );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'build' ),
+        $script_dir );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'require.yml' ),
+        $script_dir );
+
+    $shipwright->backend->import(
+        name         => 'hello',
+        source       => $source_dir,
+        build_script => $script_dir,
+    );
+    ok( grep( {/Build\.PL/} `svn cat $repo/scripts/Acme-Hello/build` ),
+        'build script ok' );
+
+    # export
+    $shipwright->backend->export( target => $shipwright->build->build_base );
+
+    for (
+        File::Spec->catfile(
+            $shipwright->build->build_base,
+            'shipwright', 'order.yml',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'etc',
+            'shipwright-script-wrapper'
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base,
+            'dists', 'Acme-Hello',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'dists',
+            'Acme-Hello',                   'MANIFEST',
+        ),
+        File::Spec->catfile(
+            $shipwright->build->build_base, 'scripts',
+            'Acme-Hello',                   'build',
+        ),
+      )
+    {
+        ok( -e $_, "$_ exists" );
+    }
+
+    # install
+    my $install_dir = tempdir;
+    $shipwright->build->run( install_base => $install_dir );
+
+    for (
+        File::Spec->catfile( $install_dir, 'lib', 'perl5', 'Acme', 'Hello.pm' ),
+        File::Spec->catfile( $install_dir, 'etc', 'shipwright-script-wrapper' ),
+      )
+    {
+        ok( -e $_, "$_ exists" );
+    }
+
+    # import another dist
+
+    chdir $cwd;
+    $shipwright = Shipwright->new(
+        config => File::Spec->catfile( 't', 'hello', 'svn.yml' ),
+        name   => 'hello',
+        source => File::Spec->catfile( 't', 'hello', 'Acme-Hello-0.03.tar.gz' ),
+        source_name => 'howdy',
+    );
+
+    $source_dir = $shipwright->source->run();
+    like( $source_dir, qr/\bhowdy\b/, 'source name looks ok' );
+    $shipwright->backend->import( name => 'hello', source => $source_dir );
+    ok( grep( {/Build\.PL/} `svn ls $repo/dists/howdy` ), 'imported ok' );
+    $script_dir = tempdir( CLEANUP => 1 );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'build' ),
+        $script_dir );
+    copy( File::Spec->catfile( 't', 'hello', 'scripts', 'howdy_require.yml' ),
+        File::Spec->catfile( $script_dir, 'require.yml' ) );
+
+    $shipwright->backend->import(
+        name         => 'hello',
+        source       => $source_dir,
+        build_script => $script_dir,
+    );
+    ok( grep( {/Build\.PL/} `svn cat $repo/scripts/howdy/build` ),
+        'build script ok' );
+
+    my $tempdir = tempdir( CLEANUP => 1 );
+    dircopy(
+        File::Spec->catfile( 't',      'hello', 'shipwright' ),
+        File::Spec->catfile( $tempdir, 'shipwright' )
+    );
+
+    # check to see if update_order works
+    like(
+        `svn cat $repo/shipwright/order.yml`,
+        qr/Acme-Hello.*howdy/s,
+        'order is right'
+    );
+
+    system( 'svn delete -m "" ' . " $repo/shipwright" );
+    system( 'svn import '
+          . File::Spec->catfile( $tempdir, 'shipwright' )
+          . " $repo/shipwright -m ''" );
+    like(
+        `svn cat $repo/shipwright/order.yml`,
+        qr/howdy.*Acme-Hello/s,
+        'imported wrong order works'
+    );
+
+    $shipwright->backend->update_order;
+    like(
+        `svn cat $repo/shipwright/order.yml`,
+        qr/Acme-Hello.*howdy/s,
+        'updated order works'
+    );
+}
+

Added: bpsbuilder/Shipwright/t/hello/svn.yml
==============================================================================
--- (empty file)
+++ bpsbuilder/Shipwright/t/hello/svn.yml	Thu Jan 24 14:46:07 2008
@@ -0,0 +1,11 @@
+hello:
+    log:
+        level: FATAL
+    backend:
+        module: SVN
+        repository: file:///tmp/shipwright_svn/hello
+    source:
+        min_perl_version: 5.008008
+    build:
+        perl: 'perl'
+        skip_test: 0



More information about the Bps-public-commit mailing list