Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "passed with warning" flag for checker result #355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/checker/basemodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class CheckerResult(models.Model):
checker = GenericForeignKey('content_type', 'object_id')

passed = models.BooleanField(default=True, help_text=_('Indicates whether the test has been passed'))
passed_with_warning = models.BooleanField(default=False, help_text=_('Indicates whether the test has been passed with a warning'))
log = models.TextField(help_text=_('Text result of the checker'))
creation_date = models.DateTimeField(auto_now_add=True)
runtime = models.IntegerField(default=0, help_text=_('Runtime in milliseconds'))
Expand Down Expand Up @@ -265,6 +266,11 @@ def set_passed(self, passed):
assert isinstance(passed, int)
self.passed = passed

def set_passed_with_warning(self, passed_with_warning):
""" Sets the passed with warning flag of the Checker. """
assert isinstance(passed_with_warning, bool)
self.passed_with_warning = passed_with_warning

def add_artefact(self, filename, path):
assert os.path.isfile(path)
artefact = CheckerResultArtefact(result = self, filename=filename)
Expand Down Expand Up @@ -437,5 +443,7 @@ def run_checks(solution, env, run_all):

if result.passed:
passed_checkers.add(checker.__class__)
if result.passed_with_warning and checker.show_publicly(result.passed):
solution.warnings = True
solution.accepted = solution_accepted
solution.save()
9 changes: 7 additions & 2 deletions src/checker/checker/ScriptChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from utilities.safeexec import execute_arglist
from utilities.file_operations import *

EXIT_CODE_PASSED_WITH_WARNING = 121

class ScriptChecker(Checker):

name = models.CharField(max_length=100, default="Externen Tutor ausführen", help_text=_("Name to be displayed on the solution detail page."))
Expand All @@ -29,7 +31,7 @@ def title(self):
@staticmethod
def description():
""" Returns a description for this Checker. """
return "Diese Prüfung wird bestanden, wenn das externe Programm keinen Fehlercode liefert."
return "This checker succeeds if the external program doesn't return an error code (exit code is 0). Exit code 121 means that the checker passed with a warning. Everything else means that the checker failed."


def path_relative_to_sandbox(self):
Expand Down Expand Up @@ -89,7 +91,10 @@ def run(self, env):
output = '<pre>' + escape(output) + '</pre>'

result.set_log(output, timed_out=timed_out, truncated=truncated, oom_ed=oom_ed)
result.set_passed(not exitcode and not timed_out and not oom_ed and not truncated)

exitcode_ok = exitcode == 0 or exitcode == EXIT_CODE_PASSED_WITH_WARNING
result.set_passed(exitcode_ok and not timed_out and not oom_ed and not truncated)
result.set_passed_with_warning(result.passed and exitcode == EXIT_CODE_PASSED_WITH_WARNING)

return result

Expand Down
18 changes: 18 additions & 0 deletions src/checker/migrations/0017_checkerresult_passed_with_warning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2022-10-12 16:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('checker', '0016_remove_JavaGCCBuilder'),
]

operations = [
migrations.AddField(
model_name='checkerresult',
name='passed_with_warning',
field=models.BooleanField(default=False, help_text='Indicates whether the test has been passed with a warning'),
),
]
4 changes: 2 additions & 2 deletions src/templates/solutions/checker_results_inline.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ <h3 class="{{result.only_title|yesno:',clickable'}} result">
{% if not result.only_title %}<a class="checkerinline" href="#{{result.title}}" title="{{result.title}}" >{% endif %}
<span class="ui-icon {{result.only_title|yesno:'icon-none,ui-icon-triangle-1-s'}}"></span>
{{result.title}} <span class="{{result.public|yesno:',ui-icon ui-icon-locked icon-orange'}}"></span>:
<span class="{% if result.passed %} passed {% else %}{% if result.required %} error {% else %} warning {% endif %}{% endif %}">
{{result.passed|yesno:_("passed, failed")}} {% if result.passed %} {% else %} {% if result.required %} {% else %} (but not required) {% endif %} {% endif %}
<span class="{% if result.passed %} {% if result.passed_with_warning %} warning {% else %} passed {% endif %} {% else %}{% if result.required %} error {% else %} warning {% endif %}{% endif %}">
{{result.passed|yesno:_("passed, failed")}} {% if result.passed %} {% if result.passed_with_warning %} with warning {% endif %} {% else %} {% if result.required %} {% else %} (but not required) {% endif %} {% endif %}
</span>
<!-- <span class="checkertime">{{ result.runtime }} ms</span> -->
{% if not result.only_title %}</a>{% endif %}
Expand Down