[Bps-public-commit] r10382 - bpsbuilder/BPB/t/hello

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jan 17 07:30:29 EST 2008


Author: sunnavy
Date: Thu Jan 17 07:30:26 2008
New Revision: 10382

Removed:
   bpsbuilder/BPB/t/hello/backend.t
   bpsbuilder/BPB/t/hello/source.t
Modified:
   bpsbuilder/BPB/t/hello/hello.t

Log:
we need run source, import, build on by one, it's better to put them into one file

Modified: bpsbuilder/BPB/t/hello/hello.t
==============================================================================
--- bpsbuilder/BPB/t/hello/hello.t	(original)
+++ bpsbuilder/BPB/t/hello/hello.t	Thu Jan 17 07:30:26 2008
@@ -1,22 +1,71 @@
 use strict;
 use warnings;
 
-use Test::More tests => 8;
+use Test::More tests => 27;
 
 use BPB;
+use File::Temp qw/tempdir/;
+use File::Copy;
+
+
+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 $bpb = BPB->new(
+        config => 't/hello/config.yml',
+        name   => 'hello',
+        source => $_,
+    );
+    isa_ok( $bpb, 'BPB' );
+    isa_ok( $bpb->source, "BPB::Source::$source{$_}" );
+}
 
 my $bpb = BPB->new(
     config => 't/hello/config.yml',
     name   => 'hello',
-    source => 'Acme::Hello',
+    source => 't/hello/Acme-Hello-0.03.tar.gz'
 );
+
+
 isa_ok( $bpb,          'BPB' );
 isa_ok( $bpb->config,  'BPB::Config' );
 isa_ok( $bpb->backend, 'BPB::Backend::SVK' );
-isa_ok( $bpb->source,  'BPB::Source::CPAN' );
+isa_ok( $bpb->source,  'BPB::Source::Compressed' );
 isa_ok( $bpb->build,   'BPB::Build' );
 
+my $source_dir = $bpb->source->run();
 for (qw/source backend build/) {
     isa_ok( $bpb->$_->log, 'Log::Log4perl::Logger' );
 }
 
+ok( -e File::Spec->catfile( $source_dir, 'lib', 'Acme', 'Hello.pm' ) );
+ok( -e File::Spec->catfile( $source_dir, 'META.yml' ) );
+
+$bpb->backend->initialize( name => 'hello' );
+my @dirs = sort `svk ls //__bpb/hello`;
+chomp @dirs;
+is_deeply( [@dirs], [ 'bin/', 'bpb/', 'dists/', 'etc/', 'scripts/', 't/' ] );
+
+$bpb->backend->import( name => 'hello', source => $source_dir );
+ok( grep { /Build\.PL/ } `svk ls //__bpb/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 );
+
+$bpb->backend->import(
+    name         => 'hello',
+    source       => $source_dir,
+    build_script => $script_dir,
+);
+ok( grep { /Build\.PL/ } `svk cat //__bpb/hello/scripts/Acme-Hello/build`, 'build script ok' );
+



More information about the Bps-public-commit mailing list