Merge branch 'master' of gitea:boyan_k/Coding_Tools
This commit is contained in:
commit
5e34464718
29
ucompile
29
ucompile
@ -17,14 +17,15 @@ def check_dependencies() -> None:
|
||||
return
|
||||
|
||||
|
||||
def run_input_cases(program, args):
|
||||
def run_input_cases(program, args) -> bool:
|
||||
verbose = args.verbose
|
||||
output = args.output
|
||||
tests_dir = args.tests_dir if args.tests_dir else "."
|
||||
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 time_flag:
|
||||
start_time = time.perf_counter()
|
||||
@ -97,6 +98,7 @@ def run_input_cases(program, args):
|
||||
print("✅")
|
||||
else:
|
||||
print("❌")
|
||||
passed = False
|
||||
# green expected output and red program output
|
||||
print(f"{Fore.GREEN}Expected output:{Style.RESET_ALL}")
|
||||
print(expected_output)
|
||||
@ -118,21 +120,19 @@ def run_input_cases(program, args):
|
||||
print(f"⏳: {elapsed_time:.4f} s")
|
||||
|
||||
print("-----------")
|
||||
return
|
||||
return passed
|
||||
|
||||
|
||||
def python_compile(file_name, args):
|
||||
def python_compile(file_name, args) -> bool:
|
||||
passed = None
|
||||
try:
|
||||
if os.system("which pypy3 &> /dev/null") == 0:
|
||||
print(f"{Fore.LIGHTMAGENTA_EX}Using pypy3{Style.RESET_ALL}")
|
||||
run_input_cases("pypy3 " + file_name, args)
|
||||
return
|
||||
return run_input_cases("pypy3 " + file_name, args)
|
||||
except Exception:
|
||||
pass
|
||||
print(f"{Fore.MAGENTA}WARNING: pypy3 not found, using python3 instead{Style.RESET_ALL}")
|
||||
run_input_cases("python3 " + file_name, args)
|
||||
return
|
||||
|
||||
return run_input_cases("python3 " + file_name, args)
|
||||
|
||||
def java_compile(file_name, args):
|
||||
if args.alternative:
|
||||
@ -147,8 +147,7 @@ def java_compile(file_name, args):
|
||||
|
||||
def haskell_compile(file_name, args):
|
||||
os.system("ghc -O2 " + file_name + " -o program")
|
||||
run_input_cases("./program", args)
|
||||
return
|
||||
return run_input_cases("./program", args)
|
||||
|
||||
|
||||
def c_compile(file_name, args):
|
||||
@ -213,7 +212,13 @@ def main():
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user