aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandeep Hegde <dsandeephegde@gmail.com>2017-10-25 19:56:26 -0400
committerSandeep Hegde <dsandeephegde@gmail.com>2017-11-06 13:00:13 -0500
commit2b8b98d3a669461775fc30bff88237a9d9055311 (patch)
tree29bf46cdc50ede4a0e4016c098dbd3d519c4ab69
parent6688b8a146cbc4ade65c7c021aef4acf0b36bee6 (diff)
downloadservo-2b8b98d3a669461775fc30bff88237a9d9055311.tar.gz
servo-2b8b98d3a669461775fc30bff88237a9d9055311.zip
Removed build and wpt-test output from mutation test log and refactored code.
-rw-r--r--python/servo/mutation/init.py12
-rw-r--r--python/servo/mutation/test.py29
2 files changed, 22 insertions, 19 deletions
diff --git a/python/servo/mutation/init.py b/python/servo/mutation/init.py
index 5cf7c1fce48..6087dc2500d 100644
--- a/python/servo/mutation/init.py
+++ b/python/servo/mutation/init.py
@@ -17,21 +17,21 @@ import test
def get_folders_list(path):
folder_list = []
for filename in listdir(path):
- if (isdir(join(path, filename))):
+ if isdir(join(path, filename)):
folder_name = join(path, filename)
folder_list.append(folder_name)
- return(folder_list)
+ return folder_list
def mutation_test_for(mutation_path):
- test_mapping_file = join(mutation_path, 'Test_mapping.json')
- if(isfile(test_mapping_file)):
+ test_mapping_file = join(mutation_path, 'test_mapping.json')
+ if isfile(test_mapping_file):
json_data = open(test_mapping_file).read()
test_mapping = json.loads(json_data)
-
+ # Run mutation test for all source files in mapping file.
for src_file in test_mapping.keys():
test.mutation_test(join(mutation_path, src_file.encode('utf-8')), test_mapping[src_file])
-
+ # Run mutation test in all folder in the path.
for folder in get_folders_list(mutation_path):
mutation_test_for(folder)
else:
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)