def time_test_suite(swallow_output, test_command, using_testmon): cached_time = cached_test_time() if cached_time is not None: print('1. Using cached time for baseline tests, to run baseline again delete the cache file') return cached_time print('1. Running tests without mutations') start_time = datetime.now() output = [] def feedback(line): if not swallow_output: print(line) print_status('Running...') output.append(line) returncode = popen_streaming_output(test_command, feedback) if returncode == 0 or (using_testmon and returncode == 5): baseline_time_elapsed = (datetime.now() - start_time).total_seconds() else: raise ErrorMessage("Tests don't run cleanly without mutations. Test command was: %s\n\nOutput:\n\n%s" % (test_command, '\n'.join(output))) print(' Done') set_cached_test_time(baseline_time_elapsed) return baseline_time_elapsed
def time_test_suite(swallow_output, test_command, using_testmon, current_hash_of_tests): """Execute a test suite specified by ``test_command`` and record the time it took to execute the test suite as a floating point number :param swallow_output: if :obj:`True` test stdout will be not be printed :type swallow_output: bool :param test_command: command to spawn the testing subprocess :type test_command: str :param using_testmon: if :obj:`True` the test return code evaluation will accommodate for ``pytest-testmon`` :type using_testmon: bool :return: execution time of the test suite :rtype: float """ cached_time = cached_test_time() if cached_time is not None and current_hash_of_tests == cached_hash_of_tests( ): print( '1. Using cached time for baseline tests, to run baseline again delete the cache file' ) return cached_time print('1. Running tests without mutations') start_time = time() output = [] def feedback(line): if not swallow_output: print(line) print_status('Running...') output.append(line) returncode = popen_streaming_output(test_command, feedback) if returncode == 0 or (using_testmon and returncode == 5): baseline_time_elapsed = time() - start_time else: raise RuntimeError( "Tests don't run cleanly without mutations. Test command was: {}\n\nOutput:\n\n{}" .format(test_command, '\n'.join(output))) print('Done') set_cached_test_time(baseline_time_elapsed, current_hash_of_tests) return baseline_time_elapsed