Make landmines work on the first landmine.

With the original script, landmines don't work if the initial commit of the landmine script and the first landmine are in the same build. In this case, the landmine file wouldn't exist yet and no landmine would be triggered. But the updated landmine content would have still been written, omitting the landmine.

Now, the script will initialize an empty landmine file if none exists. This will make sure that a landmine is set on the branch builders after the next branch point.

This also adds some debugging output to better trace when landmines are set/deleted.

BUG=
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/410893002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22557 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent da52e6a6
......@@ -58,21 +58,26 @@ def set_up_landmines(target, new_landmines):
if not os.path.exists(out_dir):
return
if os.path.exists(landmines_path):
triggered = os.path.join(out_dir, '.landmines_triggered')
with open(landmines_path, 'r') as f:
old_landmines = f.readlines()
if old_landmines != new_landmines:
old_date = time.ctime(os.stat(landmines_path).st_ctime)
diff = difflib.unified_diff(old_landmines, new_landmines,
fromfile='old_landmines', tofile='new_landmines',
fromfiledate=old_date, tofiledate=time.ctime(), n=0)
with open(triggered, 'w') as f:
f.writelines(diff)
elif os.path.exists(triggered):
# Remove false triggered landmines.
os.remove(triggered)
# Make sure the landmines tracker exists.
open(landmines_path, 'a').close()
triggered = os.path.join(out_dir, '.landmines_triggered')
with open(landmines_path, 'r') as f:
old_landmines = f.readlines()
if old_landmines != new_landmines:
old_date = time.ctime(os.stat(landmines_path).st_ctime)
diff = difflib.unified_diff(old_landmines, new_landmines,
fromfile='old_landmines', tofile='new_landmines',
fromfiledate=old_date, tofiledate=time.ctime(), n=0)
with open(triggered, 'w') as f:
f.writelines(diff)
print "Setting landmine: %s" % triggered
print "Reason:\n%s" % diff
elif os.path.exists(triggered):
# Remove false triggered landmines.
os.remove(triggered)
print "Removing landmine: %s" % triggered
with open(landmines_path, 'w') as f:
f.writelines(new_landmines)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment