html.mk

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

dep_simple.t (1638B)


      1 #
      2 # make depend works on single file.
      3 #
      4 use Modern::Perl;
      5 use Test::File;
      6 use Test::Cmd;
      7 use Test::More tests => 18;
      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( 'index.in', '' );
     14 $cmd->write( 'Makefile', <<EOF );
     15 .include "$html_mk"
     16 EOF
     17 
     18 #
     19 # 1) `make depend'
     20 #
     21 $cmd->run( args => 'depend', chdir => $cmd->curdir );
     22 
     23 my $o = "cpp .* -MF index.d -MT index.html index.in";
     24 like( $cmd->stdout,	qr{$o},	'make depend stdout' );
     25 is( $cmd->stderr,	'',	'make depend stderr' );
     26 is( $? >> 8,		0,	'make depend exit status' );
     27 
     28 file_exists_ok( $cmd->workpath . '/index.d' );
     29 
     30 #
     31 # 2) `make'
     32 #
     33 $cmd->run( chdir => $cmd->curdir );
     34 
     35 $o = "cpp .* -P -o .*index.html .*index.in";
     36 like( $cmd->stdout,	qr{$o},	'make stdout' );
     37 is( $cmd->stderr,	'',	'make stderr' );
     38 is( $? >> 8,		0,	'make exit status' );
     39 file_exists_ok( $cmd->workpath . '/index.html' );
     40 
     41 #
     42 # 3) Another `make' does nothing.
     43 #
     44 $cmd->run( chdir => $cmd->curdir );
     45 is( $cmd->stdout,	'',	'make stdout' );
     46 is( $cmd->stderr,	'',	'make stderr' );
     47 is( $? >> 8,		0,	'make exit status' );
     48 
     49 #
     50 # 4) Touch the source file and re-run `make'.
     51 #
     52 $cmd->write( 'index.in', '' );
     53 $cmd->run( chdir => $cmd->curdir );
     54 
     55 like( $cmd->stdout,	qr{$o},	'make stdout' );
     56 is( $cmd->stderr,	'',	'make stderr' );
     57 is( $? >> 8,		0,	'make exit status' );
     58 
     59 #
     60 # 5) Remove index.html and re-run `make'.
     61 #
     62 my $f = $cmd->workdir . "/index.html";
     63 is (unlink( $f ),	1,	'unlink success' );
     64 
     65 $cmd->run( chdir => $cmd->curdir );
     66 like( $cmd->stdout,	qr{$o},	'make stdout' );
     67 is( $cmd->stderr,	'',	'make stderr' );
     68 is( $? >> 8,		0,	'make exit status' );