From 22d1133ea58e3a085ad8562d2ed263133151a993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A9=D0=B0=D0=BF=D0=BE=D0=B2?= Date: Sat, 24 Apr 2021 01:41:07 +0500 Subject: [PATCH] Disable some tests if running on root. --- test/filesystem_test.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/filesystem_test.cpp b/test/filesystem_test.cpp index 4fbed91..50ef51f 100644 --- a/test/filesystem_test.cpp +++ b/test/filesystem_test.cpp @@ -76,6 +76,7 @@ using fstream = ghc::filesystem::fstream; #include #include #include +#include #endif #ifndef GHC_FILESYSTEM_FWD_TEST @@ -2445,8 +2446,13 @@ TEST_CASE("fs.op.permissions - permissions", "[filesystem][operations][fs.op.per auto allWrite = fs::perms::owner_write | fs::perms::group_write | fs::perms::others_write; CHECK_NOTHROW(fs::permissions("foo", allWrite, fs::perm_options::remove)); CHECK((fs::status("foo").permissions() & fs::perms::owner_write) != fs::perms::owner_write); - CHECK_THROWS_AS(fs::resize_file("foo", 1024), fs::filesystem_error); - CHECK(fs::file_size("foo") == 512); +#if !defined(GHC_OS_WINDOWS) + if (geteuid() != 0) +#endif + { + CHECK_THROWS_AS(fs::resize_file("foo", 1024), fs::filesystem_error); + CHECK(fs::file_size("foo") == 512); + } CHECK_NOTHROW(fs::permissions("foo", fs::perms::owner_write, fs::perm_options::add)); CHECK((fs::status("foo").permissions() & fs::perms::owner_write) == fs::perms::owner_write); CHECK_NOTHROW(fs::resize_file("foo", 2048));