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.config; 11 12 import core.time : Duration; 13 import std.typecons : Nullable; 14 15 import dextool.plugin.mutate.type; 16 import dextool.type : AbsolutePath, Path, ShellCommand; 17 public import dextool.plugin.mutate.backend : Mutation, TestGroup; 18 19 /// The mode the tool is operating in 20 enum ToolMode { 21 /// No mode set 22 none, 23 /// analyze for mutation points 24 analyzer, 25 /// center that can operate and control subcomponents 26 generate_mutant, 27 /// test mutation points with a test suite 28 test_mutants, 29 /// generate a report of the mutation points 30 report, 31 /// administrator interface for the mutation database 32 admin, 33 /// Dump the TOML configuration to the console 34 dumpConfig, 35 /// Write a TOML config to the filesystem 36 initConfig, 37 } 38 39 /// Config of the report. 40 struct ConfigReport { 41 ReportKind reportKind; 42 ReportLevel reportLevel; 43 ReportSection[] reportSection; 44 45 /// Directory to write logs to when writing to the filesystem. 46 AbsolutePath logDir; 47 48 /// Controls how to sort test cases by their kill statistics. 49 ReportKillSortOrder tcKillSortOrder; 50 int tcKillSortNum = 20; 51 52 /// User regex for reporting groups of tests 53 TestGroup[] testGroups; 54 55 /// If a unified diff should be used in the report 56 bool unifiedDiff; 57 } 58 59 /// Configuration data for the compile_commands.json 60 struct ConfigCompileDb { 61 import dextool.compilation_db : CompileCommandFilter; 62 63 /// Raw user input via either config or cli 64 string[] rawDbs; 65 66 /// path to compilation databases. 67 AbsolutePath[] dbs; 68 69 /// Flags the user wants to be automatically removed from the compile_commands.json. 70 CompileCommandFilter flagFilter; 71 } 72 73 /// Settings for the compiler 74 struct ConfigCompiler { 75 import dextool.compilation_db : SystemCompiler = Compiler; 76 77 /// Additional flags the user wants to add besides those that are in the compile_commands.json. 78 string[] extraFlags; 79 80 /// True requires system includes to be passed on to the compiler via -I 81 bool forceSystemIncludes; 82 83 /// Deduce compiler flags from this compiler and not the one in the 84 /// supplied compilation database. / This is needed when the one specified 85 /// in the DB has e.g. a c++ stdlib that is not compatible with clang. 86 SystemCompiler useCompilerSystemIncludes; 87 } 88 89 /// Settings for mutation testing 90 struct ConfigMutationTest { 91 ShellCommand mutationTester; 92 ShellCommand mutationCompile; 93 AbsolutePath mutationTestCaseAnalyze; 94 TestCaseAnalyzeBuiltin[] mutationTestCaseBuiltin; 95 Nullable!Duration mutationTesterRuntime; 96 MutationOrder mutationOrder; 97 bool dryRun; 98 99 /// How to behave when new test cases are detected. 100 enum NewTestCases { 101 doNothing, 102 /// Automatically reset alive mutants 103 resetAlive, 104 } 105 106 NewTestCases onNewTestCases; 107 108 /// How to behave when test cases are detected of having been removed 109 enum RemovedTestCases { 110 doNothing, 111 /// Remove it and all results connectedto the test case 112 remove, 113 } 114 115 RemovedTestCases onRemovedTestCases; 116 117 /// How to behave when mutants have aged. 118 enum OldMutant { 119 nothing, 120 test, 121 } 122 123 OldMutant onOldMutants; 124 long oldMutantsNr; 125 } 126 127 /// Settings for the administration mode 128 struct ConfigAdmin { 129 AdminOperation adminOp; 130 Mutation.Status mutantStatus; 131 Mutation.Status mutantToStatus; 132 string testCaseRegex; 133 } 134 135 struct ConfigWorkArea { 136 /// User input root. 137 string rawRoot; 138 string[] rawRestrict; 139 140 AbsolutePath outputDirectory; 141 AbsolutePath[] restrictDir; 142 }