grit_python_unittests.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # Copyright 2019 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. """//testing/scripts wrapper for the grit unittests. This script is used to run
  6. test_suite_all.py on the trybots to ensure that grit is working correctly on
  7. all platforms."""
  8. import json
  9. import os
  10. import sys
  11. # Add src/testing/ into sys.path for importing common without pylint errors.
  12. sys.path.append(
  13. os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
  14. from scripts import common
  15. def main_run(args):
  16. rc = common.run_command([
  17. sys.executable,
  18. os.path.join(common.SRC_DIR, 'tools', 'grit', 'grit',
  19. 'test_suite_all.py'),
  20. ])
  21. json.dump({
  22. 'valid': True,
  23. 'failures': ['Please refer to stdout for errors.'] if rc else [],
  24. }, args.output)
  25. return rc
  26. def main_compile_targets(args):
  27. json.dump([], args.output)
  28. if __name__ == '__main__':
  29. funcs = {
  30. 'run': main_run,
  31. 'compile_targets': main_compile_targets,
  32. }
  33. sys.exit(common.run_script(sys.argv[1:], funcs))