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 } 144 145 /// Builtin analyzers for testing frameworks that find failing test cases 146 enum TestCaseAnalyzeBuiltin { 147 /// Tracker for the GoogleTest framework 148 gtest, 149 /// Tracker for the CTest binary test runner 150 ctest, 151 /// Tracker for failing makefile targets 152 makefile, 153 } 154 155 /// A line in a file. 156 struct Line { 157 uint value; 158 } 159 160 /// A constraint for what to mutate during the test phase.. 161 struct TestConstraint { 162 Line[][Path] value; 163 164 bool empty() @safe pure nothrow const @nogc { 165 return value.length == 0; 166 } 167 } 168 169 struct ShellCommand { 170 import std.range : isOutputRange; 171 172 string[] value; 173 174 /// Split a user string by the whitespace to create an command+argument. 175 static ShellCommand fromString(string cmd) { 176 import std.uni : isWhite; 177 import std.array : split; 178 179 string[] args = cmd.split!isWhite; 180 return ShellCommand(args); 181 } 182 183 bool empty() @safe pure nothrow const @nogc { 184 return value.length == 0; 185 } 186 187 string toString() @safe pure const { 188 import std.array : appender; 189 190 auto buf = appender!string; 191 toString(buf); 192 return buf.data; 193 } 194 195 void toString(Writer)(ref Writer w) const if (isOutputRange!(Writer, char)) { 196 import std.format : formattedWrite; 197 198 formattedWrite(w, "shell command '%-(%s %)'", value); 199 } 200 }