aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/mutation
diff options
context:
space:
mode:
authorSandeep Hegde <dsandeephegde@gmail.com>2017-10-19 01:15:03 -0400
committerSandeep Hegde <dsandeephegde@gmail.com>2017-11-06 13:00:12 -0500
commitabbdcf0afc822fbce96f3b4ba152ceb9d0063740 (patch)
tree2960a8a1260b9a5a03c5b9257036904cd8e3ca14 /python/servo/mutation
parent0047c77f0374ec773fab1cb0c0b7fcfdbb6472d2 (diff)
downloadservo-abbdcf0afc822fbce96f3b4ba152ceb9d0063740.tar.gz
servo-abbdcf0afc822fbce96f3b4ba152ceb9d0063740.zip
XMLHTTPRequest Mutator - Initial step Mutation testing
Diffstat (limited to 'python/servo/mutation')
-rw-r--r--python/servo/mutation/test.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/python/servo/mutation/test.py b/python/servo/mutation/test.py
new file mode 100644
index 00000000000..f62045c0398
--- /dev/null
+++ b/python/servo/mutation/test.py
@@ -0,0 +1,35 @@
+import fileinput
+import re
+import subprocess
+import sys
+
+def mutate_line(file_name, line_number):
+ lines = open(file_name, 'r').readlines()
+ lines[line_number - 1] = re.sub(r'\s&&\s', ' || ', lines[line_number - 1])
+ out = open(file_name, 'w')
+ out.writelines(lines)
+ out.close()
+
+def mutation_test(file_name):
+ lineNumbers = []
+ for line in fileinput.input(file_name):
+ if re.search(r'\s&&\s', line):
+ lineNumbers.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)
+ sys.stdout.flush()
+ subprocess.call('python mach build --release', shell=True)
+ print "running tests for mutant {0}-{1}".format(file_name, lineToMutate)
+ sys.stdout.flush()
+ subprocess.call('python mach test-wpt XMLHttpRequest --release', shell=True)
+ 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')