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

Side by Side Diff: client/tools/jscoverage_wrapper.py

Issue 9837113: Move update.py to samples/swarm, remove a bunch of deprecated files for (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « client/tools/coverage.py ('k') | client/tools/scss.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file.
4
5 """Wraps jscoverage to instrument a single file more efficently.
6
7 JScoverage crawls directories recursively to copy and instrument everything
8 under a directory. This turns out to be too slow for our use, because our
9 generated .js files live in directories with > 100K files. Even though
10 jscoverage has a flag ('--exclude') to skip some files for
11 instrumentation/copying, it stills crawls recursively everything under the
12 directory.
13
14 This script is a simple wrap on top of jscoverage. It creates a temporary
15 directory, copies the file we want to instrument alone, and runs jscoverage
16 within this small directory.
17 """
18
19 import os
20 import subprocess
21 import sys
22
23 def main():
24 if len(sys.argv) < 3:
25 print "usage: %s <jscoverage-path> filepath outdir"
26 return 1
27
28 jscoveragecmd = sys.argv[1]
29 filepath = sys.argv[2]
30 outdir = sys.argv[3]
31
32 tmpdir = filepath + "_"
33 copypath = os.path.join(tmpdir, os.path.basename(filepath))
34 try:
35 os.mkdir(tmpdir)
36 except Exception:
37 if not os.path.exists(tmpdir):
38 raise
39 with open(filepath, 'r') as f1:
40 with open(copypath, 'w') as f2:
41 f2.write(f1.read())
42 status = subprocess.call([jscoveragecmd, tmpdir, outdir])
43 os.remove(copypath)
44 os.rmdir(tmpdir)
45 return status
46
47 if __name__ == '__main__':
48 sys.exit(main())
OLDNEW
« no previous file with comments | « client/tools/coverage.py ('k') | client/tools/scss.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698