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_long_term_view; 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.diff_parser : Diff; 19 import dextool.plugin.mutate.backend.report.html.constants; 20 import dextool.plugin.mutate.backend.report.html.tmpl : tmplBasicPage, tmplDefaultTable; 21 import dextool.plugin.mutate.backend.report.utility; 22 import dextool.plugin.mutate.backend.type : Mutation; 23 import dextool.plugin.mutate.config : ConfigReport; 24 import dextool.plugin.mutate.type : MutationKind; 25 import dextool.type : AbsolutePath; 26 27 auto makeLongTermView(ref Database db, ref const ConfigReport conf, 28 const(MutationKind)[] humanReadableKinds, const(Mutation.Kind)[] kinds) @trusted { 29 import std.datetime : Clock; 30 31 auto doc = tmplBasicPage; 32 doc.title(format("Long Term View %(%s %) %s", humanReadableKinds, Clock.currTime)); 33 34 toHtml(reportSelectedAliveMutants(db, kinds, 10), doc.mainBody); 35 36 return doc.toPrettyString; 37 } 38 39 private: 40 41 void toHtml(const MutantSample mut_sample, Element root) { 42 import std.path : buildPath; 43 import dextool.plugin.mutate.backend.report.html.page_files : pathToHtmlLink; 44 45 root.addChild("h2", "High Interest Mutants"); 46 47 if (mut_sample.hardestToKill.length != 0) { 48 root.addChild("h3", "Longest Surviving Mutant"); 49 root.addChild("p", 50 "This mutants has survived countless test runs. Slay one or more of them to be the hero of the team."); 51 52 auto tbl = tmplDefaultTable(root, ["Link", "Discovered", "Last Updated", "Survived"]); 53 54 foreach (const mutst; mut_sample.hardestToKill) { 55 const mut = mut_sample.mutants[mutst.statusId]; 56 auto r = tbl.appendRow(); 57 r.addChild("td").addChild("a", format("%s:%s", mut.file, 58 mut.sloc.line)).href = format("%s#%s", buildPath(htmlFileDir, 59 pathToHtmlLink(mut.file)), mut.id); 60 r.addChild("td", mutst.added.isNull ? "unknown" : mutst.added.get.toString); 61 r.addChild("td", mutst.updated.toString); 62 r.addChild("td", format("%s times", mutst.testCnt)); 63 } 64 } 65 66 if (mut_sample.oldest.length != 0) { 67 root.addChild("p", format("This is a list of the %s oldest mutants containing when they where last tested and thus had their status updated.", 68 mut_sample.oldest.length)); 69 70 auto tbl = tmplDefaultTable(root, ["Link", "Updated"]); 71 72 foreach (const mutst; mut_sample.oldest) { 73 auto mut = mut_sample.mutants[mutst.id]; 74 auto r = tbl.appendRow(); 75 r.addChild("td").addChild("a", format("%s:%s", mut.file, 76 mut.sloc.line)).href = format("%s#%s", buildPath(htmlFileDir, 77 pathToHtmlLink(mut.file)), mut.id); 78 r.addChild("td", mutst.updated.toString); 79 } 80 } 81 }