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
21 changes: 20 additions & 1 deletion bin/validate_exercises
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@
set -o errexit
set -o nounset

usage() {
cat << END_HELP
usage: $0 [-D]
where: -D run in test-runner (default: run locally)
END_HELP
exit 1
}
die() { echo "$*" >&2; exit 1; }

opts=()
while getopts ':hD' opt; do
case $opt in
h) usage ;;
D) opts+=(-D) ;;
*) die "unknown option: -$OPTARG" ;;
esac
done
shift $((OPTIND - 1))

cd "$( dirname "${BASH_SOURCE[0]}" )/.."

for exercise in exercises/*/*; do
bin/validate_one_exercise "$exercise"
bin/validate_one_exercise "${opts[@]}" "$exercise"
echo
done
6 changes: 5 additions & 1 deletion bin/validate_one_exercise
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ dir=$(mktemp -d)
cp "${solution}" "${dir}/${stub}"
cp "${tests}" "${dir}/${tests}"
cp bats-*.bash "${editor_files[@]}" "${dir}"
mkdir "$dir/.meta"
cp .meta/config.json "${dir}/.meta"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It more accurately runs this script the way the test runner does. Consider eliuds-eggs: most other tracks use the slug name in the solution, but here the solution is pop_count.sh (and the test file too). The online test runner has no trouble with this exercise, but running bin/validate_one_exercise -D eliuds-eggs was erroring.

I've seen other tracks that have a bin/validate-track-in-docker in either the track or the test runner. Now in the bash track bin/validate_exercises -D fulfills that purpose.


# Run the tests
cd "${dir}"
if $in_docker; then
docker pull exercism/bash-test-runner
# only pull the image if it's not available locally
docker image inspect exercism/bash-test-runner >/dev/null 2>&1 \
|| docker pull exercism/bash-test-runner
docker run \
--rm \
--network none \
Expand Down