diff options
author | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-11-12 01:18:29 -0500 |
---|---|---|
committer | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-11-12 23:43:04 -0500 |
commit | cc6c2eea6ede64280684b5c98795a207c4b78192 (patch) | |
tree | 757d5ecb1bf74fa6ec65f2af8688f93e77ce2840 /python/servo/mutation/test.py | |
parent | b8199e11e018d1e4fa35d3ebbe3dbf934cd258d2 (diff) | |
download | servo-cc6c2eea6ede64280684b5c98795a207c4b78192.tar.gz servo-cc6c2eea6ede64280684b5c98795a207c4b78192.zip |
Added mutation test summary and made it exit with relevant exit code
Diffstat (limited to 'python/servo/mutation/test.py')
-rw-r--r-- | python/servo/mutation/test.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/servo/mutation/test.py b/python/servo/mutation/test.py index b004dc3fcd9..46bd3950778 100644 --- a/python/servo/mutation/test.py +++ b/python/servo/mutation/test.py @@ -13,9 +13,17 @@ import subprocess import sys import os import random +from enum import Enum DEVNULL = open(os.devnull, 'wb') +class Status(Enum): + PASSED = 0 + FAILED = 1 + SKIPPED = 2 + UNEXPECTED = 3 + + def mutate_random_line(file_name): line_numbers = [] for line in fileinput.input(file_name): @@ -33,8 +41,10 @@ def mutate_random_line(file_name): def mutation_test(file_name, tests): + status = Status.UNEXPECTED local_changes_present = subprocess.call('git diff --quiet {0}'.format(file_name), shell=True) if local_changes_present == 1: + status = Status.SKIPPED print "{0} has local changes, please commit/remove changes before running the test".format(file_name) else: mutated_line = mutate_random_line(file_name) @@ -53,8 +63,10 @@ def mutation_test(file_name, tests): print "mutated file {0} diff".format(file_name) sys.stdout.flush() subprocess.call('git --no-pager diff {0}'.format(file_name), shell=True) + status = Status.FAILED else: print("Success: Mutation killed by {0}".format(test.encode('utf-8'))) + status = Status.PASSED break print "reverting mutant {0}:{1}".format(file_name, mutated_line) sys.stdout.flush() @@ -62,3 +74,4 @@ def mutation_test(file_name, tests): else: print "Cannot mutate {0}".format(file_name) print "-" * 80 + "\n" + return status |