Skip to content

Commit 799c5b1

Browse files
Merge pull request #313 from mishaschwartz/v2.1.0
v2.1.0
2 parents b473745 + fdbe2a0 commit 799c5b1

File tree

21 files changed

+266
-47
lines changed

21 files changed

+266
-47
lines changed

Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# CHANGELOG
22
All notable changes to this project will be documented here.
33

4-
## [unreleased]
4+
## [v2.1.0]
5+
- Add R tester (#310)
56

67
## [v2.0.2]
78
- Keep result object alive for longer than the default 500 seconds (#302)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ The autotester currently supports testers for the following languages and testin
138138
- [Jupyter Notebook](https://jupyter.org/)
139139
- `racket`
140140
- [RackUnit](https://docs.racket-lang.org/rackunit/)
141+
- `R`
142+
- [TestThat](https://testthat.r-lib.org/)
141143
- `custom`
142144
- see more information [here](#the-custom-tester)
143145
@@ -158,6 +160,8 @@ Installing each tester will also install the following additional packages (syst
158160
- none
159161
- `racket`
160162
- racket
163+
- `R`
164+
- R
161165
- `custom`
162166
- none
163167

client/autotest_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def get_statuses(settings_id, **_kw):
308308

309309
@app.route("/settings/<settings_id>/tests/cancel", methods=["DELETE"])
310310
@authorize
311-
def cancel_tests(settings_id):
311+
def cancel_tests(settings_id, **_kw):
312312
test_ids = request.json["test_ids"]
313313
result = {}
314314
for id_, job in zip(test_ids, _get_jobs(test_ids, settings_id)):

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ services:
88
args:
99
UBUNTU_VERSION: '18.04'
1010
LOGIN_USER: 'docker'
11-
image: markus-autotest-server-dev:1.0.0
11+
WORKSPACE: '/home/docker/.autotesting'
12+
image: markus-autotest-server-dev:1.0.1
1213
volumes:
1314
- ./server:/app:cached
1415
- workspace:/home/docker/.autotesting:rw

server/.dockerfiles/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FROM ubuntu:$UBUNTU_VERSION as base
55
ENV DEBIAN_FRONTEND=noninteractive
66

77
ARG LOGIN_USER
8+
ARG WORKSPACE
89

910
RUN apt-get update -y && \
1011
apt-get -y install software-properties-common && \
@@ -38,6 +39,8 @@ RUN python3.9 -m venv /markus_venv && \
3839
find /app/autotest_server/testers -name requirements.system -exec {} \; && \
3940
rm -rf /app/*
4041

42+
RUN mkdir -p ${WORKSPACE} && chown ${LOGIN_USER} ${WORKSPACE}
43+
4144
WORKDIR /home/${LOGIN_USER}
4245

4346
USER ${LOGIN_USER}

server/autotest_server/__init__.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _kill_user_processes(test_username: str) -> None:
8282
subprocess.run(kill_cmd, shell=True)
8383

8484

85-
def _create_test_script_command(env_dir: str, tester_type: str) -> str:
85+
def _create_test_script_command(tester_type: str) -> str:
8686
"""
8787
Return string representing a command line command to
8888
run tests.
@@ -95,9 +95,8 @@ def _create_test_script_command(env_dir: str, tester_type: str) -> str:
9595
"from testers.specs import TestSpecs",
9696
f"Tester(specs=TestSpecs.from_json(sys.stdin.read())).run()",
9797
]
98-
python_ex = os.path.join(os.path.join(TEST_SCRIPT_DIR, env_dir), "bin", "python")
9998
python_str = "; ".join(python_lines)
100-
return f"{python_ex} -c '{python_str}'"
99+
return f"\"${{PYTHON}}\" -c '{python_str}'"
101100

102101

103102
def get_available_port(min_, max_, host: str = "localhost") -> str:
@@ -174,9 +173,8 @@ def _run_test_specs(
174173

175174
for settings in test_settings["testers"]:
176175
tester_type = settings["tester_type"]
177-
env_dir = settings.get("_env_loc")
178176

179-
cmd_str = _create_test_script_command(env_dir, tester_type)
177+
cmd_str = _create_test_script_command(tester_type)
180178
args = cmd.format(cmd_str)
181179

182180
for test_data in settings["test_data"]:
@@ -198,7 +196,7 @@ def _run_test_specs(
198196
stdin=subprocess.PIPE,
199197
preexec_fn=set_rlimits_before_test,
200198
universal_newlines=True,
201-
env={**os.environ, **env_vars},
199+
env={**os.environ, **env_vars, **settings["_env"]},
202200
)
203201
try:
204202
settings_json = json.dumps({**settings, "test_data": test_data})
@@ -356,20 +354,15 @@ def update_test_settings(user, settings_id, test_settings, file_url):
356354
tester_type = tester_settings["tester_type"]
357355
if tester_type not in installed_testers:
358356
raise Exception(f"tester {tester_type} is not installed")
357+
env_dir = os.path.join(settings_dir, f"{tester_type}_{i}")
359358
tester_install = importlib.import_module(f"autotest_server.testers.{tester_type}.setup")
360-
if tester_settings.get("env_data"):
361-
env_dir = os.path.join(settings_dir, f"{tester_type}_{i}")
362-
tester_settings["_env_loc"] = env_dir
363-
try:
364-
tester_install.create_environment(tester_settings)
365-
except Exception as e:
366-
raise Exception(f"create tester environment failed:\n{e}") from e
367-
else:
368-
default_env = os.path.join(TEST_SCRIPT_DIR, DEFAULT_ENV_DIR)
369-
if not os.path.isdir(default_env):
370-
subprocess.run([sys.executable, "-m", "venv", default_env], check=True)
371-
372-
tester_settings["_env_loc"] = default_env
359+
default_env = os.path.join(TEST_SCRIPT_DIR, DEFAULT_ENV_DIR)
360+
if not os.path.isdir(default_env):
361+
subprocess.run([sys.executable, "-m", "venv", default_env], check=True)
362+
try:
363+
tester_settings["_env"] = tester_install.create_environment(tester_settings, env_dir, default_env)
364+
except Exception as e:
365+
raise Exception(f"create tester environment failed:\n{e}") from e
373366
test_settings["testers"][i] = tester_settings
374367
test_settings["_files"] = files_dir
375368
test_settings.pop("_error", None)

server/autotest_server/testers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
_TESTERS = ("custom", "haskell", "java", "jupyter", "py", "pyta", "racket")
3+
_TESTERS = ("custom", "haskell", "java", "jupyter", "py", "pyta", "r", "racket")
44

55

66
def install(testers=_TESTERS):

server/autotest_server/testers/custom/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import json
33

44

5-
def create_environment(*_args, **_kwargs):
6-
"""no op"""
5+
def create_environment(_settings, _env_dir, default_env_dir):
6+
return {"PYTHON": os.path.join(default_env_dir, 'bin', 'python3')}
77

88

99
def install():

server/autotest_server/testers/haskell/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import subprocess
44

55

6-
def create_environment(*_args, **_kwargs):
7-
"""no op"""
6+
def create_environment(_settings, _env_dir, default_env_dir):
7+
return {"PYTHON": os.path.join(default_env_dir, 'bin', 'python3')}
88

99

1010
def install():

server/autotest_server/testers/java/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import requests
55

66

7-
def create_environment(*_args, **_kwargs):
8-
"""no op"""
7+
def create_environment(_settings, _env_dir, default_env_dir):
8+
return {"PYTHON": os.path.join(default_env_dir, 'bin', 'python3')}
99

1010

1111
def install():

0 commit comments

Comments
 (0)