Skip to content

Commit

Permalink
use extra parameter for patch base path
Browse files Browse the repository at this point in the history
  • Loading branch information
m42e committed Oct 31, 2021
1 parent f7aa8f8 commit de83b76
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 3 deletions.
28 changes: 28 additions & 0 deletions tests-lit/tests/patch-reporter/reporter_path_base/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
int equal(int a, int b) {
return a == b;
}

int main() {
return equal(2, 2) != 1;
}

// clang-format off
/**
RUN: cd %S
RUN: mkdir -p %S/Output/sandbox
RUN: cp %S/main.cpp %S/Output/sandbox/main.cpp
RUN: cd %S/Output/sandbox
/// We cd to the the test directory and compile using relative paths.
RUN: cd %S; %clang_cxx %sysroot -fembed-bitcode -g -O0 Output/sandbox/main.cpp -o Output/main.cpp.exe
RUN: cd %S/Output && echo $PATH; (unset TERM; %mull_cxx -mutators=cxx_eq_to_ne -linker-flags="%sysroot" --git-project-root %S/Output --report-patch-base %S --linker=%clang_cxx -debug main.cpp.exe --report-name test --reporters Patches --reporters IDE; test $? = 0; ls -R %S/Output/test-patches; cat %S/Output/test-patches/killed-Output_sandbox_main_cpp-cxx_eq_to_ne-L2-C12.patch) | %filecheck %s --dump-input=fail --strict-whitespace --match-full-lines
CHECK:[debug] Writing Patchfile: {{.*}}
CHECK:[info] Patchfiles can be found at './test-patches'
CHECK:{{.*}}main_cpp{{.*}}
CHECK:--- a/Output/sandbox/main.cpp 0
CHECK:+{{\s+}}return a != b;
*/
2 changes: 1 addition & 1 deletion tools/CLIOptions/CLIOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::vector<std::unique_ptr<Reporter>> ReportersCLIOptions::reporters(ReporterPa
reporters.emplace_back(new mull::SQLiteReporter(diagnostics, directory, name));
} break;
case ReporterKind::Patches: {
reporters.emplace_back(new mull::PatchesReporter(diagnostics, directory, name, params.gitDir));
reporters.emplace_back(new mull::PatchesReporter(diagnostics, directory, name, params.patchBasePathDir));
} break;
case ReporterKind::Elements: {
if (!params.compilationDatabaseAvailable) {
Expand Down
11 changes: 10 additions & 1 deletion tools/CLIOptions/CLIOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ opt<std::string> ReportName( \
init(""), \
cat(MullCategory))

#define ReportPatchBaseDirectory_() \
opt<std::string> ReportPatchBaseDirectory( \
"report-patch-base", \
desc("Create Patches relative to this directory (defaults to git-project-root if available, else absolute path will be used)"), \
Optional, \
value_desc("directory"), \
init("."), \
cat(MullCategory))

#define DisableJunkDetection_() \
opt<bool> DisableJunkDetection( \
"disable-junk-detection", \
Expand Down Expand Up @@ -311,7 +320,7 @@ class MutatorsCLIOptions {
struct ReporterParameters {
std::string reporterName;
std::string reporterDirectory;
std::string gitDir;
std::string patchBasePathDir;
bool compilationDatabaseAvailable;
bool IDEReporterShowKilled;
};
Expand Down
2 changes: 2 additions & 0 deletions tools/mull-cxx/mull-cxx-cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ NoTestOutput_();
NoMutantOutput_();
ReportName_();
ReportDirectory_();
ReportPatchBaseDirectory_();
Mutators_();
DryRunOption_();
Linker_();
Expand Down Expand Up @@ -54,6 +55,7 @@ void dumpCLIInterface(Diagnostics &diagnostics) {

&ReportName,
&ReportDirectory,
&ReportPatchBaseDirectory,
reporters,
&IDEReporterShowKilled,
&DebugEnabled,
Expand Down
5 changes: 4 additions & 1 deletion tools/mull-cxx/mull-cxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,12 @@ int main(int argc, char **argv) {

tool::ReporterParameters params{ .reporterName = tool::ReportName.getValue(),
.reporterDirectory = tool::ReportDirectory.getValue(),
.patchBasePathDir = tool::ReportPatchBaseDirectory.getValue(),
.compilationDatabaseAvailable = compilationDatabaseInfoAvailable,
.gitDir = tool::GitProjectRoot.getValue(),
.IDEReporterShowKilled = tool::IDEReporterShowKilled };
if(tool::ReportPatchBaseDirectory.getValue() == "." && tool::GitProjectRoot.getValue() != "."){
params.patchBasePathDir = tool::GitProjectRoot.getValue();
}
std::vector<std::unique_ptr<mull::Reporter>> reporters = reportersOption.reporters(params);

mull::CXXJunkDetector junkDetector(diagnostics, astStorage);
Expand Down
1 change: 1 addition & 0 deletions tools/mull-runner/mull-runner-cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NoTestOutput_();
NoMutantOutput_();
ReportName_();
ReportDirectory_();
ReportPatchBaseDirectory_();
IDEReporterShowKilled_();
IncludeNotCovered_();
RunnerArgs_();
Expand Down
3 changes: 3 additions & 0 deletions tools/mull-runner/mull-runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ int main(int argc, char **argv) {
configuration.captureMutantOutput = false;
}


tool::ReporterParameters params{ .reporterName = tool::ReportName.getValue(),
.reporterDirectory = tool::ReportDirectory.getValue(),
.patchBasePathDir = tool::ReportPatchBaseDirectory.getValue(),
.compilationDatabaseAvailable = false,
.IDEReporterShowKilled = tool::IDEReporterShowKilled };

std::vector<std::unique_ptr<mull::Reporter>> reporters = reportersOption.reporters(params);

std::string executable = inputFile;
Expand Down

0 comments on commit de83b76

Please sign in to comment.