mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Added Test Mapping framework and running through a path.
This commit is contained in:
parent
0d2ad9a5be
commit
ba2152900c
3 changed files with 48 additions and 10 deletions
10
components/script/dom/Test_mapping.json
Normal file
10
components/script/dom/Test_mapping.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"xmlhttprequest.rs":
|
||||||
|
[
|
||||||
|
"XMLHttpRequest"
|
||||||
|
],
|
||||||
|
"range.rs":
|
||||||
|
[
|
||||||
|
"dom/ranges"
|
||||||
|
]
|
||||||
|
}
|
29
python/servo/mutation/init.py
Normal file
29
python/servo/mutation/init.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isfile, isdir, join
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
import test
|
||||||
|
|
||||||
|
def get_folders_list(path):
|
||||||
|
folder_list = []
|
||||||
|
for filename in listdir(path):
|
||||||
|
if (isdir(join(path, filename))):
|
||||||
|
folder_name = join(path,filename)
|
||||||
|
folder_list.append(folder_name)
|
||||||
|
return(folder_list)
|
||||||
|
|
||||||
|
def mutation_test_for(mutation_path):
|
||||||
|
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)
|
||||||
|
|
||||||
|
for src_file in test_mapping.keys():
|
||||||
|
test.mutation_test(join(mutation_path,src_file.encode('utf-8')), test_mapping[src_file])
|
||||||
|
|
||||||
|
for folder in get_folders_list(mutation_path):
|
||||||
|
mutation_test_for(folder)
|
||||||
|
else:
|
||||||
|
print ("This folder %s has no test mapping file." %(mutation_path))
|
||||||
|
|
||||||
|
mutation_test_for(sys.argv[1])
|
|
@ -10,7 +10,7 @@ def mutate_line(file_name, line_number):
|
||||||
out.writelines(lines)
|
out.writelines(lines)
|
||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
def mutation_test(file_name):
|
def mutation_test(file_name, tests):
|
||||||
lineNumbers = []
|
lineNumbers = []
|
||||||
for line in fileinput.input(file_name):
|
for line in fileinput.input(file_name):
|
||||||
if re.search(r'\s&&\s', line):
|
if re.search(r'\s&&\s', line):
|
||||||
|
@ -21,17 +21,16 @@ def mutation_test(file_name):
|
||||||
mutate_line(file_name, lineToMutate)
|
mutate_line(file_name, lineToMutate)
|
||||||
print "compling mutant {0}-{1}".format(file_name, lineToMutate)
|
print "compling mutant {0}-{1}".format(file_name, lineToMutate)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
subprocess.call('python mach build --release', shell=True)
|
#subprocess.call('python mach build --release', shell=True)
|
||||||
print "running tests for mutant {0}-{1}".format(file_name, lineToMutate)
|
print "running tests for mutant {0}-{1}".format(file_name, lineToMutate)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
testStatus = subprocess.call('python mach test-wpt XMLHttpRequest --release', shell=True)
|
for test in tests:
|
||||||
|
testStatus = subprocess.call("python mach test-wpt {0} --release".format(test.encode('utf-8')), shell=True)
|
||||||
if testStatus != 0:
|
if testStatus != 0:
|
||||||
print('Failed in while running `python mach test-wpt XMLHttpRequest --release`')
|
print('Failed in while running `python mach test-wpt {0} --release`'.format(test.encode('utf-8')))
|
||||||
print "mutated file {0} diff".format(file_name)
|
print "mutated file {0} diff".format(file_name)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
subprocess.call('git --no-pager diff {0}'.format(file_name), shell=True)
|
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, lineToMutate)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
subprocess.call('git checkout {0}'.format(file_name), shell=True)
|
subprocess.call('git checkout {0}'.format(file_name), shell=True)
|
||||||
|
|
||||||
mutation_test('components/script/dom/xmlhttprequest.rs')
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue