Skip to content

Commit

Permalink
Fix patch reporting for CXXAssignConst
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDenisov committed Jun 2, 2023
1 parent 194486d commit 72d9863
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Mutators/CXX/NumberMutators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ std::string NumberAssignConst::ID() {

NumberAssignConst::NumberAssignConst()
: TrivialCXXMutator(getNumberMutators(), MutatorKind::CXX_AssignConst, NumberAssignConst::ID(),
"Replaces 'a = b' with 'a = 42'", "42", "Replaced 'a = b' with 'a = 42'") {}
"Replaces 'a = b' with 'a = 42'", "= 42;",
"Replaced 'a = b' with 'a = 42'") {}
std::string NumberInitConst::ID() {
return "cxx_init_const";
Expand Down
32 changes: 32 additions & 0 deletions tests-lit/tests/reporters/patch-reporter/cxx_assign_const/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// clang-format off
void assign(int *x, int y) {
x[0] = y;
}

int main() {
int x = 15;
assign(&x, 10);

return 0;
}

/**
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 -O0 %pass_mull_ir_frontend -g Output/sandbox/main.cpp -o Output/main.cpp-ir.exe
RUN: cd %S/Output; (unset TERM; %mull_runner -debug ./main.cpp-ir.exe --report-name test-ir --reporters Patches --reporters IDE; test $? = 0; ls -R %S/Output/test-ir-patches; cd %S/Output/test-ir-patches; cat `ls`) | %filecheck %s --dump-input=fail --strict-whitespace --match-full-lines
CHECK:[debug] Writing Patchfile: {{.*}}
CHECK:[info] Patchfiles can be found at './test{{.*}}-patches'
CHECK:survived-{{.*}}main_cpp{{.*}}
CHECK:--- a/{{.*}}/Output/sandbox/main.cpp 0
CHECK:+++ b/{{.*}}/Output/sandbox/main.cpp 0
CHECK:+{{\s+}}x[0] = 42; y;
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mutators:
- cxx_assign_const
quiet: false

0 comments on commit 72d9863

Please sign in to comment.