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

Side by Side Diff: components/domain_reliability/bake_in_configs.py

Issue 656033008: Domain Reliability: Reenable AddBakedInConfigs test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase; don't print all json file names Created 6 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium 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 """Takes the JSON files in components/domain_reliability/baked_in_configs and 7 """Takes the JSON files in components/domain_reliability/baked_in_configs and
8 encodes their contents as an array of C strings that gets compiled in to Chrome 8 encodes their contents as an array of C strings that gets compiled in to Chrome
9 and loaded at runtime.""" 9 and loaded at runtime."""
10 10
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 json_files = read_json_files_from_gypi(gypi_file) 527 json_files = read_json_files_from_gypi(gypi_file)
528 528
529 cpp_code = CC_HEADER 529 cpp_code = CC_HEADER
530 found_invalid_config = False 530 found_invalid_config = False
531 for json_file in json_files: 531 for json_file in json_files:
532 with open(json_file, 'r') as f: 532 with open(json_file, 'r') as f:
533 json_text = f.read() 533 json_text = f.read()
534 try: 534 try:
535 config = json.loads(json_text) 535 config = json.loads(json_text)
536 except ValueError: 536 except ValueError, e:
537 print >> sys.stderr, "%s: error parsing JSON" % json_file 537 print >> sys.stderr, "%s: error parsing JSON: %s" % (json_file, e)
538 raise 538 found_invalid_config = True
539 continue
davidben 2014/10/20 20:51:31 Nit: could you add a sentence about this in the CL
Deprecated (see juliatuttle) 2014/10/20 21:07:47 Done.
539 if 'monitored_domain' not in config: 540 if 'monitored_domain' not in config:
540 print >> sys.stderr, '%s: no monitored_domain found' % json_file 541 print >> sys.stderr, '%s: no monitored_domain found' % json_file
541 found_invalid_config = True 542 found_invalid_config = True
542 continue 543 continue
543 domain = config['monitored_domain'] 544 domain = config['monitored_domain']
544 if not domain_is_whitelisted(domain): 545 if not domain_is_whitelisted(domain):
545 print >> sys.stderr, ('%s: monitored_domain "%s" not in whitelist' % 546 print >> sys.stderr, ('%s: monitored_domain "%s" not in whitelist' %
546 (json_file, domain)) 547 (json_file, domain))
547 found_invalid_config = True 548 found_invalid_config = True
548 continue 549 continue
549 cpp_code += " // " + json_file + ":\n" 550 cpp_code += " // " + json_file + ":\n"
550 cpp_code += quote_and_wrap_text(json_text) + ",\n" 551 cpp_code += quote_and_wrap_text(json_text) + ",\n"
551 cpp_code += "\n" 552 cpp_code += "\n"
552 cpp_code += CC_FOOTER 553 cpp_code += CC_FOOTER
553 554
554 if found_invalid_config: 555 if found_invalid_config:
555 return 1 556 return 1
davidben 2014/10/20 20:51:31 Does the build still fail if this happens? It seem
Deprecated (see juliatuttle) 2014/10/20 21:07:47 Yes, this is main, and it's wrapped in sys.exit be
556 557
557 with open(cpp_file, 'wb') as f: 558 with open(cpp_file, 'wb') as f:
558 f.write(cpp_code) 559 f.write(cpp_code)
559 560
560 return 0 561 return 0
561 562
562 563
563 if __name__ == '__main__': 564 if __name__ == '__main__':
564 sys.exit(main()) 565 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | components/domain_reliability/monitor_unittest.cc » ('j') | components/domain_reliability/monitor_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698