commit f80debc8220863819c81d8de18abcd3c00fb8ad1
parent 4095b8c403bd04d2096d412eb6e2dea5aca44321
Author: Kyle Milz <krwmilz@gmail.com>
Date: Mon, 22 Nov 2021 16:21:45 +0000
t: add test for CP_OBJ multiple files
Diffstat:
A | t/cp_multiple.t | | | 55 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 55 insertions(+), 0 deletions(-)
diff --git a/t/cp_multiple.t b/t/cp_multiple.t
@@ -0,0 +1,55 @@
+#
+# Test when more than 1 file in CP_OBJ, obj/ and files exist.
+#
+use Modern::Perl;
+use Test::Cmd;
+use Test::File;
+use Test::More tests => 12;
+
+
+my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
+my $html_mk = $cmd->here . '/bsd.html.mk';
+
+$cmd->write( 'site.mk', <<EOF );
+BSDSRCDIR = /tmp
+BSDOBJDIR = destdir
+EOF
+
+$cmd->write( 'a.txt', 'some stuff here' );
+$cmd->write( 'b.txt', 'some more stuff here' );
+$cmd->subdir( 'destdir' );
+$cmd->write( 'Makefile', <<EOF );
+CP_OBJ = a.txt b.txt
+SRCS =
+
+.include "site.mk"
+.include "$html_mk"
+EOF
+
+#
+# Create obj/ directory.
+#
+my $o = ".*/obj -> destdir/";
+
+$cmd->run( args => 'obj', chdir => $cmd->curdir );
+like( $cmd->stdout, qr{$o}, 'make obj stdout' );
+is( $cmd->stderr, '', 'make obj stderr' );
+is( $? >> 8, 0, 'make obj exit status' );
+
+#
+# Default make target should copy the file.
+#
+$o = "cp .*/a.txt .*/obj/a.txt
+cp .*/b.txt .*/obj/b.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 . "/a.txt" );
+file_exists_ok( $cmd->workdir . "/b.txt" );
+file_exists_ok( $cmd->workdir . "/obj/a.txt" );
+file_exists_ok( $cmd->workdir . "/obj/b.txt" );
+file_contains_like( $cmd->workdir . '/obj/a.txt', qr/some stuff here/ );
+file_contains_like( $cmd->workdir . '/obj/b.txt', qr/some more stuff here/ );