Skip to content

Commit

Permalink
Update DustMite
Browse files Browse the repository at this point in the history
* 311e457 tests: Support running tests on POSIX
* 2a1b481 .gitignore
* edc17f1 dustmite: Don't use floating-point to calculate progress
* e952bdc dustmite: Make --obfuscate --keep-length results not depend on bitness
* a3664e9 tests: dos2unix (opts.txt)
* 042fe0c splitter: Enforce order of read files
* e9736b5 Use UNIX line endings in --dump output
* 53ff3f4 dos2unix
* a4c1aa8 tests: Add imports-only test
* 3498068 tests: Add test for full reduction to empty set
* d0482ee dustmite: Emit special message when reducing to empty set
* 07f05ca dustmite: Don't attempt to reduce empty root
* 1e01585 Fix descendant counter when removing root
* 0efbe54 Add --reduce-only
* 60293fb splitter: Don't go into an infinite loop in postProcessBlockKeywords
* ec08b00 Add --no-redirect switch
* 955f569 Merge pull request #25 from John-Colvin/patch-2
* 14b3aca making sure to use std.algorithm.sort, not builtin
  • Loading branch information
CyberShadow committed Mar 6, 2016
1 parent da0a2e0 commit 1938f39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions DustMite/dustmite.d
Expand Up @@ -87,7 +87,8 @@ struct Reduction
e = e.children[a];
}
progress += e.descendants;
return format("[%5.1f%%] %s [%s]", (origDescendants-progress) * 100.0 / origDescendants, name, segments.join(binary ? "" : ", "));
auto progressPM = (origDescendants-progress) * 1000 / origDescendants; // per-mille
return format("[%2d.%d%%] %s [%s]", progressPM/10, progressPM%10, name, segments.join(binary ? "" : ", "));
}
}
}
Expand Down Expand Up @@ -252,9 +253,14 @@ EOS");
duration = dur!"msecs"(duration.total!"msecs"); // truncate anything below ms, users aren't interested in that
if (foundAnything)
{
if (noSave)
measure!"resultSave"({safeSave(resultDir);});
writefln("Done in %s tests and %s; reduced version is in %s", tests, duration, resultDir);
if (root.children.length)
{
if (noSave)
measure!"resultSave"({safeSave(resultDir);});
writefln("Done in %s tests and %s; reduced version is in %s", tests, duration, resultDir);
}
else
writefln("Done in %s tests and %s; reduced to empty set", tests, duration);
}
else
writefln("Done in %s tests and %s; no reductions found", tests, duration);
Expand Down Expand Up @@ -291,7 +297,7 @@ size_t checkDescendants(Entity e)
size_t n = 1;
foreach (c; e.children)
n += checkDescendants(c);
assert(e.descendants == n);
assert(e.descendants == n, "Wrong descendant count: expected %d, found %d".format(e.descendants, n));
return n;
}

Expand All @@ -313,6 +319,9 @@ bool testAddress(size_t[] address)
{
auto e = entityAt(address);

if (e is root && !root.children.length)
return false;
else
if (tryReduction(Reduction(Reduction.Type.Remove, address, e)))
return true;
else
Expand Down Expand Up @@ -601,7 +610,7 @@ void obfuscate(bool keepLength)
{
auto result = new char[length];
foreach (i, ref c; result)
c = (i==0 ? first : other)[uniform(0, $, rng)];
c = (i==0 ? first : other)[uniform(0, cast(uint)$, rng)];

return assumeUnique(result);
}
Expand Down Expand Up @@ -840,7 +849,10 @@ void applyReduction(ref Reduction r)
p.children = remove(p.children, r.address[$-1]);
}
else
{
root = new Entity();
root.descendants = 1;
}

debug verifyNotRemoved(root);
debug checkDescendants(root);
Expand Down Expand Up @@ -1284,7 +1296,7 @@ void assignID(Entity e)

void dumpSet(string fn)
{
auto f = File(fn, "wt");
auto f = File(fn, "wb");

string printable(string s) { return s is null ? "null" : `"` ~ s.replace("\\", `\\`).replace("\"", `\"`).replace("\r", `\r`).replace("\n", `\n`) ~ `"`; }
string printableFN(string s) { return "/*** " ~ s ~ " ***/"; }
Expand Down
2 changes: 1 addition & 1 deletion DustMite/splitter.d
Expand Up @@ -107,7 +107,7 @@ Entity loadFiles(ref string path, ParseOptions options)
else
{
auto set = new Entity();
foreach (string entry; dirEntries(path, SpanMode.breadth))
foreach (string entry; dirEntries(path, SpanMode.breadth).array.sort!((a, b) => a.name < b.name))
if (isFile(entry))
{
assert(entry.startsWith(path));
Expand Down

0 comments on commit 1938f39

Please sign in to comment.