diff options
author | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-10-25 19:56:26 -0400 |
---|---|---|
committer | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-11-06 13:00:13 -0500 |
commit | 2b8b98d3a669461775fc30bff88237a9d9055311 (patch) | |
tree | 29bf46cdc50ede4a0e4016c098dbd3d519c4ab69 /python/servo/mutation/test.py | |
parent | 6688b8a146cbc4ade65c7c021aef4acf0b36bee6 (diff) | |
download | servo-2b8b98d3a669461775fc30bff88237a9d9055311.tar.gz servo-2b8b98d3a669461775fc30bff88237a9d9055311.zip |
Removed build and wpt-test output from mutation test log and refactored code.
Diffstat (limited to 'python/servo/mutation/test.py')
-rw-r--r-- | python/servo/mutation/test.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/python/servo/mutation/test.py b/python/servo/mutation/test.py index d3f4dd60ecb..e86d237351d 100644 --- a/python/servo/mutation/test.py +++ b/python/servo/mutation/test.py @@ -11,36 +11,39 @@ import fileinput import re import subprocess import sys +import os +DEVNULL = open(os.devnull, 'wb') def mutate_line(file_name, line_number): for line in fileinput.input(file_name, inplace=True): - if(fileinput.lineno() == line_number): + if fileinput.lineno() == line_number: line = re.sub(r'\s&&\s', ' || ', line) print line.rstrip() def mutation_test(file_name, tests): - lineNumbers = [] + line_numbers = [] for line in fileinput.input(file_name): if re.search(r'\s&&\s', line): - lineNumbers.append(fileinput.lineno()) + line_numbers.append(fileinput.lineno()) - for lineToMutate in lineNumbers: - print "Mutating {0} at line {1}".format(file_name, lineToMutate) - mutate_line(file_name, lineToMutate) - print "compling mutant {0}-{1}".format(file_name, lineToMutate) + for line_to_mutate in line_numbers: + print "Mutating {0} at line {1}".format(file_name, line_to_mutate) + mutate_line(file_name, line_to_mutate) + print "compling mutant {0}:{1}".format(file_name, line_to_mutate) sys.stdout.flush() - subprocess.call('python mach build --release', shell=True) - print "running tests for mutant {0}-{1}".format(file_name, lineToMutate) + subprocess.call('python mach build --release', shell=True, stdout=DEVNULL) + print "running tests for mutant {0}:{1}".format(file_name, line_to_mutate) sys.stdout.flush() for test in tests: - testStatus = subprocess.call("python mach test-wpt {0} --release".format(test.encode('utf-8')), shell=True) - if testStatus != 0: - print('Failed in while running `python mach test-wpt {0} --release`'.format(test.encode('utf-8'))) + test_command = "python mach test-wpt {0} --release".format(test.encode('utf-8')) + test_status = subprocess.call(test_command, shell=True, stdout=DEVNULL) + if test_status != 0: + print("Failed in while running `{0}`".format(test_command)) print "mutated file {0} diff".format(file_name) sys.stdout.flush() subprocess.call('git --no-pager diff {0}'.format(file_name), shell=True) - print "reverting mutant {0}-{1}".format(file_name, lineToMutate) + print "reverting mutant {0}:{1}".format(file_name, line_to_mutate) sys.stdout.flush() subprocess.call('git checkout {0}'.format(file_name), shell=True) |