html.mk

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

commit c642618d3a8b4913a729fe81b9a3ea547b25b8c0
parent d1d47df5078ddf457a7c094f174d363b9b1874d6
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Mon, 22 Nov 2021 16:29:09 +0000

t: add test for known bug

not fixable at the moment however

Diffstat:
At/bug_cp_xliterate.t | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+), 0 deletions(-)

diff --git a/t/bug_cp_xliterate.t b/t/bug_cp_xliterate.t @@ -0,0 +1,69 @@ +# +# Using CP_OBJ and .xliterate special target on the same file results +# in make depending on the CP_OBJ file in obj/ instead of the one in +# the source directory. +# +# I don't know how to easily fix this at the moment. +# +use Modern::Perl; +use Test::Cmd; +use Test::File; +use Test::More tests => 14; + + +my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' ); +my $html_mk = $cmd->here . '/bsd.html.mk'; + +$cmd->write( 'site.mk', <<EOF ); +EOF + +$cmd->write( 'index.in', '#include "file.xliterate"' ); +$cmd->write( 'file.txt', 'some file contents' ); + +$cmd->subdir( 'destdir' ); +$cmd->write( 'Makefile', <<EOF ); +BSDSRCDIR = /tmp +BSDOBJDIR = destdir + +CP_OBJ = file.txt + +.include "$html_mk" +EOF + +# Create obj/ directory. +$cmd->run( args => 'obj', chdir => $cmd->curdir ); +is( $? >> 8, 0, 'make obj exit status' ); + +# Create dependencies +$cmd->run( args => 'depend', chdir => $cmd->curdir ); +is( $? >> 8, 0, 'make depend exit status' ); + +my $o = "cpp .* +cp .*/file.txt .*/obj/file.txt"; + +$cmd->run( chdir => $cmd->curdir ); +like( $cmd->stdout, qr{$o}, 'make stdout' ); +is( $cmd->stderr, '', 'make stderr' ); +is( $? >> 8, 0, 'make exit status' ); + +file_exists_ok( $cmd->workdir . "/file.txt" ); +file_exists_ok( $cmd->workdir . "/obj/file.txt" ); +file_contains_like( $cmd->workdir . '/obj/index.html', qr{some file contents} ); + +# +# BUG: Another `make' is not supposed to do anything, but further +# processing happens. +# +$o = "sed .*"; + +$cmd->run( chdir => $cmd->curdir ); +like( $cmd->stdout, qr{$o}, 'make stdout' ); +is( $cmd->stderr, '', 'make stderr' ); +is( $? >> 8, 0, 'make exit status' ); + + +# A third `make' does nothing. +$cmd->run( chdir => $cmd->curdir ); +is( $cmd->stdout, '', 'make stdout' ); +is( $cmd->stderr, '', 'make stderr' ); +is( $? >> 8, 0, 'make exit status' );