Start porting the tests to cmake.
authorShlomi Fish <shlomif@shlomifish.org>
Thu, 8 Dec 2016 13:51:57 +0000 (15:51 +0200)
committerShlomi Fish <shlomif@shlomifish.org>
Thu, 8 Dec 2016 13:51:57 +0000 (15:51 +0200)
fortune-mod/CMakeLists.txt
fortune-mod/Makefile
fortune-mod/run-tests.pl [new file with mode: 0644]
fortune-mod/tests/trailing-space-and-CRs.pl

index 104bc922b1c44c1c4994a6f0b6b599d344560737..f1c50d68ad96b87398d8d342ef13b8367c07db39 100644 (file)
@@ -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}"
+)
index 480d60c245e46ee281fb0075299ba63e003199b2..c187dd87bfeddf6c7f45f524acda222af6e2b39a 100644 (file)
@@ -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 (file)
index 0000000..77f962a
--- /dev/null
@@ -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"]})
index 6cfef2a2c40646a34a6b83cded4b092f2258eb7c..7e61a5cf3b77d8d8790f0b0bc681bfc572536c1c 100644 (file)
@@ -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 =
 (