aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/mutation/test.py
diff options
context:
space:
mode:
authorSandeep Hegde <dsandeephegde@gmail.com>2017-10-25 16:18:21 -0400
committerSandeep Hegde <dsandeephegde@gmail.com>2017-11-06 13:00:13 -0500
commit6688b8a146cbc4ade65c7c021aef4acf0b36bee6 (patch)
treeaef15108ab8bb832cab647eb046d292ca58b5381 /python/servo/mutation/test.py
parentc2d46c3b90264105bfa20ff6084f1fc9e054013b (diff)
downloadservo-6688b8a146cbc4ade65c7c021aef4acf0b36bee6.tar.gz
servo-6688b8a146cbc4ade65c7c021aef4acf0b36bee6.zip
Changed method to mutate a line of code
Diffstat (limited to 'python/servo/mutation/test.py')
-rw-r--r--python/servo/mutation/test.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/python/servo/mutation/test.py b/python/servo/mutation/test.py
index dd06871e65b..d3f4dd60ecb 100644
--- a/python/servo/mutation/test.py
+++ b/python/servo/mutation/test.py
@@ -14,11 +14,10 @@ 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()
+ for line in fileinput.input(file_name, inplace=True):
+ if(fileinput.lineno() == line_number):
+ line = re.sub(r'\s&&\s', ' || ', line)
+ print line.rstrip()
def mutation_test(file_name, tests):