Reviewers: jochen, Jakob,

Message:
PTAL

Description:
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=

Please review this at https://codereview.chromium.org/410893002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -15 lines):
  M build/landmines.py


Index: build/landmines.py
diff --git a/build/landmines.py b/build/landmines.py
index 2b3d7753c0db9fe26b1b9e659a0b8600bbadc287..fb8246f212f6cc7b483b8dcd2626dd7032bf32f6 100755
--- a/build/landmines.py
+++ b/build/landmines.py
@@ -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)



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to