html.mk

static html creation framework using make(1) and cpp(1)
git clone git://0x30.net/html.mk
Log | Files | Refs | README | LICENSE

cp_happy.t (1158B)


      1 #
      2 # Happy path for CP, obj/ and file exists.
      3 #
      4 use Modern::Perl;
      5 use Test::Cmd;
      6 use Test::File;
      7 use Test::More tests => 9;
      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( 'copy.txt', 'some stuff here' );
     19 $cmd->subdir( 'destdir' );
     20 $cmd->write( 'Makefile', <<EOF );
     21 CP_OBJ = copy.txt
     22 SRCS =
     23 
     24 .include "site.mk"
     25 .include "$html_mk"
     26 EOF
     27 
     28 #
     29 # Create obj/ directory.
     30 #
     31 my $o = ".*/obj -> destdir/";
     32 
     33 $cmd->run( args => 'obj', chdir => $cmd->curdir );
     34 like( $cmd->stdout,	qr{$o},	'make obj stdout' );
     35 is( $cmd->stderr,	'',	'make obj stderr' );
     36 is( $? >> 8,		0,	'make obj exit status' );
     37 
     38 #
     39 # Default make target should copy the file.
     40 #
     41 $o = "cp .*/copy.txt .*/obj/copy.txt";
     42 
     43 $cmd->run( chdir => $cmd->curdir );
     44 like( $cmd->stdout,	qr{$o},	'make stdout' );
     45 is( $cmd->stderr,	'',	'make stderr' );
     46 is( $? >> 8,		0,	'make exit status' );
     47 
     48 file_exists_ok( $cmd->workdir . "/copy.txt" );
     49 file_exists_ok( $cmd->workdir . "/obj/copy.txt" );
     50 file_contains_like( $cmd->workdir . '/obj/copy.txt', qr/some stuff here/ );