From 3cc8cca4a903e2035f29d185d82a1145300fe405 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 8 Dec 2016 15:51:57 +0200 Subject: [PATCH] Start porting the tests to cmake. --- fortune-mod/CMakeLists.txt | 5 ++++ fortune-mod/Makefile | 2 +- fortune-mod/run-tests.pl | 31 +++++++++++++++++++++ fortune-mod/tests/trailing-space-and-CRs.pl | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 fortune-mod/run-tests.pl 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 = ( -- 2.40.0