Skip to content
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ Since the tests are mostly just jUnit tests, IntelliJ and other IDE's provide su
Per exercise, create a new project. The `config.json` file should be in the project root. Mark (or create) the `workdir`, `evaluation` and `solution` directories as "sources root". Add jUnit 4 as a dependency of the project.

If your exercises use some Dodona-specific features, such as the `TabTitle` or the `AssertionStubber`, add the Judge as a dependency. Opening this repository as an IntelliJ project should allow you to create a JAR.

## Developing the judge

While developing, you can use `./integration-tests/run` to validate whether the judge is working properly. It checks the judge's output JSON against previous results (stored as `result.json`) and monitors whether something has changed.

You can also use `./integration-tests/run <path-to-repo>` to run the same checks on an exercise repository, which is useful to validate a larger set op exercises.

With `---overwrite`, you can overwrite previous `result.json` files with the current output, and with `-v` you can check for judge error output and view the exact changes when output differs.
18 changes: 0 additions & 18 deletions i18n/en

This file was deleted.

18 changes: 0 additions & 18 deletions i18n/nl

This file was deleted.

1 change: 1 addition & 0 deletions integration-tests/correct/config.json
1 change: 1 addition & 0 deletions integration-tests/correct/evaluation
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"command": "start-tab",
"hidden": false,
"permission": "student",
"title": "Vertaalde titel"
"title": "Tab title"
}
{
"command": "start-context",
"description": {
"description": "Vertaalde Test",
"description": "Test description",
"format": "code"
}
}
Expand Down
1 change: 1 addition & 0 deletions integration-tests/forgotten-semicolon/config.json
1 change: 1 addition & 0 deletions integration-tests/forgotten-semicolon/evaluation
1 change: 0 additions & 1 deletion integration-tests/i18n-correct-en/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-correct-en/evaluation

This file was deleted.

34 changes: 0 additions & 34 deletions integration-tests/i18n-correct-en/result.json

This file was deleted.

4 changes: 0 additions & 4 deletions integration-tests/i18n-correct-nl/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-correct-nl/evaluation

This file was deleted.

7 changes: 0 additions & 7 deletions integration-tests/i18n-correct-nl/submission.java

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-forgotten-semicolon/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-forgotten-semicolon/evaluation

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-stackoverflow/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-stackoverflow/evaluation

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions integration-tests/i18n-with-package-nl/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/i18n-with-package-nl/evaluation

This file was deleted.

37 changes: 0 additions & 37 deletions integration-tests/i18n-with-package-nl/result.json

This file was deleted.

9 changes: 0 additions & 9 deletions integration-tests/i18n-with-package-nl/submission.java

This file was deleted.

29 changes: 17 additions & 12 deletions integration-tests/run
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#!/usr/bin/env bash
set -e
shopt -s globstar

# Default values
target_dir="integration-tests"
overwrite=0
err_out="/dev/null"

# Parse arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--overwrite)
overwrite=1
;;
-v|--verbose)
err_out="/dev/stderr"
;;
*)
target_dir="$1"
;;
Expand All @@ -26,7 +31,7 @@ minor_change=0
major_change=0

# Find all config.json files in target directory
for config in "$target_dir"/**/config.json; do
for config in $target_dir/**/config.json; do
test_dir="$(dirname "$config")"

# Extract config values
Expand Down Expand Up @@ -69,7 +74,7 @@ for config in "$target_dir"/**/config.json; do
, "memory_limit": 1000000000
, "source": "'"$judge/$source"'"
}' \
| (timeout -k 10s 60s "$judge/run" 2> /dev/null) \
| (timeout -k 10s 60s "$judge/run" 2> "$err_out") \
| jq --sort-keys 'if(.command == "append-message")
then .message.description |= gsub("\n at [^\n]+\\([^)]+\\)"; "")
else .
Expand All @@ -80,30 +85,30 @@ for config in "$target_dir"/**/config.json; do
rm -r "$workdir"

# Count accepted and failed in output
accepted_output="$(echo "$output" | jq -s 'map(select(.accepted == true)) | length')"
failed_output="$(echo "$output" | jq -s 'map(select(.accepted == false)) | length')"
echo -en "$accepted_output accepted, $failed_output failed\t"
accepted_actual="$(echo "$output" | jq -s 'map(select(.accepted == true)) | length')"
failed_actual="$(echo "$output" | jq -s 'map(select(.accepted == false)) | length')"
echo -en "$accepted_actual accepted, $failed_actual failed\t"



if [ -f "$result_file" ]; then
# Count accepted and failed in result
accepted_result="$(jq -s 'map(select(.accepted == true)) | length' "$result_file" )"
failed_result="$(jq -s 'map(select(.accepted == true)) | length' "$result_file" )"

accepted_expected="$(jq -s 'map(select(.accepted == true)) | length' "$result_file" )"
failed_expected="$(jq -s 'map(select(.accepted == false)) | length' "$result_file" )"

# First check if files are exact using diff, then check if they differ except '.description', then check they differ in accepted or failed
if diff "$result_file" <(echo "$output") > /dev/null; then

if diff -c "$result_file" <(echo "$output") > "$err_out"; then
echo "[EXACT MATCH]"
exact_match=$((exact_match + 1))
elif diff <(jq "del(.description)" "$result_file") <(echo "$output" | jq "del(.description)") > /dev/null; then
elif diff -c <(jq "del(.description)" "$result_file") <(echo "$output" | jq "del(.description)") > /dev/null; then
echo "[DESCRIPTION CHANGED]"
description_changed=$((description_changed + 1))
elif [ "$accepted_output" -eq "$accepted_result" ] && [ "$failed_output" -eq "$failed_result" ]; then
elif [ "$accepted_actual" -eq "$accepted_expected" ] && [ "$failed_actual" -eq "$failed_expected" ]; then
echo "[MINOR CHANGE] (accepted/failed unchanged)"
minor_change=$((minor_change + 1))
else
echo "[MAJOR CHANGE] (accepted/failed changed, was $accepted_result/$failed_result)"
echo "[MAJOR CHANGE] (accepted/failed changed, expected $accepted_expected/$failed_expected, actual $accepted_actual/$failed_actual)"
major_change=$((major_change + 1))
fi
fi
Expand Down
1 change: 1 addition & 0 deletions integration-tests/stackoverflow/config.json
1 change: 1 addition & 0 deletions integration-tests/stackoverflow/evaluation
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"command": "start-tab",
"hidden": false,
"permission": "student",
"title": "Translated title"
"title": "Tab title"
}
{
"command": "start-context",
"description": {
"description": "Translated Test",
"description": "Test description",
"format": "code"
}
}
Expand Down
4 changes: 0 additions & 4 deletions integration-tests/system-exit-nl/config.json

This file was deleted.

1 change: 0 additions & 1 deletion integration-tests/system-exit-nl/evaluation

This file was deleted.

Loading