Skip to content

Commit

Permalink
Merge pull request #118 from phprus/test-root-unix
Browse files Browse the repository at this point in the history
Disable some tests if running on root.
  • Loading branch information
gulrak committed Apr 26, 2021
2 parents 7fb5021 + 22d1133 commit 777e3c9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ using fstream = ghc::filesystem::fstream;
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#endif

#ifndef GHC_FILESYSTEM_FWD_TEST
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 777e3c9

Please sign in to comment.