diff --git a/.gitignore b/.gitignore index c18dd8d..4f74949 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ __pycache__/ +*.egg-info/ +build/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0a4f8e --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2023 dogeystamp + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 522ac40..d52d26a 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ testr is a script for running competitive programming test cases (for example fo You can install all of these via Arch Linux's repositories: -- colorama +- python-colorama +- python diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..34b9112 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "gusty-testr" +version = "0.0.1" +authors = [ + { name="dogeystamp", email="dogeystamp@disroot.org" } +] +description = "A test runner for competitive programming." +readme = "README.md" +requires-python = ">=3.7" + +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +dependencies = [ + "colorama > 0.4.0" +] + +[project.scripts] +testr = "testr.cli:main" diff --git a/testr.py b/testr/cli.py similarity index 63% rename from testr.py rename to testr/cli.py index a6c562e..2012df1 100644 --- a/testr.py +++ b/testr/cli.py @@ -1,6 +1,5 @@ import time from colorama import just_fix_windows_console, Fore, Style -just_fix_windows_console() import asyncio from pathlib import Path @@ -8,30 +7,31 @@ from testr.file_data import DirectorySuite, ExecutableRunner from testr.runner import StatusCode, TestOptions import argparse -parser = argparse.ArgumentParser() -test_runner_group = parser.add_mutually_exclusive_group(required=True) -test_data_group = parser.add_mutually_exclusive_group(required=True) - -test_data_group.add_argument("--testdir", help="Directory for test cases") -test_runner_group.add_argument("--exec", help="Executable to run test cases against") - -parser.add_argument("--timelim", help="Time limit in seconds", type=float, default=5.0) - -args = parser.parse_args() - - -code_styles = { - StatusCode.AC: Fore.GREEN, - StatusCode.WA: Fore.RED, - StatusCode.IR: Fore.YELLOW, - StatusCode.TLE: Fore.YELLOW, -} - - -async def main(): +async def run_cli(): + just_fix_windows_console() start_time = time.perf_counter() + parser = argparse.ArgumentParser() + + test_runner_group = parser.add_mutually_exclusive_group(required=True) + test_data_group = parser.add_mutually_exclusive_group(required=True) + + test_data_group.add_argument("--testdir", help="Directory for test cases") + test_runner_group.add_argument("--exec", help="Executable to run test cases against") + + parser.add_argument("--timelim", help="Time limit in seconds", type=float, default=5.0) + + args = parser.parse_args() + + + code_styles = { + StatusCode.AC: Fore.GREEN, + StatusCode.WA: Fore.RED, + StatusCode.IR: Fore.YELLOW, + StatusCode.TLE: Fore.YELLOW, + } + test_suite = DirectorySuite(Path(args.testdir)) test_runner = ExecutableRunner(Path(args.exec)) @@ -64,5 +64,8 @@ async def main(): print(f"\n Finished in{time.perf_counter() - start_time : .2f} seconds.\n") +def main(): + asyncio.run(run_cli()) + if __name__ == "__main__": - asyncio.run(main()) + main()