trial.settings 4/4(100%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
880
890
900
910
920
930
940
950
960
970
980
990
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090
1100
1110
1120
1130
1141
1150
1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1281
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1511
1520
1532
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
/++ Settings parser and structures Copyright: © 2017 Szabo Bogdan License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Szabo Bogdan +/ module trial.settings; import std.conv; import trial.reporters.result; import trial.reporters.spec; import trial.reporters.specsteps; import trial.reporters.dotmatrix; import trial.reporters.landing; import trial.reporters.progress; version(Have_dub) { import dub.internal.vibecompat.data.serialization; } /// mixin template SettingsFields() { /* bool colors; bool sort; bool bail;*/ /** The reporter list that will be added by the runner at startup * You can use here only the embeded reporters. * If you want to use a custom reporter you can use `static this` constructor * * Examples: * ------------------------ * static this * { * LifeCycleListeners.instance.add(myCustomReporter); * } * ------------------------ */ string[] reporters = ["spec", "result"]; /// The test discovery classes that you want to use string[] testDiscovery = ["trial.discovery.unit.UnitTestDiscovery"]; /// The default executor is `SingleRunner`. If you want to use the /// `ParallelExecutor` set this flag true. bool runInParallel = false; /// The number of threads tha you want to use /// `0` means the number of cores that your processor has uint maxThreads = 0; /// GlyphSettings glyphs; /// Where to generate artifacts string artifactsLocation = ".trial"; /// Show the duration with yellow if it takes more `warningTestDuration` msecs uint warningTestDuration = 20; /// Show the duration with red if it takes more `dangerTestDuration` msecs uint dangerTestDuration = 100; } /// A structure representing the `trial.json` file struct Settings { version(Have_dub) { @optional { mixin SettingsFields; } } else { mixin SettingsFields; } } mixin template GlyphSettingsFields() { /// SpecGlyphs spec; /// SpecStepsGlyphs specSteps; /// TestResultGlyphs result; /// DotMatrixGlyphs dotMatrix; /// LandingGlyphs landing; /// ProgressGlyphs progress; } /// The gliph settings struct GlyphSettings { version(Have_dub) { @optional { mixin GlyphSettingsFields; } } else { mixin GlyphSettingsFields; } } /// Converts the settings object to DLang code. It's used by the generator string toCode(Settings settings) { return "Settings(" ~ settings.reporters.to!string ~ ", " ~ settings.testDiscovery.to!string ~ ", " ~ settings.runInParallel.to!string ~ ", " ~ settings.maxThreads.to!string ~ ", " ~ settings.glyphs.toCode ~ ", " ~ `"` ~ settings.artifactsLocation ~ `", ` ~ settings.warningTestDuration.to!string ~ `, ` ~ settings.dangerTestDuration.to!string ~ ")"; } /// Converts the GlyphSettings object to DLang code. It's used by the generator string toCode(GlyphSettings settings) { return "GlyphSettings(" ~ specGlyphsToCode(settings.spec) ~ ", " ~ specStepsGlyphsToCode(settings.specSteps) ~ ", " ~ testResultGlyphsToCode(settings.result) ~ ", " ~ dotMatrixGlyphsToCode(settings.dotMatrix) ~ ", " ~ landingGlyphsToCode(settings.landing) ~ ", " ~ progressGlyphsToCode(settings.progress) ~ ")"; } version (unittest) { import fluent.asserts; } /// it should be able to compile the settings code unittest { mixin("auto settings = " ~ Settings().toCode ~ ";"); } /// it should be able to transform the Settings to code. unittest { Settings settings; settings.toCode.should.equal(`Settings(` ~ `["spec", "result"], ` ~ `["trial.discovery.unit.UnitTestDiscovery"], false, 0, ` ~ "GlyphSettings(SpecGlyphs(`✓`), " ~ "SpecStepsGlyphs(`┌`, `└`, `│`), "~ "TestResultGlyphs(`✖`), " ~ "DotMatrixGlyphs(`.`,`!`,`?`), " ~ "LandingGlyphs(`✈`,`━`,`⋅`), " ~ "ProgressGlyphs(`░`,`▓`)" ~ "), " ~ `".trial", ` ~ "20, 100"~ `)`); }