-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #844 from mull-project/mutate-diffs
GitDiffFilter: expand -git-project-root argument to absolute path
- Loading branch information
Showing
5 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ons/06-reading-git-diff-and-filtering-expands-to-full-path/compile_commands.json.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"arguments": [ | ||
"cc", | ||
"-c", | ||
"-fembed-bitcode", | ||
"-g", | ||
"-O0", | ||
"-o", | ||
"%PWD/sample.cpp.exe", | ||
"%PWD/sample.cpp" | ||
], | ||
"directory": "/", | ||
"file": "%PWD/sample.cpp" | ||
} | ||
] |
34 changes: 34 additions & 0 deletions
34
...m-ir-functions/06-reading-git-diff-and-filtering-expands-to-full-path/sample.cpp.modified
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// clang-format off | ||
|
||
bool valid_age(int age) { | ||
if (age >= 21) { /// This comment line creates a diff with mutations! | ||
return true; | ||
} | ||
if (age >= 21) { | ||
(void)0; /// This comment line creates a diff with no mutations on the line. | ||
} | ||
return false; | ||
} | ||
|
||
int main() { | ||
bool test1 = valid_age(25) == true; | ||
if (!test1) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
bool test2 = valid_age(20) == false; | ||
if (!test2) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
bool test3 = valid_age(21) == true; | ||
if (!test3) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
/// success | ||
return 0; | ||
} |
34 changes: 34 additions & 0 deletions
34
...m-ir-functions/06-reading-git-diff-and-filtering-expands-to-full-path/sample.cpp.original
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// clang-format off | ||
|
||
bool valid_age(int age) { | ||
if (age >= 21) { | ||
return true; | ||
} | ||
if (age >= 21) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
int main() { | ||
bool test1 = valid_age(25) == true; | ||
if (!test1) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
bool test2 = valid_age(20) == false; | ||
if (!test2) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
bool test3 = valid_age(21) == true; | ||
if (!test3) { | ||
/// test failed | ||
return 1; | ||
} | ||
|
||
/// success | ||
return 0; | ||
} |
27 changes: 27 additions & 0 deletions
27
...ng-of-llvm-ir-functions/06-reading-git-diff-and-filtering-expands-to-full-path/test.itest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
RUN: cd %S | ||
RUN: mkdir -p %S/Output/sandbox | ||
RUN: cp %S/sample.cpp.original %S/Output/sandbox/sample.cpp | ||
RUN: cd %S/Output/sandbox | ||
RUN: git init . | ||
RUN: git add sample.cpp | ||
RUN: git -c user.name='Mull' -c user.email=alex@lowlevelbits.org commit -m "Impersonation is evil." | ||
RUN: cp %S/sample.cpp.modified %S/Output/sandbox/sample.cpp | ||
RUN: cd / && %CLANG_EXEC -fembed-bitcode -g -O0 %S/Output/sandbox/sample.cpp -o %S/Output/sample.cpp.exe | ||
|
||
/// The important part relevant to this test is -git-project-root=. (relative path is passed) | ||
RUN: cd %S/Output/sandbox && (unset TERM; %MULL_EXEC -debug -git-diff-ref=master -git-project-root=. -linker=%clang_cxx -mutators=cxx_ge_to_lt -mutators=cxx_ge_to_gt -ide-reporter-show-killed %S/Output/sample.cpp.exe 2>&1; test $? = 0) | %FILECHECK_EXEC %s --dump-input=fail --strict-whitespace --match-full-lines | ||
|
||
CHECK:[info] Incremental testing using Git Diff is enabled. | ||
CHECK:- Git ref: master | ||
CHECK:- Git project root: {{.*}}/Output/sandbox | ||
|
||
CHECK:[debug] GitDiffFilter: whitelisting instruction: {{.*}}/sample.cpp:4:7 | ||
CHECK:[debug] GitDiffFilter: whitelisting instruction: {{.*}}/sample.cpp:4:11 | ||
CHECK:[debug] GitDiffFilter: skipping instruction: {{.*}}/sample.cpp:7:7 | ||
CHECK:[debug] GitDiffFilter: skipping instruction: {{.*}}/sample.cpp:7:11 | ||
|
||
CHECK:[info] Killed mutants (2/2): | ||
CHECK:{{^.*}}sample.cpp:4:11: warning: Killed: Replaced >= with > [cxx_ge_to_gt]{{$}} | ||
CHECK:{{^.*}}sample.cpp:4:11: warning: Killed: Replaced >= with < [cxx_ge_to_lt]{{$}} | ||
CHECK:[info] All mutations have been killed | ||
CHECK:[info] Mutation score: 100% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters