Skip to content

Commit

Permalink
Merge pull request #2383 from tom-tan/safe-unittests-for-file-readTex…
Browse files Browse the repository at this point in the history
…t-etc

Mark unittests for std.file.readText, rename and exists as safe
  • Loading branch information
Михаил Страшун committed Jul 31, 2014
2 parents 087b2f7 + 9157f52 commit 5c2448e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions std/file.d
Expand Up @@ -317,7 +317,7 @@ void[] read(in char[] name, size_t upTo = size_t.max) @safe
assert(read(deleteme) == "1234");
}

version (linux) unittest
version (linux) @safe unittest
{
// A file with "zero" length that doesn't have 0 length at all
auto s = std.file.readText("/proc/sys/kernel/osrelease");
Expand Down Expand Up @@ -354,7 +354,7 @@ S readText(S = string)(in char[] name) @safe if (isSomeString!S)
return result;
}

unittest
@safe unittest
{
write(deleteme, "abc\n");
scope(exit) { assert(exists(deleteme)); remove(deleteme); }
Expand Down Expand Up @@ -474,7 +474,7 @@ void rename(in char[] from, in char[] to) @trusted
cenforce(core.stdc.stdio.rename(toStringz(from), toStringz(to)) == 0, to);
}

unittest
@safe unittest
{
auto t1 = deleteme, t2 = deleteme~"2";
scope(exit) foreach (t; [t1, t2]) if (t.exists) t.remove();
Expand Down Expand Up @@ -946,7 +946,7 @@ bool exists(in char[] name) @trusted
}
}

unittest
@safe unittest
{
assert(exists("."));
assert(!exists("this file does not exist"));
Expand Down

0 comments on commit 5c2448e

Please sign in to comment.