From 5781e585779d72e4beed2723e31f7e9a35c3b297 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 16 May 2022 20:39:51 +0200 Subject: [PATCH 1/5] MANIFEST is not executable --- MANIFEST | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 MANIFEST diff --git a/MANIFEST b/MANIFEST old mode 100755 new mode 100644 From 74c6aed92a49259cf86cc663dfa250cc2b84c416 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 27 May 2022 14:17:18 +0200 Subject: [PATCH 2/5] add Test::More as a test prereq Test::More is already used by GetOSName.t, so it should be listed as a prereq. --- Makefile.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.PL b/Makefile.PL index 90ad660..dfab1f1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -33,6 +33,7 @@ my $test_requires = $ExtUtils::MakeMaker::VERSION >= 6.64 : 'PREREQ_PM'; $param{$test_requires}{'Test'} = 0; +$param{$test_requires}{'Test::More'} = 0; $param{$test_requires}{'File::Temp'} = 0; WriteMakefile(%param); From e25cdb0907c0bb8a8e34babbc3297ddd00453217 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 16 May 2022 20:46:44 +0200 Subject: [PATCH 3/5] convert most tests to Test::More --- t/CodePage.t | 4 +-- t/CreateFile.t | 6 ++-- t/ExpandEnvironmentStrings.t | 6 ++-- t/GetFileVersion.t | 9 +++--- t/GetFolderPath.t | 6 ++-- t/GetFullPathName.t | 36 ++++++++++------------ t/GetLongPathName.t | 8 ++--- t/GetOSVersion.t | 7 ++--- t/GetShortPathName.t | 9 +++--- t/GuidGen.t | 8 ++--- t/HttpGetFile.t | 60 +++++++++++++++++------------------- t/Names.t | 8 ++--- t/Privileges.t | 39 +++++++++++++---------- t/Unicode.t | 23 ++++++++------ 14 files changed, 105 insertions(+), 124 deletions(-) diff --git a/t/CodePage.t b/t/CodePage.t index 75741cc..ac768a2 100644 --- a/t/CodePage.t +++ b/t/CodePage.t @@ -1,9 +1,7 @@ use strict; -use Test; +use Test::More tests => 8; use Win32; -plan tests => 8; - my $ansicp = Win32::GetACP(); ok($ansicp > 0 && $ansicp <= 65001); diff --git a/t/CreateFile.t b/t/CreateFile.t index ee1bf46..46da3c3 100644 --- a/t/CreateFile.t +++ b/t/CreateFile.t @@ -1,13 +1,11 @@ use strict; -use Test; +use Test::More tests => 15; use Win32; my $path = "testing-$$"; rmdir($path) if -d $path; unlink($path) if -f $path; -plan tests => 15; - ok(!-d $path); ok(!-f $path); @@ -22,7 +20,7 @@ ok(!-d $path); ok(Win32::CreateFile($path)); ok(-f $path); -ok(-s $path, 0); +is(-s $path, 0); ok(!Win32::CreateDirectory($path)); ok(!Win32::CreateFile($path)); diff --git a/t/ExpandEnvironmentStrings.t b/t/ExpandEnvironmentStrings.t index b57b47c..58543ea 100644 --- a/t/ExpandEnvironmentStrings.t +++ b/t/ExpandEnvironmentStrings.t @@ -1,7 +1,5 @@ use strict; -use Test; +use Test::More tests => 1; use Win32; -plan tests => 1; - -ok(Win32::ExpandEnvironmentStrings("%WINDIR%"), $ENV{WINDIR}); +is(Win32::ExpandEnvironmentStrings("%WINDIR%"), $ENV{WINDIR}); diff --git a/t/GetFileVersion.t b/t/GetFileVersion.t index b9e51f8..13e674e 100644 --- a/t/GetFileVersion.t +++ b/t/GetFileVersion.t @@ -1,10 +1,9 @@ use strict; -use Test; +use Test::More; use Win32; unless (defined &Win32::BuildNumber) { - print "1..0 # Skip: Only ActivePerl seems to set the perl.exe fileversion\n"; - exit; + plan skip_all => 'Only ActivePerl seems to set the perl.exe fileversion'; } plan tests => 2; @@ -13,6 +12,6 @@ my @version = Win32::GetFileVersion($^X); my $version = $version[0] + $version[1] / 1000 + $version[2] / 1000000; # numify $] because it is a version object in 5.10 which will stringify with trailing 0s -ok($version, 0+$]); +is($version, 0+$]); -ok($version[3], int(Win32::BuildNumber())); +is($version[3], int(Win32::BuildNumber())); diff --git a/t/GetFolderPath.t b/t/GetFolderPath.t index c010c25..6c322b2 100644 --- a/t/GetFolderPath.t +++ b/t/GetFolderPath.t @@ -1,8 +1,6 @@ use strict; -use Test; +use Test::More tests => 1; use Win32; -plan tests => 1; - # "windir" exists back to Win9X; "SystemRoot" only exists on WinNT and later. -ok(Win32::GetFolderPath(Win32::CSIDL_WINDOWS), $ENV{WINDIR}); +is(Win32::GetFolderPath(Win32::CSIDL_WINDOWS), $ENV{WINDIR}); diff --git a/t/GetFullPathName.t b/t/GetFullPathName.t index db1dc82..1f37f1b 100644 --- a/t/GetFullPathName.t +++ b/t/GetFullPathName.t @@ -1,34 +1,32 @@ use strict; -use Test; +use Test::More tests => 16; use Win32; -plan tests => 16; - my $cwd = Win32::GetCwd; my @cwd = split/\\/, $cwd; my $file = pop @cwd; my $dir = join('\\', @cwd); -ok(scalar Win32::GetFullPathName('.'), $cwd); -ok((Win32::GetFullPathName('.'))[0], "$dir\\"); -ok((Win32::GetFullPathName('.'))[1], $file); +is(scalar Win32::GetFullPathName('.'), $cwd); +is((Win32::GetFullPathName('.'))[0], "$dir\\"); +is((Win32::GetFullPathName('.'))[1], $file); -ok((Win32::GetFullPathName('./'))[0], "$cwd\\"); -ok((Win32::GetFullPathName('.\\'))[0], "$cwd\\"); -ok((Win32::GetFullPathName('./'))[1], ""); +is((Win32::GetFullPathName('./'))[0], "$cwd\\"); +is((Win32::GetFullPathName('.\\'))[0], "$cwd\\"); +is((Win32::GetFullPathName('./'))[1], ""); -ok(scalar Win32::GetFullPathName($cwd), $cwd); -ok((Win32::GetFullPathName($cwd))[0], "$dir\\"); -ok((Win32::GetFullPathName($cwd))[1], $file); +is(scalar Win32::GetFullPathName($cwd), $cwd); +is((Win32::GetFullPathName($cwd))[0], "$dir\\"); +is((Win32::GetFullPathName($cwd))[1], $file); -ok(scalar Win32::GetFullPathName(substr($cwd,2)), $cwd); -ok((Win32::GetFullPathName(substr($cwd,2)))[0], "$dir\\"); -ok((Win32::GetFullPathName(substr($cwd,2)))[1], $file); +is(scalar Win32::GetFullPathName(substr($cwd,2)), $cwd); +is((Win32::GetFullPathName(substr($cwd,2)))[0], "$dir\\"); +is((Win32::GetFullPathName(substr($cwd,2)))[1], $file); -ok(scalar Win32::GetFullPathName('/Foo Bar/'), substr($cwd,0,2)."\\Foo Bar\\"); +is(scalar Win32::GetFullPathName('/Foo Bar/'), substr($cwd,0,2)."\\Foo Bar\\"); chdir(my $dird = $dir !~ /^[A-Z]:$/ ? $dir : "$dir\\"); -ok(scalar Win32::GetFullPathName('.'), $dird); +is(scalar Win32::GetFullPathName('.'), $dird); -ok((Win32::GetFullPathName($file))[0], "$dir\\"); -ok((Win32::GetFullPathName($file))[1], $file); +is((Win32::GetFullPathName($file))[0], "$dir\\"); +is((Win32::GetFullPathName($file))[1], $file); diff --git a/t/GetLongPathName.t b/t/GetLongPathName.t index 5019a2b..45058c2 100644 --- a/t/GetLongPathName.t +++ b/t/GetLongPathName.t @@ -1,5 +1,5 @@ use strict; -use Test; +use Test::More; use Win32; my @paths = qw( @@ -43,11 +43,7 @@ my %expect; plan tests => scalar(@paths); -my $i = 1; for (@paths) { my $got = Win32::GetLongPathName($_); - print "# '$_' => expect '$expect{$_}' => got '$got'\n"; - print "not " unless $expect{$_} eq $got; - print "ok $i\n"; - ++$i; + is $expect{$_}, $got; } diff --git a/t/GetOSVersion.t b/t/GetOSVersion.t index cb3f364..86a88f1 100644 --- a/t/GetOSVersion.t +++ b/t/GetOSVersion.t @@ -1,11 +1,8 @@ use strict; -use Test; +use Test::More tests => 1; use Win32; -plan tests => 1; - my $scalar = Win32::GetOSVersion(); my @array = Win32::GetOSVersion(); -print "not " unless $scalar == $array[4]; -print "ok 1\n"; +is $scalar, $array[4]; diff --git a/t/GetShortPathName.t b/t/GetShortPathName.t index 649420a..d19f4a1 100644 --- a/t/GetShortPathName.t +++ b/t/GetShortPathName.t @@ -1,5 +1,4 @@ use strict; -use Test; use Win32; BEGIN { @@ -8,21 +7,21 @@ BEGIN { unlink("8dot3test_canary_GetShortPathName $$"); if ( length $canary > 12 ) { print "1..0 # Skip: The system and/or current volume is not configured to support short names.\n"; - exit 0; + exit 0; } } +use Test::More tests => 5; + my $path = "Long Path $$"; unlink($path); END { unlink $path } -plan tests => 5; - Win32::CreateFile($path); ok(-f $path); my $short = Win32::GetShortPathName($path); -ok($short, qr/^\S{1,8}(\.\S{1,3})?$/); +like($short, qr/^\S{1,8}(\.\S{1,3})?$/); ok(-f $short); unlink($path); diff --git a/t/GuidGen.t b/t/GuidGen.t index 7011e2f..5469f53 100644 --- a/t/GuidGen.t +++ b/t/GuidGen.t @@ -1,15 +1,13 @@ use strict; -use Test; +use Test::More tests => 3; use Win32; -plan tests => 3; - my $guid1 = Win32::GuidGen(); my $guid2 = Win32::GuidGen(); # {FB9586CD-273B-43BE-A20C-485A6BD4FCD6} -ok($guid1, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); -ok($guid2, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); +like($guid1, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); +like($guid2, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); # Every GUID is unique ok($guid1 ne $guid2); diff --git a/t/HttpGetFile.t b/t/HttpGetFile.t index 0a16aab..21ce88c 100644 --- a/t/HttpGetFile.t +++ b/t/HttpGetFile.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test; +use Test::More; use Win32; use Digest::SHA; @@ -8,8 +8,7 @@ my $tmpfile = "http-download-test-$$.tgz"; END { 1 while unlink $tmpfile; } unless (defined &Win32::HttpGetFile) { - print "1..0 # Skip: gcc before 4.8 does not have winhttp library\n"; - exit; + plan skip_all => 'gcc before 4.8 does not have winhttp library'; } # We can only verify specific error messages with a known locale. @@ -35,67 +34,66 @@ sub HttpGetFileList { return ($ok, $message); } -ok(HttpGetFile('nonesuch://example.com', 'NUL:'), "", "'nonesuch://' is not a real protocol"); -ok($LastError, '12006', "correct error code for unrecognized protocol"); -ok(HttpGetFile('http://!#@!&@$', 'NUL:'), "", "invalid URL"); -ok($LastError, '12005', "correct error code for invalid URL"); +is(HttpGetFile('nonesuch://example.com', 'NUL:'), "", "'nonesuch://' is not a real protocol"); +is($LastError, '12006', "correct error code for unrecognized protocol"); +is(HttpGetFile('http://!#@!&@$', 'NUL:'), "", "invalid URL"); +is($LastError, '12005', "correct error code for invalid URL"); my ($ok, $message) = HttpGetFileList('nonesuch://example.com', 'NUL:'); -ok($ok, "", "'nonesuch://' is not a real protocol"); -if ($english_locale) { - ok($message, "The URL does not use a recognized protocol\r\n", "correct bad protocol message"); -} -else { - skip("Cannot verify error on non-English locale setting"); +is($ok, "", "'nonesuch://' is not a real protocol"); +SKIP: { + skip "Cannot verify error on non-English locale setting", 1 + if $english_locale; + + is($message, "The URL does not use a recognized protocol\r\n", "correct bad protocol message"); } -ok($LastError, '12006', "correct error code for unrecognized protocol with list context return"); +is($LastError, '12006', "correct error code for unrecognized protocol with list context return"); if ($ENV{PERL_WIN32_INTERNET_OK}) { # The digest for version 0.57 should obviously stay the same even after new versions are released - ok(Win32::HttpGetFile('https://cpan.metacpan.org/authors/id/J/JD/JDB/Win32-0.57.tar.gz', $tmpfile), + is(Win32::HttpGetFile('https://cpan.metacpan.org/authors/id/J/JD/JDB/Win32-0.57.tar.gz', $tmpfile), '1', "successfully downloaded a tarball"); my $sha = Digest::SHA->new('sha1'); $sha->addfile($tmpfile, 'b'); - ok($sha->hexdigest, + is($sha->hexdigest, '44a6d7d1607d7267b0dbcacbb745cec204f1c1a4', "downloaded tarball has correct digest"); my ($ok, $message) = HttpGetFileList('https://cpan.metacpan.org/authors/id/Z/ZZ/ZILCH/nonesuch.tar.gz', 'NUL:'); - ok($ok, '', 'Download of nonexistent file from real site should fail with 404'); - ok($LastError - 1e9, '404', 'Correct 404 HTTP status for not found'); - if ($english_locale) { - ok($message, 'Not Found', 'Should get text of 404 message'); - } - else { - skip("Cannot verify error on non-English locale setting"); + is($ok, '', 'Download of nonexistent file from real site should fail with 404'); + is($LastError - 1e9, '404', 'Correct 404 HTTP status for not found'); + SKIP: { + skip "Cannot verify error on non-English locale setting", 1 + if $english_locale; + is($message, 'Not Found', 'Should get text of 404 message'); } # Since all GitHub downloads use redirects, we can test that they work. 1 while unlink $tmpfile; - ok(Win32::HttpGetFile('https://github.com/perl-libwin32/win32/archive/refs/tags/v0.57.zip', $tmpfile), + is(Win32::HttpGetFile('https://github.com/perl-libwin32/win32/archive/refs/tags/v0.57.zip', $tmpfile), '1', "successfully downloaded a zipball via redirect"); $sha = Digest::SHA->new('sha1'); $sha->addfile($tmpfile, 'b'); - ok($sha->hexdigest, + is($sha->hexdigest, '9d282e2292e67fb2e25422dfb190474e30a38de3', "downloaded GitHub zip archive has correct digest"); - ok(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:'), + is(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:'), '', 'Cannot download from site with self-signed cert without ignoring cert errors'); - ok($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with self-signed certificate"); - ok(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:', 1), + is($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with self-signed certificate"); + is(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:', 1), '1', 'Can download from site with self-signed cert using ignore cert errors parameter'); - ok(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:'), + is(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:'), '', 'Cannot download from site with expired cert without ignoring cert errors'); - ok($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with expired certificate"); - ok(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:', 1), + is($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with expired certificate"); + is(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:', 1), '1', 'Can download from site with expired cert using ignore cert errors parameter'); } diff --git a/t/Names.t b/t/Names.t index a719020..b6f1dc0 100644 --- a/t/Names.t +++ b/t/Names.t @@ -1,10 +1,6 @@ use strict; -BEGIN { - eval "use Test::More"; - return unless $@; - print "1..0 # Skip: Test requires Test::More module\n"; - exit 0; -} +use warnings; +use Test::More; use Win32; my $tests = 16; diff --git a/t/Privileges.t b/t/Privileges.t index 61a3495..8873db7 100644 --- a/t/Privileges.t +++ b/t/Privileges.t @@ -1,32 +1,35 @@ use strict; use warnings; -use Test; +use Test::More tests => 7; use Win32; use Config; use File::Temp; -plan tests => 7; - -ok(ref(Win32::GetProcessPrivileges()) eq 'HASH'); -ok(ref(Win32::GetProcessPrivileges(Win32::GetCurrentProcessId())) eq 'HASH'); +is(ref(Win32::GetProcessPrivileges()), 'HASH'); +is(ref(Win32::GetProcessPrivileges(Win32::GetCurrentProcessId())), 'HASH'); # All Windows PIDs are divisible by 4. It's an undocumented implementation # detail, but it means it's extremely unlikely that the PID below is valid. ok(!Win32::GetProcessPrivileges(3423237)); -my $whoami = `whoami /priv 2>&1`; -my $skip = ($? == -1 || $? >> 8) ? '"whoami" command is missing' : 0; +SKIP: { + my $whoami = `whoami /priv 2>&1`; + skip '"whoami" command is missing', 1 + if $? == -1 || $? >> 8; -skip($skip, sub{ my $privs = Win32::GetProcessPrivileges(); + my $ok = 1; while ($whoami =~ /^(Se\w+)/mg) { - return 0 unless exists $privs->{$1}; + if (!exists $privs->{$1}) { + $ok = 0; + last; + } } - return 1; -}); + ok $ok; +} # there isn't really anything to test, we just want to make sure that the # function doesn't segfault @@ -36,20 +39,22 @@ ok(1); Win32::IsSymlinkCreationAllowed(); ok(1); -$skip = $^O ne 'MSWin32' ? 'MSWin32-only test' : 0; -$skip ||= !$Config{d_symlink} ? 'this perl doesn\'t have symlink()' : 0; +SKIP: { + skip 'MSWin32-only test', 1 + if $^O ne 'MSWin32'; + skip "this perl doesn't have symlink()", 1 + if !$Config{d_symlink}; -skip($skip, sub { my $tmpdir = File::Temp->newdir; my $dirname = $tmpdir->dirname; if (Win32::IsSymlinkCreationAllowed()) { # we expect success - return symlink("foo", $tmpdir->dirname . "/new_symlink") == 1; + is symlink("foo", $tmpdir->dirname . "/new_symlink"), 1; } else { # we expect failure - return symlink("foo", $tmpdir->dirname . "/new_symlink") == 0; + is symlink("foo", $tmpdir->dirname . "/new_symlink"), 0; } -}); +} diff --git a/t/Unicode.t b/t/Unicode.t index c1380e8..ee6eb9f 100644 --- a/t/Unicode.t +++ b/t/Unicode.t @@ -1,5 +1,4 @@ use strict; -use Test; use Config qw(%Config); use Cwd qw(cwd); use Encode qw(); @@ -27,6 +26,8 @@ BEGIN { } } +use Test::More tests => 12; + my $home = Win32::GetCwd(); my $cwd = cwd(); # may be a Cygwin path my $dir = "Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz"; @@ -43,8 +44,6 @@ sub cleanup { cleanup(); END { cleanup() } -plan test => 12; - # Create Unicode directory Win32::CreateDirectory($dir); ok(-d Win32::GetANSIPathName($dir)); @@ -60,7 +59,7 @@ while ($_ = readdir($dh)) { # On Cygwin 1.7 readdir() returns the utf8 representation of the # filename but doesn't turn on the SvUTF8 bit Encode::_utf8_on($_) if $^O eq "cygwin" && $Config{osvers} !~ /^1.5/; - ok($file, Win32::GetLongPathName("$dir\\$_")); + is($file, Win32::GetLongPathName("$dir\\$_")); } closedir($dh); @@ -68,7 +67,7 @@ closedir($dh); my $full = Win32::GetFullPathName($dir); my $long = Win32::GetLongPathName($full); -ok($long, Win32::GetLongPathName($home)."\\$dir"); +is($long, Win32::GetLongPathName($home)."\\$dir"); # We can Win32::SetCwd() into the Unicode directory ok(Win32::SetCwd($dir)); @@ -80,9 +79,9 @@ my $subdir = cwd(); # change back to home directory to make sure relative paths # in @INC continue to work ok(chdir($home)); -ok(Win32::GetCwd(), $home); +is(Win32::GetCwd(), $home); -ok(Win32::GetLongPathName($w32dir), $long); +is(Win32::GetLongPathName($w32dir), $long); # cwd() on Cygwin returns a mapped path that we need to translate # back to a Windows path. Invoking `cygpath` on $subdir doesn't work. @@ -90,9 +89,13 @@ if ($^O eq "cygwin") { $subdir = Cygwin::posix_to_win_path($subdir, 1); } $subdir =~ s,/,\\,g; -# Cygwin64 no longer returns an ANSI name -skip($^O eq "cygwin", Win32::GetLongPathName($subdir), $long); +SKIP: { + skip 'Cygwin64 no longer returns an ANSI name', 1 + if $^O eq "cygwin"; + + is(Win32::GetLongPathName($subdir), $long); +} # We can chdir() into the Unicode directory if we use the ANSI name ok(chdir(Win32::GetANSIPathName($dir))); -ok(Win32::GetLongPathName(Win32::GetCwd()), $long); +is(Win32::GetLongPathName(Win32::GetCwd()), $long); From 6bee1c959b91a829d11544886a8a8f8efce79ec4 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 27 May 2022 14:14:34 +0200 Subject: [PATCH 4/5] convert GetCurrentThreadId test to use Test::More The GetCurrentThreadId test forks, then continues testing in the child rather than the parent. This conflicts with the standard behavior of Test::More, which does extra checks at process end but only for the parent process. Use Test::Builder's ->no_ending setting to prevent that extra handling. We have a test plan, so everything should work without that extra handling. --- t/GetCurrentThreadId.t | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/t/GetCurrentThreadId.t b/t/GetCurrentThreadId.t index ce98f3e..71aa94c 100644 --- a/t/GetCurrentThreadId.t +++ b/t/GetCurrentThreadId.t @@ -1,38 +1,41 @@ use strict; use Config qw(%Config); -use Test; +use Test::More; use Win32; my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/; -my $tests = $fork_emulation ? 4 : 2; -plan tests => $tests; +plan tests => $fork_emulation ? 4 : 2; my $pid = $$+0; # make sure we don't copy any magic to $pid if ($^O eq "cygwin") { - skip(!defined &Cygwin::pid_to_winpid, - Cygwin::pid_to_winpid($pid), - Win32::GetCurrentProcessId()); + SKIP: { + skip 'Cygwin::pid_to_winpid is not available', 1 + if !defined &Cygwin::pid_to_winpid; + + is(Cygwin::pid_to_winpid($pid), Win32::GetCurrentProcessId()); + } } else { - ok($pid, Win32::GetCurrentProcessId()); + is($pid, Win32::GetCurrentProcessId()); } if ($fork_emulation) { # This test relies on the implementation detail that the fork() emulation # uses the negative value of the thread id as a pseudo process id. if (my $child = fork) { - waitpid($child, 0); - exit 0; + Test::More->builder->no_ending(1); + waitpid($child, 0); + exit $?; } - ok(-$$, Win32::GetCurrentThreadId()); + is(-$$, Win32::GetCurrentThreadId()); # GetCurrentProcessId() should still return the real PID - ok($pid, Win32::GetCurrentProcessId()); - ok($$ != Win32::GetCurrentProcessId()); + is($pid, Win32::GetCurrentProcessId()); + isnt($$, Win32::GetCurrentProcessId()); } else { # here we just want to see something. - ok(Win32::GetCurrentThreadId() > 0); + cmp_ok(Win32::GetCurrentThreadId(), '>', 0); } From abc9ec8890c1f0ebf30749419a911f5de7e167a2 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 27 May 2022 16:34:26 +0200 Subject: [PATCH 5/5] drop Test.pm prereq --- Makefile.PL | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.PL b/Makefile.PL index dfab1f1..77961c8 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -32,7 +32,6 @@ my $test_requires = $ExtUtils::MakeMaker::VERSION >= 6.64 ? 'TEST_REQUIRES' : 'PREREQ_PM'; -$param{$test_requires}{'Test'} = 0; $param{$test_requires}{'Test::More'} = 0; $param{$test_requires}{'File::Temp'} = 0;