From: Shlomi Fish Date: Thu, 29 Dec 2016 12:32:46 +0000 (+0200) Subject: Fix the -m flag on Linux/etc. X-Git-Tag: fortune-mod-1.99.3~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e2064082df01f2238472e0daa34b3bb23e2d651;p=fortune-mod Fix the -m flag on Linux/etc. --- diff --git a/fortune-mod/CMakeLists.txt b/fortune-mod/CMakeLists.txt index 76b23ef..1957b53 100644 --- a/fortune-mod/CMakeLists.txt +++ b/fortune-mod/CMakeLists.txt @@ -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 index 0000000..3967b92 --- /dev/null +++ b/fortune-mod/tests/t/test-fortune-m.t @@ -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'); +}