Skip to content

Commit

Permalink
Fix GHA tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Jul 27, 2024
1 parent e5dd386 commit 626d6b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
33 changes: 17 additions & 16 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,26 @@ test_output=$(prove ${solution_dir}/${slug}-test.ys 2>&1)

# Write the results.json file based on the exit code of the command that was
# just executed that tested the implementation file
sanitized_test_output=$(printf "${test_output}" | sed '/wallclock/d')
if [ $? -eq 0 ]; then
jq -n '{version: 1, status: "pass"}' > ${results_file}
elif [ $? -eq 255 ]; then
sanitized_test_output=$(printf "${test_output}" | sed '/wallclock/d')
jq -n --arg output "${sanitized_test_output}" '{version: 1, status: "error", message: $output}' > ${results_file}
else
sanitized_test_output=$(printf "${test_output}" | sed '/wallclock/d')
jq -n --arg output "${sanitized_test_output}" '{version: 1, status: "fail", message: $output}' > ${results_file}
# OPTIONAL: Sanitize the output
# In some cases, the test output might be overly verbose, in which case stripping
# the unneeded information can be very helpful to the student
# sanitized_test_output=$(printf "${test_output}" | sed -n '/Test results:/,$p')

# OPTIONAL: Manually add colors to the output to help scanning the output for errors
# If the test output does not contain colors to help identify failing (or passing)
# tests, it can be helpful to manually add colors to the output
# colorized_test_output=$(echo "${test_output}" \
# | GREP_COLOR='01;31' grep --color=always -E -e '^(ERROR:.*|.*failed)$|$' \
# | GREP_COLOR='01;32' grep --color=always -E -e '^.*passed$|$')
if (echo "$sanitized_test_output" | grep -q '^ Failed tests: '); then
jq -n --arg output "${sanitized_test_output}" '{version: 1, status: "fail", message: $output}' > ${results_file}
# OPTIONAL: Sanitize the output
# In some cases, the test output might be overly verbose, in which case stripping
# the unneeded information can be very helpful to the student
# sanitized_test_output=$(printf "${test_output}" | sed -n '/Test results:/,$p')

# OPTIONAL: Manually add colors to the output to help scanning the output for errors
# If the test output does not contain colors to help identify failing (or passing)
# tests, it can be helpful to manually add colors to the output
# colorized_test_output=$(echo "${test_output}" \
# | GREP_COLOR='01;31' grep --color=always -E -e '^(ERROR:.*|.*failed)$|$' \
# | GREP_COLOR='01;32' grep --color=always -E -e '^.*passed$|$')
else
jq -n --arg output "${sanitized_test_output}" '{version: 1, status: "error", message: $output}' > ${results_file}
fi
fi

echo "${slug}: done"
1 change: 1 addition & 0 deletions tests/syntax-error/leap.ys
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
!yamlscript/v0

defn is-leap-year():
- this is invalid yamlscript

0 comments on commit 626d6b9

Please sign in to comment.