Skip to content

Commit

Permalink
fix Issue 15517
Browse files Browse the repository at this point in the history
was already fixed but had no fixture
  • Loading branch information
burner committed May 29, 2017
1 parent ef15d6e commit 27b6122
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions std/experimental/logger/core.d
Expand Up @@ -3144,3 +3144,51 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted
tl.log("123456789"d);
assert(tl.msg == "123456789");
}

// Issue 15517
@system unittest
{
import std.stdio : File;
import std.string : indexOf;
import std.file : exists, remove;

string fn = "logfile.log";
if (exists(fn))
{
remove(fn);
}

auto oldShared = sharedLog;
scope(exit)
{
sharedLog = oldShared;
if (exists(fn))
{
remove(fn);
}
}

auto ts = [ "Test log 1", "Test log 2", "Test log 3"];

auto fl = new FileLogger(fn);
sharedLog = fl;
assert(exists(fn));

foreach (t; ts)
{
log(t);
}

auto f = File(fn);
auto l = f.byLine();
assert(!l.empty);
size_t idx;
foreach (it; l)
{
assert(it.indexOf(ts[idx]) != -1, it);
++idx;
}

assert(exists(fn));
fl.file.close();
}

0 comments on commit 27b6122

Please sign in to comment.