blink_python_tests.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. # Copyright 2015 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. import json
  6. import os
  7. import sys
  8. # Add src/testing/ into sys.path for importing common without pylint errors.
  9. sys.path.append(
  10. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  11. from scripts import common
  12. def main_run(args):
  13. with common.temporary_file() as tempfile_path:
  14. rc = common.run_command([
  15. sys.executable,
  16. os.path.join(common.SRC_DIR, 'third_party', 'blink',
  17. 'tools', 'run_blinkpy_tests.py'),
  18. '--write-full-results-to', tempfile_path,
  19. ], cwd=args.paths['checkout'])
  20. with open(tempfile_path) as f:
  21. results = json.load(f)
  22. parsed_results = common.parse_common_test_results(results)
  23. failures = parsed_results['unexpected_failures']
  24. json.dump({
  25. 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
  26. ((rc == 0) or failures)),
  27. 'failures': failures.keys(),
  28. }, args.output)
  29. return rc
  30. def main_compile_targets(args):
  31. json.dump([], args.output)
  32. if __name__ == '__main__':
  33. funcs = {
  34. 'run': main_run,
  35. 'compile_targets': main_compile_targets,
  36. }
  37. sys.exit(common.run_script(sys.argv[1:], funcs))