-
-
Notifications
You must be signed in to change notification settings - Fork 9
Remove jq dependency #102
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
Merged
Merged
Remove jq dependency #102
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4121c85
Remove jq dependency
codingthat 5fac842
Update test runner directory to align with test runner repo
codingthat d4d4a27
Fixes thanks to shellcheck
codingthat 8c69e6f
Don't use ${} where simpler $ suffices
codingthat ab00e2d
Convert verify-exercises to GDScript to still properly process config…
codingthat 205d2c0
Update test runner to use GDScript
codingthat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,40 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| temp_dir_base=$(mktemp -d) | ||
| echo $(godot --version) | ||
| godot --version | ||
|
|
||
| run_test() { | ||
| slug=$(basename $1) | ||
| slug=$(basename "$1") | ||
| temp_dir=${temp_dir_base}/${slug} | ||
| mkdir -p ${temp_dir} | ||
| mkdir -p "${temp_dir}" | ||
| # Copy relevant files to the temp directory (replace solution with example) | ||
| solution_file_name="$(jq -r '.files.solution[0]' $1/.meta/config.json)" | ||
| test_file="$1/$(jq -r '.files.test[0]' $1/.meta/config.json)" | ||
| example_file="$1/$(jq -r '.files.example[0]' $1/.meta/config.json)" | ||
| cp ${test_file} ${temp_dir} | ||
| solution_file_name="$slug.gd" | ||
| test_file="${slug}_test.gd" | ||
| example_file=".meta/example.gd" | ||
| cp "${test_file}" "${temp_dir}" | ||
| cp ${example_file} "${temp_dir}/${solution_file_name}" | ||
| # Run the tests | ||
| (cd /opt/test-runner && bin/run.sh $slug $temp_dir $temp_dir) || exit 1 | ||
| (cd /opt/exercism/gdscript/test-runner && bin/run.sh "$slug" "$temp_dir" "$temp_dir") || exit 1 | ||
codingthat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Check status | ||
| test_status="$(jq -r '.status' $temp_dir/results.json)" | ||
| if [ "$test_status" != "pass" ]; then | ||
| if [[ $(cat "$temp_dir"/results.json) =~ ' "status": "fail",' ]]; then | ||
codingthat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "Tests for $slug have failed:" | ||
| cat $temp_dir/results.json | ||
| cat "$temp_dir"/results.json | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| # Verify the Concept Exercises | ||
| for concept_exercise_dir in ./exercises/concept/*/; do | ||
| if [ -d $concept_exercise_dir ]; then | ||
| if [ -d "$concept_exercise_dir" ]; then | ||
codingthat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "Checking $(basename "${concept_exercise_dir}") exercise..." | ||
| run_test $concept_exercise_dir | ||
| run_test "$concept_exercise_dir" | ||
| fi | ||
| done | ||
|
|
||
| # Verify the Practice Exercises | ||
| for practice_exercise_dir in ./exercises/practice/*/; do | ||
| if [ -d $practice_exercise_dir ]; then | ||
| if [ -d "$practice_exercise_dir" ]; then | ||
codingthat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "Checking $(basename "${practice_exercise_dir}") exercise..." | ||
| run_test $practice_exercise_dir | ||
| run_test "$practice_exercise_dir" | ||
| fi | ||
| done | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you not using the
config.json? That's more reliable.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the preexisting
test_runner.gdthat this script indirectly calls:Since that's already being assumed there, this seemed the most straightforward way to remove
jqfrom this spot. As it currently is (and already had been before this PR), followingconfig.jsonhere but not in the test runner would make the test runner fail if an exercise deviated from this convention.I see that the behavior in
test_runner.gdis implied by the spec, becausetest_runner.gdnormally wouldn't have access toconfig.json(especially if a tmp dir is used that doesn't contain it).For consistency with other tracks, we could ditch bash entirely in favor of GDScript for
verify-exercises— then we can have JSON parsing for free here. (That's what the Python track seems to do.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assumptions are precursors to bugs ;) But if that assumption is already baked in... 🤷
If that's not too much work, it would be a nice improvement.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meatball133 I can do this but are you OK with that, or was there some reason verify-exercises needed to be a bash script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( OK'd @ http://forum.exercism.org/t/create-new-track-for-gdscript/3955/218 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, it's converted ✔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still depends on exercism/gdscript-test-runner#54 to pass though.