diff options
author | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-10-24 22:16:48 -0400 |
---|---|---|
committer | Sandeep Hegde <dsandeephegde@gmail.com> | 2017-11-06 13:00:12 -0500 |
commit | ba2152900cc0aa82e62905033e943fb3e4320945 (patch) | |
tree | 087e04d17b1483bae08bab3b306d6fd6497a6c77 | |
parent | 0d2ad9a5beebfb2ac19e99139dd6ddb747bb4bbb (diff) | |
download | servo-ba2152900cc0aa82e62905033e943fb3e4320945.tar.gz servo-ba2152900cc0aa82e62905033e943fb3e4320945.zip |
Added Test Mapping framework and running through a path.
-rw-r--r-- | components/script/dom/Test_mapping.json | 10 | ||||
-rw-r--r-- | python/servo/mutation/init.py | 29 | ||||
-rw-r--r-- | python/servo/mutation/test.py | 19 |
3 files changed, 48 insertions, 10 deletions
diff --git a/components/script/dom/Test_mapping.json b/components/script/dom/Test_mapping.json new file mode 100644 index 00000000000..6ea27ad36ae --- /dev/null +++ b/components/script/dom/Test_mapping.json @@ -0,0 +1,10 @@ +{
+ "xmlhttprequest.rs":
+ [
+ "XMLHttpRequest"
+ ],
+ "range.rs":
+ [
+ "dom/ranges"
+ ]
+}
diff --git a/python/servo/mutation/init.py b/python/servo/mutation/init.py new file mode 100644 index 00000000000..e3d4aea9bcd --- /dev/null +++ b/python/servo/mutation/init.py @@ -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]) diff --git a/python/servo/mutation/test.py b/python/servo/mutation/test.py index 790789f3fdd..533e7cffe4b 100644 --- a/python/servo/mutation/test.py +++ b/python/servo/mutation/test.py @@ -10,7 +10,7 @@ def mutate_line(file_name, line_number): out.writelines(lines) out.close() -def mutation_test(file_name): +def mutation_test(file_name, tests): lineNumbers = [] for line in fileinput.input(file_name): if re.search(r'\s&&\s', line): @@ -21,17 +21,16 @@ def mutation_test(file_name): mutate_line(file_name, lineToMutate) print "compling mutant {0}-{1}".format(file_name, lineToMutate) 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) sys.stdout.flush() - testStatus = subprocess.call('python mach test-wpt XMLHttpRequest --release', shell=True) - if testStatus != 0: - print('Failed in while running `python mach test-wpt XMLHttpRequest --release`') - print "mutated file {0} diff".format(file_name) - sys.stdout.flush() - subprocess.call('git --no-pager diff {0}'.format(file_name), 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: + print('Failed in while running `python mach test-wpt {0} --release`'.format(test.encode('utf-8'))) + 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) sys.stdout.flush() subprocess.call('git checkout {0}'.format(file_name), shell=True) - -mutation_test('components/script/dom/xmlhttprequest.rs') |