]> granicus.if.org Git - fortune-mod/commitdiff
Fix the -m flag on Linux/etc.
authorShlomi Fish <shlomif@shlomifish.org>
Thu, 29 Dec 2016 12:32:46 +0000 (14:32 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Thu, 29 Dec 2016 12:32:46 +0000 (14:32 +0200)
fortune-mod/CMakeLists.txt
fortune-mod/tests/t/test-fortune-m.t [new file with mode: 0644]

index 76b23ef2727478018a278f6da5eb5f16e522481f..1957b53827ad0b6b9d9c88e66940ff97e12736f5 100644 (file)
@@ -133,6 +133,15 @@ ADD_DEFINITIONS("-DLOCFORTDIR=\"${LOCALDIR}\"")
 ADD_DEFINITIONS("-DOFFDIR=\"${OCOOKIEDIR}\"")
 ADD_DEFINITIONS("-DFORTDIR=\"${COOKIEDIR}\"")
 
+INCLUDE(CheckIncludeFile)
+CHECK_INCLUDE_FILE("regex.h" HAVE_REGEX_H)
+
+IF ("${HAVE_REGEX_H}")
+    ADD_DEFINITIONS("-DHAVE_REGEX_H")
+    ADD_DEFINITIONS("-DBSD_REGEX")
+ENDIF()
+
+ADD_DEFINITIONS("-DHAVE_STDBOOL")
 SET (COOKIES
     art
     ascii-art
diff --git a/fortune-mod/tests/t/test-fortune-m.t b/fortune-mod/tests/t/test-fortune-m.t
new file mode 100644 (file)
index 0000000..3967b92
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Path qw/mkpath rmtree/;
+use Cwd qw/getcwd/;
+
+use Test::More tests => 1;
+sub do_system
+{
+    my ($args) = @_;
+
+    my $cmd = $args->{cmd};
+    print "Running [@$cmd]\n";
+    if ( system(@$cmd) )
+    {
+        die "Running [@$cmd] failed!";
+    }
+}
+
+{
+    my $cwd = getcwd();
+    my $build_dir = "$cwd/fortune-m-build-dir";
+    my $inst_dir = "$cwd/fortune-m-INST_DIR";
+    rmtree($build_dir, 0, 0);
+    rmtree($inst_dir, 0, 0);
+    mkpath ($build_dir);
+    chdir $build_dir;
+    do_system({cmd => ['cmake', "-DCMAKE_INSTALL_PREFIX=$inst_dir", $ENV{SRC_DIR}]});
+    do_system({cmd => ['make']});
+    do_system({cmd => ['make', 'install',]});
+
+    my $text = `'$inst_dir/games/fortune' -m giants`;
+
+    # TEST
+    like ($text, qr/Newton/, 'fortune -m matched');
+}