ADD_DEFINITIONS("-DOFFDIR=\"${OCOOKIEDIR}\"")
ADD_DEFINITIONS("-DFORTDIR=\"${COOKIEDIR}\"")
+SET (COOKIES
+ art
+ ascii-art
+ computers
+ cookie
+ definitions
+ drugs
+ education
+ ethnic
+ food
+ fortunes
+ goedel
+ humorists
+ kids
+ law
+ linuxcookie
+ literature
+ love
+ magic
+ medicine
+ men-women
+ miscellaneous
+ news
+ people
+ pets
+ platitudes
+ politics
+ riddles
+ science
+ songs-poems
+ sports
+ startrek
+ translate-me
+ wisdom
+ work
+ linux
+ perl
+ knghtbrd
+ paradoxum
+ zippy
+ debian
+)
+
ADD_SUBDIRECTORY("datfiles")
+string (REPLACE ";" " " COOKIES_STR "${COOKIES}")
ADD_CUSTOM_TARGET(
"check"
- "perl" "${CMAKE_SOURCE_DIR}/run-tests.pl" "--src-dir" "${CMAKE_SOURCE_DIR}"
+ "perl" "${CMAKE_SOURCE_DIR}/run-tests.pl" "--src-dir" "${CMAKE_SOURCE_DIR}" "--cookies" "${COOKIES_STR}"
)
-SET (COOKIES
- art
- ascii-art
- computers
- cookie
- definitions
- drugs
- education
- ethnic
- food
- fortunes
- goedel
- humorists
- kids
- law
- linuxcookie
- literature
- love
- magic
- medicine
- men-women
- miscellaneous
- news
- people
- pets
- platitudes
- politics
- riddles
- science
- songs-poems
- sports
- startrek
- translate-me
- wisdom
- work
- linux
- perl
- knghtbrd
- paradoxum
- zippy
- debian
-)
-
FOREACH(c ${COOKIES})
SET(TARGET_NAME "cookie__${c}")
SET(DEST "${c}.dat")
use Getopt::Long qw/ GetOptions /;
my $src_dir;
+my $cookies_list_str;
GetOptions(
+ 'cookies=s' => \$cookies_list_str,
'src-dir=s' => \$src_dir,
) or die "could not parse options - $!";
}
local $ENV{SRC_DIR} = $src_dir;
+local $ENV{COOKIES} = $cookies_list_str;
sub do_system
{
my ($args) = @_;
my $cmd = $args->{cmd};
- print "Running [@$cmd]";
+ print "Running [@$cmd]\n";
if ( system(@$cmd) )
{
die "Running [@$cmd] failed!";
i="$1"
shift
-echo -n "Testing "$i" ..."
+echo -n "Testing \"$i\" ..."
if ! tail -n 1 "$i" | grep -q '^%$' ; then
echo " failed % check"
echo "Fortune cookie file does not end in a single %"
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+sub mytest
+{
+ foreach my $cookie (split/ /, $ENV{COOKIES})
+ {
+ if (system("sh", "$ENV{SRC_DIR}/tests/scripts/check-fortune-file.sh", "$ENV{SRC_DIR}/datfiles/$cookie") != 0)
+ {
+ fail("$cookie failed.");
+ return;
+ }
+ }
+ pass("All are ok.");
+}
+
+mytest();
+