From 86ba4921477b92e8918e5c6288218c5c150b9873 Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 10 Apr 2015 19:44:13 +0100 Subject: [PATCH 1/5] Add Travis case for testing not blib but installed --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c881540c..2cbb31fd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ matrix: env: COVERAGE=1 - perl: "5.20" env: EUMM_BLEAD=1 + - perl: "5.20" + env: TEST_INSTALLED=1 # test not from blib but after installing - perl: "5.10" - perl: "5.12" - perl: "5.14" @@ -57,14 +59,15 @@ before_install: - cd $BUILD_DIR # $BUILD_DIR is set by the build-dist command install: - cpan-install --deps # installs prereqs, including recommends - - cpan-install --coverage # installs converage prereqs, if enabled + - cpan-install --coverage # installs coverage prereqs, if enabled - prove t/00-report-prereqs.t t/01-checkmanifest.t # SYSTEM_CORES set by travis-perl-helpers - if [ "$SERIAL_BUILD" == 1 ]; then make; else make -j$(( $SYSTEM_CORES * 2 )); fi before_script: - coverage-setup script: - - if [ "$SERIAL_TESTING" == 1 ]; then prove -b -v $(test-files); else prove --formatter TAP::Formatter::File -j$(test-jobs) -b -v $(test-files); fi + - export PROVE_FLAG=""; if [ "$TEST_INSTALLED" == 1 ]; then make install clean; mv Basic Basic.x; mv ../Basic ../Basic.x; else PROVE_FLAG="-b -v"; fi # clean is to ensure no blib, mv to ensure doesn't think is in repo! + - if [ "$SERIAL_TESTING" == 1 ]; then prove $PROVE_FLAG $(test-files); else prove --formatter TAP::Formatter::File -j$(test-jobs) $PROVE_FLAG $(test-files); fi after_script: - perl -Iblib/lib -MPDL::Config -MData::Dumper -e 'print Dumper \%PDL::Config' after_success: From 4947a1d6af6cb57c81e50e9b60c70cbabef4f19c Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 10 Apr 2015 21:47:37 +0100 Subject: [PATCH 2/5] Have t/inline* not "use blib" as test framework does that --- t/inline-comment-test.t | 3 +-- t/inline-with.t | 3 +-- t/inlinepdlpp.t | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/t/inline-comment-test.t b/t/inline-comment-test.t index 6ceb6905a..1e5902b3d 100644 --- a/t/inline-comment-test.t +++ b/t/inline-comment-test.t @@ -5,9 +5,8 @@ # -- DCM, April 16, 2012 use strict; +use warnings; use Test::More; -use blib; # otherwise possible error on virgin systems not finding PDL::Core - use PDL::LiteF; # First some Inline administivia. diff --git a/t/inline-with.t b/t/inline-with.t index f1efe99ba..58edc2568 100644 --- a/t/inline-with.t +++ b/t/inline-with.t @@ -2,9 +2,8 @@ # Also that the XS code in PDL::API works. use strict; +use warnings; use Test::More; -use blib; # otherwise possible error on virgin systems not finding PDL::Core - use PDL::LiteF; my $inline_test_dir; diff --git a/t/inlinepdlpp.t b/t/inlinepdlpp.t index 4cdbd9878..386b89cee 100644 --- a/t/inlinepdlpp.t +++ b/t/inlinepdlpp.t @@ -1,7 +1,6 @@ use strict; +use warnings; use Test::More; -use blib; # otherwise possible error on virgin systems not finding PDL::Core - use PDL::LiteF; BEGIN { From c53c2a67c8dd9e0fe418bd4436562eaec120b535 Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 10 Apr 2015 22:34:14 +0100 Subject: [PATCH 3/5] Idiomatic Test::More use in t/inlinepdlpp.t --- t/inlinepdlpp.t | 58 +++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/t/inlinepdlpp.t b/t/inlinepdlpp.t index 386b89cee..5accdf504 100644 --- a/t/inlinepdlpp.t +++ b/t/inlinepdlpp.t @@ -1,45 +1,18 @@ use strict; use warnings; -use Test::More; +use Test::More tests => 5; use PDL::LiteF; -BEGIN { - # clean out the _Inline directory on every test - # (may be OTT but ensures that we're always testing the latest code) - # - # require File::Path; - # File::Path::rmtree (["_Inline", ".Inline"], 0, 0); - - # Test for Inline and set options - my $inline_test_dir = './.inlinepdlpp'; - mkdir $inline_test_dir unless -d $inline_test_dir; - eval 'use Inline (Config => DIRECTORY => $inline_test_dir , FORCE_BUILD => 1)'; - plan skip_all => "Skipped: Inline not installed" if $@; - diag "Inline Version: $Inline::VERSION\n"; - eval 'use Inline 0.43'; - plan skip_all => "Skipped: not got Inline >= 0.43" if $@; - plan tests => 3; -} - -sub myshape { join ',', $_[0]->dims } - -# use Inline 'INFO'; # use to generate lots of info -use Inline 'Pdlpp'; - -ok(1); # ok, we made it so far - -$a = sequence(3,3); - -$b = $a->testinc; - -ok(myshape($a) eq myshape($b)); - -ok(all $b == $a+1); - -__DATA__ - -__Pdlpp__ - +my $inline_test_dir = './.inlinepdlpp'; +mkdir $inline_test_dir unless -d $inline_test_dir; +SKIP: { + use_ok('Inline', Config => DIRECTORY => $inline_test_dir, FORCE_BUILD => 1) + || skip "Skipped: Inline not installed", 4; + note "Inline Version: $Inline::VERSION\n"; + eval { Inline->VERSION(0.43) }; + is $@, '', 'at least 0.43' or skip "Skipped: not got Inline >= 0.43", 3; + # use Inline 'INFO'; # use to generate lots of info + eval { Inline->bind(Pdlpp => <<'EOF') }; # simple PP definition pp_def('testinc', @@ -48,3 +21,12 @@ pp_def('testinc', ); # this tests the bug with a trailing comment and *no* newline +EOF + is $@, '', 'bind no error' or skip "bind failed", 2; + my $x = sequence(3,3); + my $y = $x->testinc; + is myshape($x), myshape($y), 'myshape eq'; + ok(all $y == $x+1, '=='); +} + +sub myshape { join ',', $_[0]->dims } From d3f4641706041c1c25e0f2de9fa6205918b6eae2 Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 10 Apr 2015 22:44:24 +0100 Subject: [PATCH 4/5] Idiomatic Test::More use in t/inline-with.t --- t/inline-with.t | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/t/inline-with.t b/t/inline-with.t index 58edc2568..4b797c06b 100644 --- a/t/inline-with.t +++ b/t/inline-with.t @@ -36,27 +36,12 @@ END { } } } -# rmtree $inline_test_dir if -d $inline_test_dir; } -#use Inline 'INFO'; # use to generate lots of info -use Inline with => 'PDL'; -use Inline 'C'; - -note "Inline Version: $Inline::VERSION\n"; -ok 1, 'compiled'; - -my $pdl = myfloatseq(); -note $pdl->info,"\n"; - -is $pdl->dims, 3, 'dims correct'; - -done_testing; - -__DATA__ - -__C__ - +SKIP: { + #use Inline 'INFO'; # use to generate lots of info + use_ok 'Inline', with => 'PDL' or skip 'with PDL failed', 3; + eval { Inline->bind(C => <<'EOF') }; static pdl* new_pdl(int datatype, PDL_Indx dims[], int ndims) { pdl *p = PDL->pdlnew(); @@ -78,3 +63,16 @@ pdl* myfloatseq() dataf[i] = i; /* the data must be initialized ! */ return p; } +EOF + is $@, '', 'bind no error' or skip 'Inline C failed', 2; + + note "Inline Version: $Inline::VERSION\n"; + ok 1, 'compiled'; + + my $pdl = myfloatseq(); + note $pdl->info,"\n"; + + is $pdl->dims, 3, 'dims correct'; +} + +done_testing; From 75732eb07ff4ef800c039ec768fe57b32d8f55c5 Mon Sep 17 00:00:00 2001 From: Ed J Date: Fri, 10 Apr 2015 22:52:29 +0100 Subject: [PATCH 5/5] Idiomatic Test::More use in t/inline-comment-test.t --- t/inline-comment-test.t | 48 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/t/inline-comment-test.t b/t/inline-comment-test.t index 1e5902b3d..353744e64 100644 --- a/t/inline-comment-test.t +++ b/t/inline-comment-test.t @@ -40,33 +40,9 @@ BEGIN { plan tests => 3; } +SKIP: { # use Inline 'INFO'; # use to generate lots of info -use Inline 'Pdlpp'; - -print "Inline Version: $Inline::VERSION\n"; -ok(1, 'Everything seems to have compiled'); - -$a = sequence(3,3); - -$b = $a->testinc; - -ok(all ($b == $a+1), 'Sanity check runs correctly'); - -# Test the inability to comment-out a threadloop. This is documented on the -# 11th page of the PDL::PP chapter of the PDL book. If somebody ever fixes this -# wart, this test will fail, in which case the book's text should be updated. -$b = $a->testinc2; -TODO: { - # Note: This test appears to fail on Cygwin and some flavors of Linux. - local $TODO = 'This test inexplicably passes on some machines'; - ok(not (all $b == $a + 1), 'WART: commenting out a threadloop does not work') - or diag("\$a is $a and \$b is $b"); -} - -__DATA__ - -__Pdlpp__ - +eval { Inline->bind(Pdlpp => <<'EOF') }; # simple PP definition with user irritation tests :-) pp_def('testinc', @@ -107,3 +83,23 @@ pp_def('testinc2', }, ); +EOF +is $@, '', 'compiled' or skip 'bind failed', 2; + +$a = sequence(3,3); + +$b = $a->testinc; + +ok(all ($b == $a+1), 'Sanity check runs correctly'); + +# Test the inability to comment-out a threadloop. This is documented on the +# 11th page of the PDL::PP chapter of the PDL book. If somebody ever fixes this +# wart, this test will fail, in which case the book's text should be updated. +$b = $a->testinc2; +TODO: { + # Note: This test appears to fail on Cygwin and some flavors of Linux. + local $TODO = 'This test inexplicably passes on some machines'; + ok(not (all $b == $a + 1), 'WART: commenting out a threadloop does not work') + or diag("\$a is $a and \$b is $b"); +} +}