Merge branch 'master' of gitea:boyan_k/Coding_Tools
This commit is contained in:
commit
5e34464718
31
ucompile
31
ucompile
@ -17,14 +17,15 @@ def check_dependencies() -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def run_input_cases(program, args):
|
def run_input_cases(program, args) -> bool:
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
output = args.output
|
output = args.output
|
||||||
tests_dir = args.tests_dir if args.tests_dir else "."
|
tests_dir = args.tests_dir if args.tests_dir else "."
|
||||||
time_flag = args.time
|
time_flag = args.time
|
||||||
|
|
||||||
input_files = glob(os.path.join(tests_dir, "*.in"))
|
input_files = sorted(glob(os.path.join(tests_dir, "*.in")), key=os.path.getmtime)
|
||||||
|
|
||||||
|
passed = True
|
||||||
if len(input_files) < 1:
|
if len(input_files) < 1:
|
||||||
if time_flag:
|
if time_flag:
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
@ -97,6 +98,7 @@ def run_input_cases(program, args):
|
|||||||
print("✅")
|
print("✅")
|
||||||
else:
|
else:
|
||||||
print("❌")
|
print("❌")
|
||||||
|
passed = False
|
||||||
# green expected output and red program output
|
# green expected output and red program output
|
||||||
print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}")
|
print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}")
|
||||||
print(expected_output)
|
print(expected_output)
|
||||||
@ -118,21 +120,19 @@ def run_input_cases(program, args):
|
|||||||
print(f"⏳: {elapsed_time:.4f} s")
|
print(f"⏳: {elapsed_time:.4f} s")
|
||||||
|
|
||||||
print("-----------")
|
print("-----------")
|
||||||
return
|
return passed
|
||||||
|
|
||||||
|
|
||||||
def python_compile(file_name, args):
|
def python_compile(file_name, args) -> bool:
|
||||||
|
passed = None
|
||||||
try:
|
try:
|
||||||
if os.system("which pypy3 &> /dev/null") == 0:
|
if os.system("which pypy3 &> /dev/null") == 0:
|
||||||
print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}")
|
print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}")
|
||||||
run_input_cases("pypy3 " + file_name, args)
|
return run_input_cases("pypy3 " + file_name, args)
|
||||||
return
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}")
|
print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}")
|
||||||
run_input_cases("python3 " + file_name, args)
|
return run_input_cases("python3 " + file_name, args)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def java_compile(file_name, args):
|
def java_compile(file_name, args):
|
||||||
if args.alternative:
|
if args.alternative:
|
||||||
@ -147,8 +147,7 @@ def java_compile(file_name, args):
|
|||||||
|
|
||||||
def haskell_compile(file_name, args):
|
def haskell_compile(file_name, args):
|
||||||
os.system("ghc -O2 " + file_name + " -o program")
|
os.system("ghc -O2 " + file_name + " -o program")
|
||||||
run_input_cases("./program", args)
|
return run_input_cases("./program", args)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def c_compile(file_name, args):
|
def c_compile(file_name, args):
|
||||||
@ -213,7 +212,13 @@ def main():
|
|||||||
|
|
||||||
args.tests_dir = args.tests if args.tests else "."
|
args.tests_dir = args.tests if args.tests else "."
|
||||||
|
|
||||||
SUPPORTED_LANGS[file_ext](file_name, args)
|
if not SUPPORTED_LANGS[file_ext](file_name, args): # don't do submit dialogue if failed
|
||||||
|
return
|
||||||
|
|
||||||
|
temmies_check = os.path.join(os.path.dirname(file_name), ".temmies")
|
||||||
|
if os.path.exists(temmies_check):
|
||||||
|
if input("🎉✨ -- Submit? (y/N): ") == "y":
|
||||||
|
os.system("temmies submit")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user