diff --git a/spec/std/file_spec.cr b/spec/std/file_spec.cr index 538fa6a165a2..54ce7ed48df8 100644 --- a/spec/std/file_spec.cr +++ b/spec/std/file_spec.cr @@ -867,7 +867,15 @@ describe "File" do pending_win32 "raises when reading a file with no permission" do with_tempfile("file.txt") do |path| File.touch(path) - File.chmod(path, 0) + File.chmod(path, File::Permissions::None) + {% if flag?(:unix) %} + # TODO: Find a better way to execute this spec when running as privileged + # user. Compiling a program and running a separate process would be a + # lot of overhead. + if LibC.getuid == 0 + pending! "Spec cannot run as superuser" + end + {% end %} expect_raises(File::AccessDeniedError) { File.read(path) } end end