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 /// Statement deletion 29 sdl, 30 /// Decision/Condition Requirement 31 dcr, 32 /// Logical Connector Replacement Bit-wise 33 lcrb, 34 /// rithmetic operator replacement simple 35 aors, 36 /// constant replacement 37 cr, 38 } 39 40 /// The order the mutations are done when running in test_mutants mode 41 enum MutationOrder { 42 random, 43 consecutive, 44 bySize, 45 } 46 47 /// The kind of report to generate to the user 48 enum ReportKind { 49 /// As a plain text output 50 plain, 51 /// As compiler warnings and a fix-it hint for the mutation 52 compiler, 53 /// As a JSON model 54 json, 55 /// As a HTML report 56 html, 57 } 58 59 /// Sections to include in the report 60 enum ReportSection { 61 /// alive mutants 62 alive, 63 /// killed mutants 64 killed, 65 /// all mutants 66 all_mut, 67 /// summary section of the mutation testing 68 summary, 69 /// mutation statistics 70 mut_stat, 71 /// test cases that killed the mutant 72 tc_killed, 73 /// test case statistics 74 tc_stat, 75 /// test case mapping to killed mutants 76 tc_map, 77 /// test case suggestions for killing mutants 78 tc_suggestion, 79 /// Test cases that has killed zero mutants 80 tc_killed_no_mutants, 81 /// Test cases that kill the same mutants 82 tc_full_overlap, 83 /// Test cases that kill the same mutants with a mutation ID column 84 tc_full_overlap_with_mutation_id, 85 /// Test groups defined by the user 86 tc_groups, 87 /// Minimal set of tests 88 tc_min_set, 89 /// Similarity between test cases 90 tc_similarity, 91 /// Similarity between test groups 92 tc_groups_similarity, 93 /// mutants that has survived that the plugin recommend the user to kill 94 mut_recommend_kill, 95 /// a section containing a diff and mutants for it 96 diff, 97 /// report of the mutants that only the test case kill 98 tc_unique, 99 /// mutants manually marked by user 100 marked_mutants, 101 /// trend information of how mutation score is predicted to evolve 102 trend, 103 } 104 105 /// How to sort test cases when reporting them by their kill statistics. 106 enum ReportKillSortOrder { 107 /// From the top down 108 top, 109 /// From the botton up 110 bottom, 111 } 112 113 /// Administrative operation to perform 114 enum AdminOperation { 115 none, 116 /// Reset mutants to unknown 117 resetMutant, 118 /// 119 removeMutant, 120 /// 121 removeTestCase, 122 /// 123 markMutant, 124 /// 125 removeMarkedMutant, 126 /// 127 resetTestCase, 128 /// compact the database to reduce the disc space it takes up 129 compact, 130 /// force a mutation testing to stop testing timeout mutants 131 stopTimeoutTest, 132 /// Reset all mutants of a kind 133 resetMutantSubKind, 134 /// reset the worklist of mutants to test 135 clearWorklist, 136 } 137 138 /// Builtin analyzers for testing frameworks that find failing test cases 139 enum TestCaseAnalyzeBuiltin { 140 /// Tracker for the GoogleTest framework 141 gtest, 142 /// Tracker for the CTest binary test runner 143 ctest, 144 /// Tracker for failing makefile targets 145 makefile, 146 /// Only track the test_cmd 147 test_cmd 148 } 149 150 /// A line in a file. 151 struct Line { 152 uint value; 153 } 154 155 /// A constraint for what to mutate during the test phase.. 156 struct TestConstraint { 157 Line[][Path] value; 158 159 bool empty() @safe pure nothrow const @nogc { 160 return value.length == 0; 161 } 162 } 163 164 struct ShellCommand { 165 import std.algorithm : joiner; 166 import std.array : appender; 167 import std.format : formattedWrite; 168 import std.path : relativePath; 169 import std.range : isOutputRange, only; 170 import std.string : join; 171 172 string[] value; 173 174 bool empty() @safe pure nothrow const @nogc { 175 return value.length == 0; 176 } 177 178 string toString() @safe pure const { 179 auto buf = appender!string; 180 toString(buf); 181 return buf.data; 182 } 183 184 void toString(Writer)(ref Writer w) const if (isOutputRange!(Writer, char)) { 185 formattedWrite(w, "shell command '%-(%s %)'", value); 186 } 187 188 string toShortString() @safe nothrow const { 189 auto r = () nothrow{ 190 try { 191 return value[0].relativePath; 192 } catch (Exception e) { 193 } 194 return value[0]; 195 }(); 196 if (value.length == 1) 197 return r; 198 return only([r], value[1 .. $]).joiner.join(" "); 199 } 200 } 201 202 struct UserRuntime { 203 import dextool.plugin.mutate.backend.type : Language; 204 205 Path file; 206 Language lang; 207 } 208 209 enum SchemaRuntime : ubyte { 210 inject, 211 library, 212 } 213 214 enum CoverageRuntime : ubyte { 215 inject, 216 library, 217 } 218 219 enum MutantIdGeneratorConfig : ubyte { 220 relaxed, 221 strict, 222 }