Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMutation testing for Servo #18529
Mutation testing for Servo #18529
Comments
|
This came up in a conversation with Lonnen about a similar project on Firefox, so he can also be a resource if someone or a team embarks on this. |
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
|
We have done initial steps Mutation testing project. This is our pull request
|
|
Test mapping is introduced to reduce the time taken to run the tests. As for each mutant, we need to run only small part of the WPT tests, It would be time-consuming to run all tests so a multiple number of times. sample test_mapping.josn
Now test mapping is present for a couple of known source code files. The rest of the mapping needs to be filled. We need to come up with a way finding out test mapping for WPT tests. It could be done by something similar to the test coverage tool, which keeps track of the code executed when the tests run. Is there code coverage tool for WPT test in servo? |
|
There is no code coverage tool for tests in Servo, unfortunately. |
|
Then the only way is to add the mapping manually by a person who knows about the particular part of the code? It would be a cumbersome task. |
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
Initial steps of Mutation testing <!-- Please describe your changes on the following line: --> - Added one strategy of mutation which is replacing occurrences && to ||. - Added test mapping framework for running mutation tests corresponding to a mutant. - Added one test_mapping.json to map source file in a folder to WPT test. - Added README mentioning about Mutation testing. - Added CI script to invoke mutation test. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes #18529 (github issue number if applicable). - [x] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18984) <!-- Reviewable:end -->
|
We are now implementing more strategies we would need more test mappings so that we can run it on more files. So if manually adding the test mapping is the only solution then someone can start with it. We need suggestion on these approaches. Appreciate your thoughts. |
|
What's wrong with falling back to all tests for any files that do not have known mappings? |
|
Time would be the main constraint here. Each mutant will take 25-30mins. If we scale it to the whole servo project there are ~1000 source files then it will take days. |
|
Could we procedurally generate the mappings using a one-time, highly aggressive set of tests? Basically perform a mutation that's guaranteed to break any tests relevant to the file, then use whichever tests break as a result as the list of tests which map to that file. I'm pretty sure the mutation of deleting each function's body and replacing it with a single line to return a constant of that function's type would be such a "guaranteed mutation". |
|
Yes, this looks like a very good option to generate test mapping, with a few manual verification. We should definitely consider this approach. But, we currently don't have such a strong mutation strategy, which will not have a lot of false negatives (no test mapping is generated even if there should be one). So, the plan is to finish the existing goals in this project, then come back to this when we are better equipped to tackle this. |
Mutation Test: with more mutation strategies <!-- Please describe your changes on the following line: --> 1. Added following mutation strategies: - If True (make if always true) - If False(make if always false) - Modify Comparision (<= to <, >= to >) - Plus To Minus - Minus To Plus - Changing Atomic Strings (make string constant empty) - Duplicate Line - Delete If Block 2. Randomized the test order. 3. Introduced logging instead of print. 4. Added retry mechanism when mutation cannot be performed on a file by a strategy. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes #18529 (github issue number if applicable). <!-- Either: --> - [X] These changes do not require tests because it is a python script to run mutation test and does not change any behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19417) <!-- Reviewable:end -->
|
This was implemented. |
Implement mutation testing (https://en.wikipedia.org/wiki/Mutation_testing) for Servo, based on the WPT test suite.