From 66fb7f3ccb1926b56f594504da99cc8d5f1ec579 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Fri, 31 Mar 2023 13:22:15 +0200 Subject: test infra - Under -DNO_TAINT_SUPPORT skip tests that use -T or -t This patch uses a collection of heuristics to skip test files which would die on a perl compiled with -DNO_TAINT_SUPPORT but without -DSILENT_NO_TAINT_SUPPORT. -DNO_TAINT_SUPPORT disables taint support in a "safe" way, such that if you try to use taint mode with the -t or -T options an exception will be thrown informing you that the perl you are using does not support taint. (The related setting -DSILENT_NO_TAINT_SUPPORT disables taint support but causes the -t and -T options to be silently ignored.) The error from using -t and -T is thrown very early in the process startup and there is no way to "gracefully" handle it and convert it into something else, for instance to skip a test file which contains it. This patch generally fixes our code to skip these tests. * Make t/TEST and t/harness check shebang lines and use filename checks to filter out tests that use -t or -T. Primarily this is the result of checking their shebang line, but some cpan/ files are excluded by name, either from a very short list of exclusions, or because their file name contains the word "taint". Non-cpan test files were fixed individually as noted below. * test.pl - make run_multiple_progs() skip test cases based on the switches that are part of the test definition. This function is used in a great deal of our internal tests, so it fixes a lot of tests in one go. * XS-APITest/t/call.t, t/run/switchDX.t, lib/B/Deparse.t - Skip a small set of tests in each file. --- ext/XS-APItest/t/call.t | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/XS-APItest/t/call.t b/ext/XS-APItest/t/call.t index 390ed8de93..1116f286fb 100644 --- a/ext/XS-APItest/t/call.t +++ b/ext/XS-APItest/t/call.t @@ -14,7 +14,7 @@ BEGIN { plan(538); use_ok('XS::APItest') }; - +use Config; ######################### # f(): general test sub to be called by call_sv() etc. @@ -343,8 +343,11 @@ for my $fn_type (qw(eval_pv eval_sv call_sv)) { # DAPM 9-Aug-04. A taint test in eval_sv() could die after setting up # a new jump level but before pushing an eval context, leading to # stack corruption +SKIP: { + skip("Your perl was built without taint support", 1) + unless $Config{taint_support}; -fresh_perl_is(<<'EOF', "x=2", { switches => ['-T', '-I../../lib'] }, 'eval_sv() taint'); + fresh_perl_is(<<'EOF', "x=2", { switches => ['-T', '-I../../lib'] }, 'eval_sv() taint'); use XS::APItest; my $x = 0; @@ -357,4 +360,4 @@ sub f { eval { my @a = sort f 2, 1; $x++}; print "x=$x\n"; EOF - +} -- cgit v1.2.1