cp_multiple.t (1406B)
1 # 2 # Test when more than 1 file in CP_OBJ, obj/ and files exist. 3 # 4 use Modern::Perl; 5 use Test::Cmd; 6 use Test::File; 7 use Test::More tests => 12; 8 9 10 my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' ); 11 my $html_mk = $cmd->here . '/bsd.html.mk'; 12 13 $cmd->write( 'site.mk', <<EOF ); 14 BSDSRCDIR = /tmp 15 BSDOBJDIR = destdir 16 EOF 17 18 $cmd->write( 'a.txt', 'some stuff here' ); 19 $cmd->write( 'b.txt', 'some more stuff here' ); 20 $cmd->subdir( 'destdir' ); 21 $cmd->write( 'Makefile', <<EOF ); 22 CP_OBJ = a.txt b.txt 23 SRCS = 24 25 .include "site.mk" 26 .include "$html_mk" 27 EOF 28 29 # 30 # Create obj/ directory. 31 # 32 my $o = ".*/obj -> destdir/"; 33 34 $cmd->run( args => 'obj', chdir => $cmd->curdir ); 35 like( $cmd->stdout, qr{$o}, 'make obj stdout' ); 36 is( $cmd->stderr, '', 'make obj stderr' ); 37 is( $? >> 8, 0, 'make obj exit status' ); 38 39 # 40 # Default make target should copy the file. 41 # 42 $o = "cp .*/a.txt .*/obj/a.txt 43 cp .*/b.txt .*/obj/b.txt"; 44 45 $cmd->run( chdir => $cmd->curdir ); 46 like( $cmd->stdout, qr{$o}, 'make stdout' ); 47 is( $cmd->stderr, '', 'make stderr' ); 48 is( $? >> 8, 0, 'make exit status' ); 49 50 file_exists_ok( $cmd->workdir . "/a.txt" ); 51 file_exists_ok( $cmd->workdir . "/b.txt" ); 52 file_exists_ok( $cmd->workdir . "/obj/a.txt" ); 53 file_exists_ok( $cmd->workdir . "/obj/b.txt" ); 54 file_contains_like( $cmd->workdir . '/obj/a.txt', qr/some stuff here/ ); 55 file_contains_like( $cmd->workdir . '/obj/b.txt', qr/some more stuff here/ );