Skip to content

Commit

Permalink
Fix the taint checking tests (again)
Browse files Browse the repository at this point in the history
NO_TAINT comes in more than one flavour!
  $Config{taint_disabled} => undef
  - taint is enabled
  $Config{taint_disabled} => 'define'
  - taint is disabled, '-t', or '-T' will fail
  $Config{taint_disabled} => 'silent'
  - taint is disabled, '-t', or '-T' will be fine
  • Loading branch information
egiles committed Jul 17, 2023
1 parent e2a2399 commit 0d1c253
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Perl extension Test-Compile

v3.3.1 2023-07-17
- Fix 'silent, no taint' mode (which doesn't cause the compile to fail)

v3.3.0 2023-07-12
- Tests should pass, even if Taint mode is not compiled into perl
- Improve the documentation (@dirs was a terrible name)
Expand Down
2 changes: 1 addition & 1 deletion lib/Test/Compile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Test::Compile;
use warnings;
use strict;

use version; our $VERSION = version->declare("v3.3.0");
use version; our $VERSION = version->declare("v3.3.1");
use parent 'Exporter';
use Test::Compile::Internal;

Expand Down
2 changes: 1 addition & 1 deletion lib/Test/Compile/Internal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Test::Compile::Internal;
use warnings;
use strict;

use version; our $VERSION = version->declare("v3.3.0");
use version; our $VERSION = version->declare("v3.3.1");
use File::Find;
use File::Spec;
use Test::Builder;
Expand Down
13 changes: 9 additions & 4 deletions t/100-internal-pl-file-compiles.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ use Test::Compile::Internal;
my $internal = Test::Compile::Internal->new();
$internal->verbose(0);

# Is this perl capable of checking taint?
my $perl_can_check_taint = $Config{taint_disabled} ? 0 : 1;
# Is asking perl to check taint going to fail?
my $taint_checks_safe = 1;
if ( defined $Config{taint_disabled} ) {
if ( $Config{taint_disabled} eq "define" ) {
$taint_checks_safe = 0;
}
}

# Given (success.pl)
# When
Expand All @@ -23,13 +28,13 @@ is($yes, 1, "success.pl should compile");
# When
my $taint = $internal->pl_file_compiles('t/scripts/taint.pl');
# Then
is($taint, $perl_can_check_taint, "taint.pl should compile, with -T");
is($taint, $taint_checks_safe, "taint.pl should compile, with -T");

# Given (taint2.pl - script has -T in shebang)
# When
my $taint2 = $internal->pl_file_compiles('t/scripts/CVS/taint2.pl');
# Then
is($taint2, $perl_can_check_taint, "taint2.pl should compile, with -t");
is($taint2, $taint_checks_safe, "taint2.pl should compile, with -t");

# Given (failure.pl doesn't compile)
# When
Expand Down

0 comments on commit 0d1c253

Please sign in to comment.