made app into a pip-installable package

This commit is contained in:
dogeystamp 2023-11-02 20:56:08 -04:00
parent 6bd279f55b
commit 5c86b88bee
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
5 changed files with 75 additions and 24 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
__pycache__/ __pycache__/
*.egg-info/
build/

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2023 dogeystamp <dogeystamp@disroot.org>
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.

View File

@ -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: You can install all of these via Arch Linux's repositories:
- colorama - python-colorama
- python

26
pyproject.toml Normal file
View File

@ -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"

View File

@ -1,6 +1,5 @@
import time import time
from colorama import just_fix_windows_console, Fore, Style from colorama import just_fix_windows_console, Fore, Style
just_fix_windows_console()
import asyncio import asyncio
from pathlib import Path from pathlib import Path
@ -8,30 +7,31 @@ from testr.file_data import DirectorySuite, ExecutableRunner
from testr.runner import StatusCode, TestOptions from testr.runner import StatusCode, TestOptions
import argparse import argparse
parser = argparse.ArgumentParser()
test_runner_group = parser.add_mutually_exclusive_group(required=True) async def run_cli():
test_data_group = parser.add_mutually_exclusive_group(required=True) just_fix_windows_console()
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():
start_time = time.perf_counter() 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_suite = DirectorySuite(Path(args.testdir))
test_runner = ExecutableRunner(Path(args.exec)) 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") print(f"\n Finished in{time.perf_counter() - start_time : .2f} seconds.\n")
def main():
asyncio.run(run_cli())
if __name__ == "__main__": if __name__ == "__main__":
asyncio.run(main()) main()