Skip to content

Commit

Permalink
use FindBin in tests
Browse files Browse the repository at this point in the history
perl 5.26 won't have . in @inc anymore.
  • Loading branch information
perlpunk committed May 16, 2017
1 parent dac1422 commit c676071
Show file tree
Hide file tree
Showing 26 changed files with 82 additions and 36 deletions.
3 changes: 2 additions & 1 deletion test/01syntax.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/02config.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
9 changes: 7 additions & 2 deletions test/03typemap.t
@@ -1,11 +1,16 @@
use strict; use warnings; use diagnostics;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my $t;
BEGIN {
$t = $Bin;
}
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

use Inline C => DATA =>
TYPEMAPS => File::Spec->catfile(File::Spec->curdir(), $t, 'typemap');
TYPEMAPS => File::Spec->catfile($t, 'typemap');

is(int((add_em_up(1.2, 3.4) + 0.001) * 10), 46);

Expand Down
3 changes: 2 additions & 1 deletion test/04perlapi.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/05xsmode.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/06parseregexp.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
4 changes: 3 additions & 1 deletion test/07typemap_multi.t
@@ -1,5 +1,7 @@
use strict; use warnings; use diagnostics;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my $t = $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
18 changes: 12 additions & 6 deletions test/08taint.t
Expand Up @@ -12,7 +12,15 @@ BEGIN {
}

use warnings; use strict;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
my $bin;
BEGIN {
# untaint
($bin) = $Bin =~ m/(.*)/;
}
my $t = $bin;
use lib $bin;

use Test::More tests => 10;
use Test::Warn;
use TestInlineSetup;
Expand All @@ -30,15 +38,13 @@ warnings_like {require_taint_2()} [qr/$w1/, qr/$w2/, qr/$w1/, qr/$w3/], 'warn_te
warnings_like {require_taint_3()} [qr/$w1/, qr/$w2/, qr/$w1/, qr/$w3/, qr/$w1/, qr/$w2/, qr/$w1/, qr/$w3/], 'warn_test 3';

sub require_taint_1 {
require "./$t/08taint_1.p";
require "$t/08taint_1.p";
}

sub require_taint_2 {
my $t = -d 'test' ? 'test' : 't';
require "./$t/08taint_2.p";
require "$t/08taint_2.p";
}

sub require_taint_3 {
my $t = -d 'test' ? 'test' : 't';
require "./$t/08taint_3.p";
require "$t/08taint_3.p";
}
3 changes: 2 additions & 1 deletion test/09parser.t
Expand Up @@ -27,7 +27,8 @@ BEGIN {
};

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
4 changes: 3 additions & 1 deletion test/10callback.t
Expand Up @@ -3,7 +3,9 @@
# This test script plagiarises the perlcall documentation.

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
my $t = $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/11default_readonly.t
Expand Up @@ -2,7 +2,8 @@
# Thanks Marty O'Brien.

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
3 changes: 2 additions & 1 deletion test/14void_arg.t
@@ -1,5 +1,6 @@
use strict; use warnings;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use diagnostics;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/14void_arg_PRD.t
Expand Up @@ -2,7 +2,8 @@
# Tests 4 onwards are not expected to pass - so we make them TODO.

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/15ccflags.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Config;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
3 changes: 2 additions & 1 deletion test/16ccflagsex.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Config;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
7 changes: 6 additions & 1 deletion test/17prehead.t
@@ -1,5 +1,10 @@
use strict; use warnings; use diagnostics;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my$t;
BEGIN {
$t = $Bin;
}
use TestInlineSetup;
use Config;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
12 changes: 8 additions & 4 deletions test/19INC.t
@@ -1,13 +1,17 @@
use strict; use warnings; use diagnostics;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my $t;
BEGIN {
$t = $Bin;
}
use Cwd;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

BEGIN {
my $cwd = Cwd::getcwd();
my $incdir1 = $cwd . "/$t/foo/";
my $incdir2 = $cwd . "/$t/bar/";
my $incdir1 = "$t/foo/";
my $incdir2 = "$t/bar/";
$main::includes = "-I$incdir1 -I$incdir2";
};

Expand Down
3 changes: 2 additions & 1 deletion test/20eval.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
3 changes: 2 additions & 1 deletion test/21read_DATA.t
Expand Up @@ -2,7 +2,8 @@
# The bug existed up to and including Inline-0.52.

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
3 changes: 2 additions & 1 deletion test/22read_DATA_2.t
Expand Up @@ -2,7 +2,8 @@
# The bug existed up to and including Inline-0.52.

use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
3 changes: 2 additions & 1 deletion test/24prefix.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Config;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand Down
4 changes: 3 additions & 1 deletion test/25proto.t
@@ -1,5 +1,7 @@
use strict; use warnings;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my $t = $Bin;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;

Expand Down
3 changes: 2 additions & 1 deletion test/26fork.t
@@ -1,5 +1,6 @@
use strict; use warnings;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Test::More;
use Config;
Expand Down
3 changes: 2 additions & 1 deletion test/27inline_maker.t
@@ -1,5 +1,6 @@
use strict; use warnings; use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Test::More;
use Config;
Expand Down
4 changes: 3 additions & 1 deletion test/28autowrap.t
@@ -1,5 +1,7 @@
use strict; use warnings; use diagnostics;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use FindBin '$Bin';
use lib $Bin;
my $t = $Bin;
use TestInlineSetup;
use Inline config => directory => $TestInlineSetup::DIR;
use Test::More;
Expand Down
5 changes: 3 additions & 2 deletions test/30cppflags.t
@@ -1,7 +1,8 @@
use strict;
use warnings;
use diagnostics;
use lib -e 't' ? 't' : 'test';
use FindBin '$Bin';
use lib $Bin;
use TestInlineSetup;
use Config;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
Expand All @@ -28,4 +29,4 @@ if ( $foo_retval == 4321 ) {
else {
warn "\n Expected: 4321\n Got: $foo_retval\n";
print "not ok 1\n";
}
}

0 comments on commit c676071

Please sign in to comment.