Skip to content
Snippets Groups Projects
Commit 3b85960b authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

...

parent 486af6bf
Branches
No related tags found
No related merge requests found
import subprocess import subprocess
import os, sys import os, sys, shutil
import time import time
import task_autotest.config as config import task_autotest.config as config
def test_task_commit(task_path, commit, workdir="_test"): def test_task_commit(task_path, commit, workdir="_test"):
start_time = time.time()
wd = config.REPO_DIR + "/" + workdir wd = config.REPO_DIR + "/" + workdir
subprocess.run(["git", "checkout", commit], cwd=wd, check=True) subprocess.run(["git", "checkout", commit], cwd=wd, check=True)
outdir = config.DATA_DIR + "/tests/" + task_path.replace('/', '_') + '/' + commit + '/' outdir = config.DATA_DIR + "/tests/" + task_path.replace('/', '_') + '/' + commit + '/'
outdir_part = "/".join(outdir.split("/")[:-2])
if not os.path.isdir(outdir_part):
os.mkdir(outdir_part)
if os.path.isdir(outdir):
shutil.rmtree(outdir)
os.mkdir(outdir) os.mkdir(outdir)
with open(outdir + "time", "w") as f: with open(outdir + "time", "w") as f:
f.write(time.time()) f.write(str(int(start_time)))
...@@ -11,6 +11,7 @@ import wtforms ...@@ -11,6 +11,7 @@ import wtforms
from wtforms.fields import EmailField from wtforms.fields import EmailField
from wtforms.widgets import NumberInput from wtforms.widgets import NumberInput
import pprint import pprint
import sys, os
import task_autotest.config as config import task_autotest.config as config
import task_autotest.web import task_autotest.web
...@@ -83,4 +84,26 @@ def base_page(content, head=html.bucket(), limited_size=True, sticky_head=True, ...@@ -83,4 +84,26 @@ def base_page(content, head=html.bucket(), limited_size=True, sticky_head=True,
def web_index(): def web_index():
b = html.Builder() b = html.Builder()
return base_page(b.root).print_file()
@app.route("/show_test/<string:task>/<string:commit>/", methods=['GET', 'POST'])
def show_test(task, commit):
if not commit.isalnum():
raise werkzeug.exceptions.Forbidden()
if not all(i.isalnum() or i in "_" for i in task):
raise werkzeug.exceptions.Forbidden()
path = config.DATA_DIR + '/tests/' + task + "/" + commit + "/"
if not os.path.isdir(path):
return werkzeug.exceptions.NotFound()
b = html.Builder()
b.h1(f"Test úlohy {task} na {commit[:12]}")
with open(path + "time") as f:
start_time = datetime.fromtimestamp(int(f.read()))
b.p(f"Test běžel v {start_time}")
return base_page(b.root).print_file() return base_page(b.root).print_file()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment