Skip to content

Commit 956bb01

Browse files
committed
fix "No fortunes found" error when asking for non-existent cookies collections filenames
1 parent 91e8a7b commit 956bb01

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

fortune-mod/fortune/fortune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ static int form_file_list(char **files, int file_cnt)
11341134
}
11351135
else
11361136
{
1137-
ret = 1;
1137+
ret = 0;
11381138
}
11391139
}
11401140
else if (strncmp(fullpathname, locpathname, sizeof(fullpathname)) &&

fortune-mod/tests/t/test-fortune-percent.t

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use lib "$FindBin::Bin/lib";
99
use FortTestInst ();
1010

1111
use Path::Tiny qw/ cwd path tempdir tempfile /;
12-
use Test::More tests => 9;
12+
use Test::More tests => 11;
1313
use Test::Trap
1414
qw( trap $trap :flow:stderr(systemsafe):stdout(systemsafe):warn );
1515

@@ -35,6 +35,29 @@ use Test::Trap
3535
}
3636
}
3737

38+
{
39+
my @cmd =
40+
( $inst_dir->child( 'games', 'fortune' ), "notexisttttttttttt" );
41+
42+
print "Running [@cmd]\n";
43+
trap
44+
{
45+
system(@cmd);
46+
};
47+
48+
{
49+
# TEST
50+
unlike( $trap->stdout(), qr/\S/ms, "No fortunes found", );
51+
52+
# TEST
53+
like(
54+
$trap->stderr(),
55+
qr/\ANo fortunes found/ms,
56+
"error message for No fortunes found",
57+
);
58+
}
59+
}
60+
3861
my @cmd = (
3962
$inst_dir->child( 'games', 'fortune' ),
4063
"999999999999999%", "songs-poems"

0 commit comments

Comments
 (0)