10203040506070809010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089090091092093094095096097098099010001010 module trial.reporters.landing; import std.stdio; import std.array; import std.conv; import std.datetime; import std.string; import std.algorithm; import trial.interfaces; import trial.reporters.writer; struct LandingGlyphs { string plane = "✈"; string margin = "━"; string lane = "⋅"; } string landingGlyphsToCode(LandingGlyphs glyphs) { return "LandingGlyphs(`"~ glyphs.plane ~"`,`"~ glyphs.margin ~"`,`"~ glyphs.lane ~"`)"; } class LandingReporter : ITestCaseLifecycleListener, ILifecycleListener { private { ReportWriter writer; LandingGlyphs glyphs; ulong testCount; ulong currentTest; bool success = true; } this(LandingGlyphs glyphs) { writer = defaultWriter; this.glyphs = glyphs; } this(ReportWriter writer) { this.writer = writer; } void begin(ulong testCount) { this.testCount = testCount; writer.writeln("\n\n"); drawLane; } void update() { } void end(SuiteResult[]) { } void begin(string suite, ref TestResult test) { } void end(string suite, ref TestResult test) { currentTest++; success = success && test.status == TestResult.Status.success; drawLane; } private void drawLane() { size_t size = (writer.width / 4) * 3; size_t position = ((cast(double) currentTest / cast(double) testCount) * size).to!size_t; writer.goTo(3); writer.writeln(glyphs.margin.replicate(size), ReportWriter.Context.inactive); if (currentTest < testCount) { writer.write(glyphs.lane.replicate(position), ReportWriter.Context.inactive); writer.write(glyphs.plane, success ? ReportWriter.Context.active : ReportWriter.Context.danger); writer.writeln(glyphs.lane.replicate(size - position - 1), ReportWriter.Context.inactive); } else { writer.write(glyphs.lane.replicate(size), ReportWriter.Context.inactive); writer.writeln(glyphs.plane, success ? ReportWriter.Context.active : ReportWriter.Context.danger); } writer.writeln(glyphs.margin.replicate(size), ReportWriter.Context.inactive); } }
module trial.reporters.landing; import std.stdio; import std.array; import std.conv; import std.datetime; import std.string; import std.algorithm; import trial.interfaces; import trial.reporters.writer; struct LandingGlyphs { string plane = "✈"; string margin = "━"; string lane = "⋅"; } string landingGlyphsToCode(LandingGlyphs glyphs) { return "LandingGlyphs(`"~ glyphs.plane ~"`,`"~ glyphs.margin ~"`,`"~ glyphs.lane ~"`)"; } class LandingReporter : ITestCaseLifecycleListener, ILifecycleListener { private { ReportWriter writer; LandingGlyphs glyphs; ulong testCount; ulong currentTest; bool success = true; } this(LandingGlyphs glyphs) { writer = defaultWriter; this.glyphs = glyphs; } this(ReportWriter writer) { this.writer = writer; } void begin(ulong testCount) { this.testCount = testCount; writer.writeln("\n\n"); drawLane; } void update() { } void end(SuiteResult[]) { } void begin(string suite, ref TestResult test) { } void end(string suite, ref TestResult test) { currentTest++; success = success && test.status == TestResult.Status.success; drawLane; } private void drawLane() { size_t size = (writer.width / 4) * 3; size_t position = ((cast(double) currentTest / cast(double) testCount) * size).to!size_t; writer.goTo(3); writer.writeln(glyphs.margin.replicate(size), ReportWriter.Context.inactive); if (currentTest < testCount) { writer.write(glyphs.lane.replicate(position), ReportWriter.Context.inactive); writer.write(glyphs.plane, success ? ReportWriter.Context.active : ReportWriter.Context.danger); writer.writeln(glyphs.lane.replicate(size - position - 1), ReportWriter.Context.inactive); } else { writer.write(glyphs.lane.replicate(size), ReportWriter.Context.inactive); writer.writeln(glyphs.plane, success ? ReportWriter.Context.active : ReportWriter.Context.danger); } writer.writeln(glyphs.margin.replicate(size), ReportWriter.Context.inactive); } }