commit d1d47df5078ddf457a7c094f174d363b9b1874d6
parent f80debc8220863819c81d8de18abcd3c00fb8ad1
Author: Kyle Milz <krwmilz@gmail.com>
Date: Mon, 22 Nov 2021 16:23:14 +0000
t: add test for SUBDIR unhappy paths
Diffstat:
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/t/subdir_unhappy.t b/t/subdir_unhappy.t
@@ -0,0 +1,43 @@
+#
+# SUBDIR Unhappy paths.
+#
+use Modern::Perl;
+use Test::Cmd;
+use Test::More tests => 6;
+
+
+my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
+my $html_mk = $cmd->here . "/bsd.html.mk";
+
+#
+# 1) SUBDIR does not exist
+#
+my $o = "===> dir_not_exist\n";
+my $e = 'make: chdir\(.*/dir_not_exist\): No such file or directory';
+
+$cmd->write( 'Makefile', <<EOF );
+SRCS =
+SUBDIR = dir_not_exist
+
+.include "$html_mk"
+EOF
+
+$cmd->run( chdir => $cmd->curdir );
+
+is( $cmd->stdout, $o, 'make stdout' );
+like( $cmd->stderr, qr{$e}, 'make stderr' );
+is( $? >> 8, 2, 'make exit status' );
+
+#
+# 2) SUBDIR is a file.
+#
+$o = "===> dir_not_exist\n";
+$e = 'make: chdir\(.*/dir_not_exist\): Not a directory';
+
+$cmd->write( 'dir_not_exist', '' );
+
+$cmd->run( chdir => $cmd->curdir );
+
+is( $cmd->stdout, $o, 'make stdout' );
+like( $cmd->stderr, qr{$e}, 'make stderr' );
+is( $? >> 8, 2, 'make exit status' );