Browse Source

If a file /submission/.sh is present, run it as a tests suite

master
nemunaire 2 months ago
parent
commit
da10a7bc26
  1. 4
      check.py
  2. 22
      tests.py

4
check.py

@ -4,6 +4,7 @@ from datetime import datetime
import email
import email.policy
import os
from os.path import exists
import sys
import stat
import subprocess
@ -24,6 +25,7 @@ import late
import login
import signature
from test import MailTest
import tests
def signcheck(data):
yield MailTest("Those tests are limited to signature checking. THIS IS NOT THE SUBMISSION INTERFACE.", 2)
@ -54,6 +56,8 @@ def gen_checks(gpgmail, submissions_dir, check_content=False, check_submission_h
yield ( archive.hash_archive, [submissions_dir, check_submission_hash] )
yield archive.guess_mime
yield ( archive.extract, [submissions_dir] )
if exists(submissions_dir + ".sh"):
yield ( tests.run_script, [submissions_dir + ".sh"] )
def respondissueemail(to, subject, ref, initial_to=None):

22
tests.py

@ -0,0 +1,22 @@
import subprocess
from test import MailTest
def run_script(dest, script):
with subprocess.Popen(
["/bin/sh", script],
cwd=dest,
env={"LANG": 'C'},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
) as p:
p.wait()
err = p.stdout.read().decode('utf-8', 'replace')
err += p.stderr.read().decode('utf-8', 'replace')
if p.returncode == 0:
yield MailTest("Preliminary tests:", details=err.replace(dest, "/rendu/"))
yield dest
elif p.returncode == 124 || p.returncode == 137:
yield MailTest("Preliminary tests aborted for too long execution:", 1, details=err.replace(dest, "/rendu/"))
else:
yield MailTest("An error occured during preliminary tests:", 1, details=err.replace(dest, "/rendu/"))
Loading…
Cancel
Save