Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: build/landmines.py

Issue 457063002: Fix v8 landmines script. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/run-tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 the V8 project authors. All rights reserved. 2 # Copyright 2014 the V8 project authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 This script runs every build as a hook. If it detects that the build should 7 This script runs every build as a hook. If it detects that the build should
8 be clobbered, it will touch the file <build_dir>/.landmine_triggered. The 8 be clobbered, it will touch the file <build_dir>/.landmine_triggered. The
9 various build scripts will then check for the presence of this file and clobber 9 various build scripts will then check for the presence of this file and clobber
10 accordingly. The script will also emit the reasons for the clobber to stdout. 10 accordingly. The script will also emit the reasons for the clobber to stdout.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 """Does the work of setting, planting, and triggering landmines.""" 54 """Does the work of setting, planting, and triggering landmines."""
55 out_dir = get_target_build_dir(landmine_utils.builder(), target) 55 out_dir = get_target_build_dir(landmine_utils.builder(), target)
56 56
57 landmines_path = os.path.join(out_dir, '.landmines') 57 landmines_path = os.path.join(out_dir, '.landmines')
58 if not os.path.exists(out_dir): 58 if not os.path.exists(out_dir):
59 return 59 return
60 60
61 if not os.path.exists(landmines_path): 61 if not os.path.exists(landmines_path):
62 print "Landmines tracker didn't exists." 62 print "Landmines tracker didn't exists."
63 63
64 # Make sure the landmines tracker exists. 64 # FIXME(machenbach): Clobber deletes the .landmines tracker. Difficult
65 open(landmines_path, 'a').close() 65 # to know if we are right after a clobber or if it is first-time landmines
66 # deployment. Also, a landmine-triggered clobber right after a clobber is
67 # not possible. Different clobber methods for msvs, xcode and make all
68 # have different blacklists of files that are not deleted.
69 if os.path.exists(landmines_path):
70 triggered = os.path.join(out_dir, '.landmines_triggered')
71 with open(landmines_path, 'r') as f:
72 old_landmines = f.readlines()
73 if old_landmines != new_landmines:
74 old_date = time.ctime(os.stat(landmines_path).st_ctime)
75 diff = difflib.unified_diff(old_landmines, new_landmines,
76 fromfile='old_landmines', tofile='new_landmines',
77 fromfiledate=old_date, tofiledate=time.ctime(), n=0)
66 78
67 triggered = os.path.join(out_dir, '.landmines_triggered') 79 with open(triggered, 'w') as f:
68 with open(landmines_path, 'r') as f: 80 f.writelines(diff)
69 old_landmines = f.readlines() 81 print "Setting landmine: %s" % triggered
70 if old_landmines != new_landmines: 82 elif os.path.exists(triggered):
71 old_date = time.ctime(os.stat(landmines_path).st_ctime) 83 # Remove false triggered landmines.
72 diff = difflib.unified_diff(old_landmines, new_landmines, 84 os.remove(triggered)
73 fromfile='old_landmines', tofile='new_landmines', 85 print "Removing landmine: %s" % triggered
74 fromfiledate=old_date, tofiledate=time.ctime(), n=0)
75
76 with open(triggered, 'w') as f:
77 f.writelines(diff)
78 print "Setting landmine: %s" % triggered
79 elif os.path.exists(triggered):
80 # Remove false triggered landmines.
81 os.remove(triggered)
82 print "Removing landmine: %s" % triggered
83 with open(landmines_path, 'w') as f: 86 with open(landmines_path, 'w') as f:
84 f.writelines(new_landmines) 87 f.writelines(new_landmines)
85 with open(landmines_path, 'r') as f:
86 print "Content of the landmines tracker:"
87 print f.read()
88 88
89 89
90 def process_options(): 90 def process_options():
91 """Returns a list of landmine emitting scripts.""" 91 """Returns a list of landmine emitting scripts."""
92 parser = optparse.OptionParser() 92 parser = optparse.OptionParser()
93 parser.add_option( 93 parser.add_option(
94 '-s', '--landmine-scripts', action='append', 94 '-s', '--landmine-scripts', action='append',
95 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], 95 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')],
96 help='Path to the script which emits landmines to stdout. The target ' 96 help='Path to the script which emits landmines to stdout. The target '
97 'is passed to this script via option -t. Note that an extra ' 97 'is passed to this script via option -t. Note that an extra '
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) 130 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
131 131
132 for target in ('Debug', 'Release'): 132 for target in ('Debug', 'Release'):
133 set_up_landmines(target, landmines) 133 set_up_landmines(target, landmines)
134 134
135 return 0 135 return 0
136 136
137 137
138 if __name__ == '__main__': 138 if __name__ == '__main__':
139 sys.exit(main()) 139 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/run-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698