From: Shlomi Fish Date: Thu, 8 Dec 2016 13:51:57 +0000 (+0200) Subject: Start porting the tests to cmake. X-Git-Tag: fortune-mod-1.99.3~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cc8cca4a903e2035f29d185d82a1145300fe405;p=fortune-mod Start porting the tests to cmake. --- diff --git a/fortune-mod/CMakeLists.txt b/fortune-mod/CMakeLists.txt index 104bc92..f1c50d6 100644 --- a/fortune-mod/CMakeLists.txt +++ b/fortune-mod/CMakeLists.txt @@ -122,3 +122,8 @@ ADD_DEFINITIONS("-DOFFDIR=\"${OCOOKIEDIR}\"") ADD_DEFINITIONS("-DFORTDIR=\"${COOKIEDIR}\"") ADD_SUBDIRECTORY("datfiles") + +ADD_CUSTOM_TARGET( + "check" + "perl" "${CMAKE_SOURCE_DIR}/run-tests.pl" "--src-dir" "${CMAKE_SOURCE_DIR}" +) diff --git a/fortune-mod/Makefile b/fortune-mod/Makefile index 480d60c..c187dd8 100644 --- a/fortune-mod/Makefile +++ b/fortune-mod/Makefile @@ -185,7 +185,7 @@ datfiles-check: cookies-z cd datfiles && $(DATFILES_MAKE) check root-check: - perl tests/trailing-space-and-CRs.pl + SRC_DIR=. perl tests/trailing-space-and-CRs.pl tap-check: prove tests/t/*.t diff --git a/fortune-mod/run-tests.pl b/fortune-mod/run-tests.pl new file mode 100644 index 0000000..77f962a --- /dev/null +++ b/fortune-mod/run-tests.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Getopt::Long qw/ GetOptions /; + +my $src_dir; +GetOptions( + 'src-dir=s' => \$src_dir, +) or die "could not parse options - $!"; + +if (!defined $src_dir) +{ + die "--src-dir was not defined"; +} + +local $ENV{SRC_DIR} = $src_dir; + +sub do_system +{ + my ($args) = @_; + + my $cmd = $args->{cmd}; + print "Running [@$cmd]"; + if ( system(@$cmd) ) + { + die "Running [@$cmd] failed!"; + } +} +do_system({cmd => [$^X , "$src_dir/tests/trailing-space-and-CRs.pl"]}) diff --git a/fortune-mod/tests/trailing-space-and-CRs.pl b/fortune-mod/tests/trailing-space-and-CRs.pl index 6cfef2a..7e61a5c 100644 --- a/fortune-mod/tests/trailing-space-and-CRs.pl +++ b/fortune-mod/tests/trailing-space-and-CRs.pl @@ -6,7 +6,7 @@ use warnings; use File::Find::Object; use IO::All qw/ io /; -my $tree = File::Find::Object->new({}, '.'); +my $tree = File::Find::Object->new({}, $ENV{SRC_DIR}); my %do_not_check = (