def main(paths: List[pathlib.Path], *, marker: onlinejudge_verify.marker.VerificationMarker, timeout: float = math.inf, tle: float = 60, jobs: int = 1) -> VerificationSummary: try: import resource _, hard = resource.getrlimit(resource.RLIMIT_STACK) resource.setrlimit(resource.RLIMIT_STACK, (hard, hard)) except: logger.warning('failed to increase the stack size') print(f'::warning ::failed to ulimit') compilers = [] if 'CXX' in os.environ: compilers.append(os.environ['CXX']) else: compilers.append('g++') compilers.append('clang++') failed_test_paths: List[pathlib.Path] = [] start = time.time() for path in paths: if marker.is_verified(path): continue verified = verify_file(path, compilers=compilers, tle=tle, jobs=jobs) if verified is None: logger.info('ignored') elif verified: marker.mark_verified(path) else: marker.mark_failed(path) failed_test_paths.append(path) # Set an error message for GitHub Action. https://help.github.com/en/actions/reference/development-tools-for-github-actions print( f'::error file={str(path.resolve(strict=True).relative_to(pathlib.Path.cwd().resolve(strict=True)))}::failed to verify' ) # to prevent taking too long; we may fail to use the results of verification due to expired tokens if timeout is not None and time.time() - start > timeout: break return VerificationSummary(failed_test_paths=failed_test_paths)
def main(paths: List[pathlib.Path], *, marker: onlinejudge_verify.marker.VerificationMarker, timeout: float = math.inf, tle: float = 60, jobs: int = 1) -> VerificationSummary: try: resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) except: logger.warning('failed to make the stack size unlimited') ulimit_success = False else: ulimit_success = True compilers = [] if 'CXX' in os.environ: compilers.append(os.environ['CXX']) else: compilers.append('g++') compilers.append('clang++') failed_test_paths: List[pathlib.Path] = [] start = time.time() for path in paths: if marker.is_verified(path): continue verified = verify_file(path, compilers=compilers, tle=tle, jobs=jobs) if verified: marker.mark_verified(path) else: marker.mark_failed(path) failed_test_paths.append(path) # to prevent taking too long; we may fail to use the results of verification due to expired tokens if timeout is not None and time.time() - start > timeout: break return VerificationSummary(failed_test_paths=failed_test_paths, ulimit_success=ulimit_success)
def main(paths: List[pathlib.Path], *, marker: onlinejudge_verify.marker.VerificationMarker, timeout: float = math.inf, jobs: int = 1) -> None: try: resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)) except: logger.warning('failed to make the stack size unlimited') compilers = [] if 'CXX' in os.environ: compilers.append(os.environ['CXX']) else: compilers.append('g++') compilers.append('clang++') failed_test_paths: List[pathlib.Path] = [] start = time.time() for path in paths: if marker.is_verified(path): continue verified = verify_file(path, compilers=compilers, jobs=jobs) if verified: marker.mark_verified(path) else: marker.mark_failed(path) failed_test_paths.append(path) # to prevent taking too long; we may fail to use the results of verification due to expired tokens if timeout is not None and time.time() - start > timeout: break # failするテストがあったらraiseする if len(failed_test_paths) > 0: logger.error('%d test failed', len(failed_test_paths)) for path in failed_test_paths: logger.error('failed: %s', str(path)) raise Exception('{} test failed'.format(len(failed_test_paths)))