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

Side by Side Diff: swarm_client/tests/run_isolated/regen_test_data.py

Issue 69143004: Delete swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Regenerates all the .isolated test data files.
7
8 Keep in sync with ../run_isolated_smoke_test.py.
9 """
10
11 import glob
12 import hashlib
13 import json
14 import os
15 import sys
16
17 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
18
19
20 # Ordering is important to keep this script simple.
21 INCLUDES_TO_FIX = [
22 ('manifest2.isolated', ['manifest1.isolated']),
23 ('check_files.isolated', ['manifest2.isolated', 'repeated_files.isolated']),
24 ]
25
26
27 def sha1(filename):
28 with open(filename, 'rb') as f:
29 return hashlib.sha1(f.read()).hexdigest()
30
31
32 def load(filename):
33 with open(filename, 'r') as f:
34 return json.load(f)
35
36
37 def save(filename, data):
38 """Saves data as json properly formatted.
39
40 Strips spurious whitespace json.dump likes to add at the end of lines and add
41 a trailing \n.
42 """
43 out = ''.join(
44 '%s\n' % l.rstrip()
45 for l in json.dumps(data, indent=2, sort_keys=True).splitlines())
46 with open(filename, 'wb') as f:
47 f.write(out)
48
49
50 def main():
51 # Simplify our life.
52 os.chdir(ROOT_DIR)
53
54 # First, reformat all the files.
55 for filename in glob.glob('*.isolated'):
56 save(filename, load(filename))
57
58 # Then update the SHA-1s.
59 for manifest, includes in INCLUDES_TO_FIX:
60 data = load(manifest)
61 data['includes'] = [sha1(f) for f in includes]
62 save(manifest, data)
63 return 0
64
65
66 if __name__ == '__main__':
67 sys.exit(main())
OLDNEW
« no previous file with comments | « swarm_client/tests/run_isolated/manifest2.isolated ('k') | swarm_client/tests/run_isolated/repeated_files.isolated » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698