html.mk

static html creation framework using make(1) and cpp(1)
Log | Files | Refs | README | LICENSE

commit 94879c93d1f5cf8c7ab64096d32472b68f9725ea
parent 041b415cfb915e2f07c0be3200cfdfda63a54642
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu, 22 Jul 2021 22:36:44 +0000

t: add test for multiple source files

Diffstat:
Mbsd.html.mk | 3+++
At/srcs_multiple.t | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/bsd.html.mk b/bsd.html.mk @@ -161,6 +161,9 @@ all: ${.OBJDIR}/${file}: ${.CURDIR}/${file} cp ${.CURDIR}/${file} $@ +clean: + echo foo + # # Helper targets for misc tasks. # diff --git a/t/srcs_multiple.t b/t/srcs_multiple.t @@ -0,0 +1,60 @@ +# +# Building multiple source files in tree and out of tree. +# +use Modern::Perl; +use Test::Cmd; +use Test::File; +use Test::More tests => 13; + + +my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' ); +my $html_mk = $cmd->here . "/bsd.html.mk"; + +$cmd->write( 'Makefile', <<EOF ); +SRCS += a.in b.in c.in + +.include "$html_mk" +EOF + +$cmd->write( 'a.in', <<EOF ); +<p> This is file a. </p> +EOF + +$cmd->write( 'b.in', <<EOF ); +<p> This is file a. </p> +EOF + +$cmd->write( 'c.in', <<EOF ); +<p> This is file a. </p> +EOF + +# +# 1) First check that output files are created in tree. +# + +$cmd->run( chdir => $cmd->curdir ); + +like( $cmd->stdout, qr/.*/, 'make stdout' ); +is( $cmd->stderr, "", 'make stderr' ); +is( $? >> 8, 0, 'make exit status' ); + +file_exists_ok( $cmd->workdir . '/a.html' ); +file_exists_ok( $cmd->workdir . '/b.html' ); +file_exists_ok( $cmd->workdir . '/c.html' ); + +# +# 2) Now run `make obj` and make sure files are created in obj/. +# + +$cmd->run( args => 'obj', chdir => $cmd->curdir ); +is( $? >> 8, 0, 'make obj exit status' ); + +$cmd->run( chdir => $cmd->curdir ); + +like( $cmd->stdout, qr/.*/, 'make stdout' ); +is( $cmd->stderr, "", 'make stderr' ); +is( $? >> 8, 0, 'make exit status' ); + +file_exists_ok( $cmd->workdir . '/obj/a.html' ); +file_exists_ok( $cmd->workdir . '/obj/b.html' ); +file_exists_ok( $cmd->workdir . '/obj/c.html' );