StdioTest
Stage for grading submissions against standard input/output using declared test cases.
Kind: Grading Stage
Behaviour:
Runs the executable according to a run command in the terminal, applying standard input and command line arguments
The resultant standard output will be compared (diff-ed) against an expected output, in which the correctness of a
case
will be determinedScore for this
case
will be granted fully only if it is correctIf execution exceeds time limit specified in
_settings.stage_wait_duration_secs
, it will be treated as incorrectcases
against the same executable file are grouped as atestCase
Throws:
FieldsIncorrectlyUsedError
if_settings.lang
does not correspond to a distroHeredocDelimitingError
againststdin
andexpected
FileNotFoundError
if file specified infile_stdin
andfile_expected
cannot be found
Config
stdioTest:
testCases:
- file: String # file to run
id: Int # id for this case
args: [String]? # optional command line arguments
stdin: String? # optional standard input
file_stdin: String? # optional helper file for providing standard input
expected: String? # optional expected output of the case
file_expected: String? # optional helper file for providing expected output
visibility: Visiblity # visibility of the result of this case
hide_from_report: [HiddenItem]? # items to be hidden from report
score: Double? # scores for passing this case, if any (if not specified, scoring is disabled for this test case)
valgrind: Valgrind? # test case-specific override for Valgrind [default: null (following the `valgrind` key)]
diff_ignore_flags: [DiffIgnoreFlag]? # list of diff ignore flags to be used for comparing standard output against expected output
compat:denyStderr: Boolean? # whether to treat `stderr` output as a failing condition [default: false]
additional_packages: [String]? # list of additional packages to install [default: []]
additional_pip_packages: [String]? # list of additional PIP packages to install [default: []]
Visiblity: ALWAYS_VISIBLE | ALWAYS_HIDDEN | VISIBLE_AFTER_GRADING | VISIBLE_AFTER_GRADING_IF_FAILED
The visibility of the test case to the student
Individual report elements can be hidden via the
hide_from_report
flagsALWAYS_VISIBLE
: Test case information is always available to studentsALWAYS_HIDDEN
: Test case information is always hidden from students (except whether the test case has passed, and the score of the test case)VISIBLE_AFTER_GRADING
: Test case information is visible after the deadline of the assignmentVISIBLE_AFTER_GRADING_IF_FAILED
: Test case information is visible after the deadline of the assignment only if the test case has failed
DiffIgnoreFlag: TRAILING_WHITESPACE | SPACE_CHANGE | ALL_SPACE | BLANK_LINES
Additional flags to provide to the
diff
application to ignore certain types of differencesTRAILING_WHITESPACE
: Ignores line differences which only differ by trailing whitespaceSPACE_CHANGE
: Ignores line differences which only differ by the change in number and/or type of whitespaceALL_SPACE
: Ignores all types of space changes, including between whitespace and no whitespaceBLANK_LINES
: Ignores all changes whose lines are blank
HiddenItem: STDIN | STDOUT | STDERR | DIFF
Individual elements of the StdioTest report to hide; Overrides the visibility setting if set
STDIN
: Hides the standard input from the reportSTDOUT
: Hides the standard output from the reportSTDERR
: Hides the standard error from the reportDIFF
: Hides the diff between the expected and actual output from the report
file_stdin
andfile_expected
: These files are expected to be within theprovided
directory. If these fields are set, specifying their in-file text counterpart will return errorscore
: Caveat - Ifvalgrind.score
is set tonull
andstdioTest.score
is set tonull
, theValgrind
stage will use thescore
value of the globalValgrind
configuration. To disable this behavior, use0
as thestdioTest.score
.Valgrind
: see the config: of Valgrind stagecompat:denyStderr
: If set totrue
, anystderr
output from the executable will be treated as the test case failing.Treating
stderr
as a failing condition will become the default in the next release of the ZINC Grader. To opt out of this behavior, set this field tofalse
.
additional_packages
: Additional packages to install before running the executableadditional_pip_packages
: Additional PIP packages to install before running the executableIf the
lang
is notpython
, you must specifypython3-pip
inadditional_packages
to first install Pip.
Report
stdioTest:
- file: String # file to run
id: Int # id for this case
args: String # command line arguments concatenated
stdin: [String] # standard input, could be an empty list
stdout: [String] # the standard output of the submission upon execution
stderr: [String] # the standard errors generated during execution
exitCode: Int # the first non-zero exit code in the sequence of commands executed, or zero if no command
# exited with a non-zero exit code
expect: [String] # expected output of the case
visibility: Visiblity # visibility of the result of this case
diff: [String] # the diff generated output between expect and stdout (in this order)
hasTimedOut: Boolean # whether the execution has timed out
isCorrect: Boolean # whether the case is considered correct
score: Score? # scores for passing this case and the total score
exeExitCode: Int # The exit code of the executable file
diffExitCode: Int # The exit code of diff
See Scorable.md for more information on score
.