You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

  1. """Run Python's test suite in a fast, rigorous way.
  2. The defaults are meant to be reasonably thorough, while skipping certain
  3. tests that can be time-consuming or resource-intensive (e.g. largefile),
  4. or distracting (e.g. audio and gui). These defaults can be overridden by
  5. simply passing a -u option to this script.
  6. """
  7. import os
  8. import sys
  9. import test.support
  10. def is_multiprocess_flag(arg):
  11. return arg.startswith('-j') or arg.startswith('--multiprocess')
  12. def is_resource_use_flag(arg):
  13. return arg.startswith('-u') or arg.startswith('--use')
  14. def main(regrtest_args):
  15. args = [sys.executable,
  16. '-W', 'default', # Warnings set to 'default'
  17. '-bb', # Warnings about bytes/bytearray
  18. '-E', # Ignore environment variables
  19. ]
  20. # Allow user-specified interpreter options to override our defaults.
  21. args.extend(test.support.args_from_interpreter_flags())
  22. args.extend(['-m', 'test', # Run the test suite
  23. '-r', # Randomize test order
  24. '-w', # Re-run failed tests in verbose mode
  25. ])
  26. if sys.platform == 'win32':
  27. args.append('-n') # Silence alerts under Windows
  28. if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
  29. args.extend(['-j', '0']) # Use all CPU cores
  30. if not any(is_resource_use_flag(arg) for arg in regrtest_args):
  31. args.extend(['-u', 'all,-largefile,-audio,-gui'])
  32. args.extend(regrtest_args)
  33. print(' '.join(args))
  34. os.execv(sys.executable, args)
  35. if __name__ == '__main__':
  36. main(sys.argv[1:])