1 /** 2 Copyright: Copyright (c) 2018, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module dextool.plugin.mutate.backend.report.html.page_minimal_set; 11 12 import logger = std.experimental.logger; 13 import std.format : format; 14 15 import arsd.dom : Document, Element, require, Table; 16 17 import dextool.plugin.mutate.backend.database : Database; 18 import dextool.plugin.mutate.backend.report.html.constants; 19 import dextool.plugin.mutate.backend.report.html.tmpl : tmplBasicPage, tmplDefaultTable; 20 import dextool.plugin.mutate.backend.report.utility; 21 import dextool.plugin.mutate.backend.type : Mutation; 22 import dextool.plugin.mutate.config : ConfigReport; 23 import dextool.plugin.mutate.type : MutationKind; 24 25 auto makeMinimalSetAnalyse(ref Database db, ref const ConfigReport conf, 26 const(MutationKind)[] humanReadableKinds, const(Mutation.Kind)[] kinds) @trusted { 27 import std.datetime : Clock; 28 29 auto doc = tmplBasicPage; 30 doc.title(format("Minimal Set Analyse %(%s %) %s", humanReadableKinds, Clock.currTime)); 31 doc.mainBody.addChild("p", 32 "This are the minimal set of mutants that result in the mutation score."); 33 34 toHtml(reportMinimalSet(db, kinds), doc.mainBody); 35 36 return doc.toPrettyString; 37 } 38 39 private: 40 41 void toHtml(MinimalTestSet min_set, Element root) { 42 import core.time : Duration; 43 import std.conv : to; 44 45 root.addChild("h2", format!"Ineffective Test Cases (%s/%s %s)"(min_set.redundant.length, 46 min_set.total, cast(double) min_set.redundant.length / cast(double) min_set.total)); 47 root.addChild("p", "These test cases do not contribute towards the mutation score."); 48 { 49 auto tbl = tmplDefaultTable(root, [ 50 "Test Case", "Killed", "Sum of test time" 51 ]); 52 Duration sum; 53 foreach (const tc; min_set.redundant) { 54 auto r = tbl.appendRow(); 55 r.addChild("td", tc.name); 56 r.addChild("td", min_set.testCaseTime[tc.name].killedMutants.to!string); 57 r.addChild("td", min_set.testCaseTime[tc.name].time.to!string); 58 sum += min_set.testCaseTime[tc.name].time; 59 } 60 root.addChild("p", format("Total test time: %s", sum)); 61 } 62 63 root.addChild("h2", format!"Minimal Set (%s/%s %s)"(min_set.minimalSet.length, 64 min_set.total, cast(double) min_set.minimalSet.length / cast(double) min_set.total)); 65 root.addChild("p", "This is the minimum set of tests that achieve the mutation score."); 66 { 67 auto tbl = tmplDefaultTable(root, [ 68 "Test Case", "Killed", "Sum of test time" 69 ]); 70 Duration sum; 71 foreach (const tc; min_set.minimalSet) { 72 auto r = tbl.appendRow(); 73 r.addChild("td", tc.name); 74 r.addChild("td", min_set.testCaseTime[tc.name].killedMutants.to!string); 75 r.addChild("td", min_set.testCaseTime[tc.name].time.to!string); 76 sum += min_set.testCaseTime[tc.name].time; 77 } 78 root.addChild("p", format("Total test time: %s", sum)); 79 } 80 }