From 48a70037020b3de1a359a509cf7d36f982b27fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Sun, 19 Jul 2020 12:19:33 -0700 Subject: [PATCH 1/2] Fixes issue #22 failed tests on MSYS2 It seems it is not possible to make files unreadable on MSYS2. Skipped the tests that checked for readable bit. Also added 'msys' to the _win32() sub such that MSYS2 is treated as Win32 in the tests. --- lib/Test/File.pm | 2 +- t/file_contains.t | 4 ++++ t/test_files.t | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Test/File.pm b/lib/Test/File.pm index be8fbbe..115ef2a 100644 --- a/lib/Test/File.pm +++ b/lib/Test/File.pm @@ -81,7 +81,7 @@ sub _normalize { sub _win32 { return 0 if $^O eq 'darwin'; return $ENV{PRETEND_TO_BE_WIN32} if defined $ENV{PRETEND_TO_BE_WIN32}; - return $^O =~ m/Win/; + return $^O =~ m/Win/ || $^O eq 'msys'; } # returns true if symlinks can't exist diff --git a/t/file_contains.t b/t/file_contains.t index 377c2cf..5bc8a5a 100644 --- a/t/file_contains.t +++ b/t/file_contains.t @@ -30,6 +30,7 @@ test_test(); SKIP: { skip "Superuser has special privileges", 1, if( $> == 0 or $< == 0 ); +skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( "not ok 1 - not_readable contains $pattern1" ); test_diag( 'File [not_readable] is not readable!' ); test_fail(+1); @@ -58,6 +59,7 @@ test_test(); SKIP: { skip "Superuser has special privileges", 1, if( $> == 0 or $< == 0 ); +skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( "not ok 1 - not_readable doesn't contain $bad_pattern" ); test_diag( 'File [not_readable] is not readable!' ); test_fail(+1); @@ -92,6 +94,7 @@ test_test(); SKIP: { skip "Superuser has special privileges", 1, if( $> == 0 or $< == 0 ); +skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( "not ok 1 - not_readable contains $pattern1" ); test_diag( 'File [not_readable] is not readable!' ); test_fail(+1); @@ -127,6 +130,7 @@ test_test(); SKIP: { skip "Superuser has special privileges", 1, if( $> == 0 or $< == 0 ); +skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( "not ok 1 - not_readable doesn't contain $bad_pattern" ); test_diag( 'File [not_readable] is not readable!' ); test_fail(+1); diff --git a/t/test_files.t b/t/test_files.t index 6deddc3..fb98a1f 100644 --- a/t/test_files.t +++ b/t/test_files.t @@ -80,6 +80,7 @@ subtest readable_fails => sub { SKIP: { subtest not_readable_fails => sub { SKIP: { skip "Superuser has special privileges", 3, if( $> == 0 or $< == 0 ); + skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( 'ok 1 - writeable is not readable' ); file_not_readable_ok( 'writeable' ); test_out( 'ok 2 - writeable really is not readable' ); @@ -115,6 +116,7 @@ subtest writable_fails => sub { subtest not_writable => sub { SKIP: { skip "Superuser has special privileges", 1, if( $> == 0 or $< == 0 ); + skip "Not possible to make file unreadable on MSYS2" if $^O eq 'msys'; test_out( 'ok 1 - readable is not writable' ); test_out( 'not ok 2 - writable is not writable' ); test_diag('File [writable] is writable!'); @@ -128,9 +130,9 @@ subtest not_writable => sub { SKIP: { subtest executable => sub { if (Test::File::_win32()) { - test_out("ok 1 # skip file_not_executable_ok doesn't work on Windows!"); - test_out("ok 2 # skip file_not_executable_ok doesn't work on Windows!"); - test_out("ok 3 # skip file_not_executable_ok doesn't work on Windows!"); + test_out("ok 1 # skip file_executable_ok doesn't work on Windows!"); + test_out("ok 2 # skip file_executable_ok doesn't work on Windows!"); + test_out("ok 3 # skip file_executable_ok doesn't work on Windows!"); } else { test_out("ok 1 - executable is executable"); From 6ca73cb4bdc753ac4e3bb5cf8b7c68b55de6a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Sun, 19 Jul 2020 13:51:22 -0700 Subject: [PATCH 2/2] UID and EUID are zero for MSWin32. The test writeable_fails in t/test_files.t assumes that a UID==0 or EUID==0 implies running with elevated privileges. It seems this is not the case for MSWin32. --- t/test_files.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test_files.t b/t/test_files.t index fb98a1f..5813a2a 100644 --- a/t/test_files.t +++ b/t/test_files.t @@ -100,7 +100,7 @@ subtest writable_fails => sub { file_writable_ok( 'writable' ); test_out( "ok 2 - $label" ); file_writable_ok( 'writable', $label ); - if( $> == 0 or $< == 0 ) { + if( ($^O ne 'MSWin32') && ($> == 0 or $< == 0 )) { test_out( 'ok 3 - readable is writeable' ); } else {