1 /** 2 Copyright: Copyright (c) 2017, 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.type; 11 12 import dextool.type : Path, AbsolutePath; 13 14 /// The kind of mutation to perform 15 enum MutationKind { 16 /// all mutation operators are used 17 all, 18 /// Relational operator replacement 19 ror, 20 /// Relational operator replacement for pointers 21 rorp, 22 /// Logical connector replacement 23 lcr, 24 /// Arithmetic operator replacement 25 aor, 26 /// Unary operator insert 27 uoi, 28 /// Absolute value replacement 29 abs, 30 /// Statement deletion 31 sdl, 32 /// Decision/Condition Coverage 33 dcc, 34 /// Decision/Condition Requirement 35 dcr, 36 /// Logical Connector Replacement Bit-wise 37 lcrb, 38 } 39 40 /// The order the mutations are done when running in test_mutants mode 41 enum MutationOrder { 42 random, 43 consecutive, 44 } 45 46 /// The kind of report to generate to the user 47 enum ReportKind { 48 /// As a plain text output 49 plain, 50 /// As a markdown report that 51 markdown, 52 /// As compiler warnings and a fix-it hint for the mutation 53 compiler, 54 /// As a JSON model 55 json, 56 /// In the CSV format 57 csv, 58 /// As a HTML report 59 html, 60 } 61 62 /// The level of reporting 63 enum ReportLevel { 64 /// Report a summary of the mutation statistics 65 summary, 66 /// Report alive mutants 67 alive, 68 /// Report all mutants 69 all 70 } 71 72 /// Sections to include in the report 73 enum ReportSection { 74 /// alive mutants 75 alive, 76 /// killed mutants 77 killed, 78 /// all mutants 79 all_mut, 80 /// summary section of the mutation testing 81 summary, 82 /// mutation statistics 83 mut_stat, 84 /// test cases that killed the mutant 85 tc_killed, 86 /// test case statistics 87 tc_stat, 88 /// test case mapping to killed mutants 89 tc_map, 90 /// test case suggestions for killing mutants 91 tc_suggestion, 92 /// Test cases that has killed zero mutants 93 tc_killed_no_mutants, 94 /// Test cases that kill the same mutants 95 tc_full_overlap, 96 /// Test cases that kill the same mutants with a mutation ID column 97 tc_full_overlap_with_mutation_id, 98 /// Test groups defined by the user 99 tc_groups, 100 /// Minimal set of tests 101 tc_min_set, 102 /// Similarity between test cases 103 tc_similarity, 104 /// Similarity between test groups 105 tc_groups_similarity, 106 /// A treemap of the mutation scores 107 treemap, 108 /// mutants that has survived that the plugin recommend the user to kill 109 mut_recommend_kill, 110 /// a section containing a diff and mutants for it 111 diff, 112 /// report of the mutants that only the test case kill 113 tc_unique, 114 /// mutants manually marked by user 115 marked_mutants 116 } 117 118 /// How to sort test cases when reporting them by their kill statistics. 119 enum ReportKillSortOrder { 120 /// From the top down 121 top, 122 /// From the botton up 123 bottom, 124 } 125 126 /// Administrative operation to perform 127 enum AdminOperation { 128 none, 129 /// Reset mutants to unknown 130 resetMutant, 131 /// 132 removeMutant, 133 /// 134 removeTestCase, 135 /// 136 markMutant, 137 /// 138 removeMarkedMutant, 139 /// 140 resetTestCase, 141 /// compact the database to reduce the disc space it takes up 142 compact, 143 /// force a mutation testing to stop testing timeout mutants 144 stopTimeoutTest 145 } 146 147 /// Builtin analyzers for testing frameworks that find failing test cases 148 enum TestCaseAnalyzeBuiltin { 149 /// Tracker for the GoogleTest framework 150 gtest, 151 /// Tracker for the CTest binary test runner 152 ctest, 153 /// Tracker for failing makefile targets 154 makefile, 155 } 156 157 /// A line in a file. 158 struct Line { 159 uint value; 160 } 161 162 /// A constraint for what to mutate during the test phase.. 163 struct TestConstraint { 164 Line[][Path] value; 165 166 bool empty() @safe pure nothrow const @nogc { 167 return value.length == 0; 168 } 169 } 170 171 struct ShellCommand { 172 import std.range : isOutputRange; 173 174 string[] value; 175 176 /// Split a user string by the whitespace to create an command+argument. 177 static ShellCommand fromString(string cmd) { 178 import std.uni : isWhite; 179 import std.array : split; 180 181 string[] args = cmd.split!isWhite; 182 return ShellCommand(args); 183 } 184 185 bool empty() @safe pure nothrow const @nogc { 186 return value.length == 0; 187 } 188 189 string toString() @safe pure const { 190 import std.array : appender; 191 192 auto buf = appender!string; 193 toString(buf); 194 return buf.data; 195 } 196 197 void toString(Writer)(ref Writer w) const if (isOutputRange!(Writer, char)) { 198 import std.format : formattedWrite; 199 200 formattedWrite(w, "shell command '%-(%s %)'", value); 201 } 202 }