This repository was archived by the owner on Jun 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo.py
More file actions
60 lines (46 loc) · 1.52 KB
/
Copy pathcombo.py
File metadata and controls
60 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import shutil
import os
from constants.COLORS import *
from constants.settings import INPUT_FILES_ROOT, SCORE_STATISTICS_FILE, TARGET_ROOT, TEST_ROOT
from core.run_samples import execute
import threading
import subprocess as sb
lock = threading.Lock()
files = os.listdir(INPUT_FILES_ROOT)
with open(SCORE_STATISTICS_FILE, "w") as initialize:
print(end='file name,coverage\n', file=initialize)
initialize.close()
files = [file for file in files if file.split('.')[1] in ['c', 'cpp']]
threads = []
results = []
def init():
if not "main.cpp" in os.listdir("target"):
sb.call("touch target/main.cpp")
init()
def pre_execute(target_root: str, filename: str):
lock.acquire()
results.append(execute(target_root, filename))
lock.release()
for index, file in enumerate(files):
print(f"{WARNING}{BOLD}RUNNING TESTS FOR {file}...{ENDC}")
shutil.copyfile(rf"{INPUT_FILES_ROOT}/{file}",
rf"{TARGET_ROOT}/main.cpp")
thread = threading.Thread(target=pre_execute(
f"{TARGET_ROOT}/main.cpp", file))
thread.start()
threads.append(thread)
print(f"{WARNING}{BOLD}FINISHED TESTING PROCESS ON {file}{ENDC}")
with open(SCORE_STATISTICS_FILE, "a") as scores_file:
print(results[index], file=scores_file)
scores_file.close()
for thread in threads:
thread.join()
def end():
print(f"{WARNING}RESTORING CHANGES...{ENDC}")
if "a.exe" in os.listdir("."):
os.remove("a.exe")
try:
shutil.rmtree(f"{TEST_ROOT}")
except:
return
end()