From 69d5701bd7c5daad5572297b0333920e181766ec Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 23 Oct 2025 22:55:19 +0200 Subject: [PATCH 1/2] rename internal test module to not be 'Test2' Test2 is a real module (even though it has no functionality) so it is confusing to have a test script use the name for an internal test module. Rename the module to avoid the confusion. --- t/op/require_gh20577.t | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/t/op/require_gh20577.t b/t/op/require_gh20577.t index c3f6caeaad28..517e0c5e4cfd 100644 --- a/t/op/require_gh20577.t +++ b/t/op/require_gh20577.t @@ -12,18 +12,18 @@ eval <<'EOF' or die $@; { my %fatpacked; - $fatpacked{"Test1.pm"} = <<'TEST1'; - package Test1; + $fatpacked{"TestModule1.pm"} = <<'TEST1'; + package TestModule1; sub import { - my $filename = 'Test2.pm'; + my $filename = 'TestModule2.pm'; $INC{$filename} = "the_test_file"; } 1; TEST1 - $fatpacked{"Test2.pm"} = <<'TEST2'; - package Test2; - use Test1; + $fatpacked{"TestModule2.pm"} = <<'TEST2'; + package TestModule2; + use TestModule1; 1; TEST2 @@ -45,14 +45,14 @@ TEST2 EOF ok(UNIVERSAL::isa($INC[0],"FatPacked"), '$INC[0] starts FatPacked'); -ok(!exists $INC{"Test1.pm"}, 'Test1.pm not in %INC'); -ok(!exists $INC{"Test2.pm"}, 'Test2.pm not in %INC'); -my $ok= eval "use Test2; 1"; +ok(!exists $INC{"TestModule1.pm"}, 'TestModule1.pm not in %INC'); +ok(!exists $INC{"TestModule2.pm"}, 'TestModule2.pm not in %INC'); +my $ok= eval "use TestModule2; 1"; my $err= !$ok ? $@ : undef; -is($err,undef,"No error loading Test2"); -is($ok,1,"Loaded Test2 successfully"); +is($err,undef,"No error loading TestModule2"); +is($ok,1,"Loaded TestModule2 successfully"); ok(UNIVERSAL::isa($INC[0],"FatPacked"), '$INC[0] is still FatPacked'); -ok(UNIVERSAL::isa($INC{"Test1.pm"},"FatPacked"), '$INC{"Test1.pm"} is still FatPacked'); -is($INC{"Test2.pm"},"the_test_file", '$INC{"Test2.pm"} is as expected'); -is($INC[0],$INC{"Test1.pm"},'Same object in @INC and %INC'); +ok(UNIVERSAL::isa($INC{"TestModule1.pm"},"FatPacked"), '$INC{"TestModule1.pm"} is still FatPacked'); +is($INC{"TestModule2.pm"},"the_test_file", '$INC{"TestModule2.pm"} is as expected'); +is($INC[0],$INC{"TestModule1.pm"},'Same object in @INC and %INC'); done_testing(); From 4f1f1e2203f938d3123cfccb28fbacc96c68181d Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 23 Oct 2025 21:39:41 +0200 Subject: [PATCH 2/2] block Test2 in tests where Test::More isn't allowed Tests in t/ are generally not allowed to use Test::More or related modules. Instead, they are meant to use t/test.pl. There is a porting test to make sure they are not used. Test2 should be blocked in the same places that Test::More is. --- t/porting/test_bootstrap.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/porting/test_bootstrap.t b/t/porting/test_bootstrap.t index 53b31b8afbcf..e4f8463c08e4 100644 --- a/t/porting/test_bootstrap.t +++ b/t/porting/test_bootstrap.t @@ -39,7 +39,7 @@ while (my $file = <$fh>) { # but exclude this file from that test. unlike( $contents, - qr/use\s+Test::(?:Simple|More)/, + qr/use\s+(?:Test::(?:Simple|More|Builder)|Test2)/, "$file doesn't use Test::Simple or Test::More" ) unless ($file =~ m|porting/test_bootstrap\.t|); next unless $file =~ m!^base/! or $file =~ m!^comp!;