Skip to content
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

chore: execute genreated code while checking examples #141

Merged
merged 1 commit into from
Nov 21, 2024
Merged
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
47 changes: 42 additions & 5 deletions run_all_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,47 @@ use_poetry=true
if [[ "${1:-}" == "--no-poetry" ]]; then
use_poetry=false
fi
readonly use_poetry

function check_puzzle_code() {
local puzzle_str="$1"
readonly puzzle_str

if ! echo -e "2\nPiotr" | python3 -c "${puzzle_str}"
then
return 1
fi

if echo -e "3" | python3 -c "${puzzle_str}"
then
return 2
fi

if echo -e "2\nWrong!" | python3 -c "${puzzle_str}"
then
return 3
fi

return 0
}

function check_example() {
local example_file="$1"
printf "Checking \"%s\"\n" "${example_file}"
readonly example_file

local puzzle_str
if ${use_poetry}; then
puzzle_str=$(poetry run python3 "${example_file}")
else
puzzle_str=$(python3 "${example_file}")
fi
readonly puzzle_str
check_puzzle_code "${puzzle_str}"
}

cd examples/
if $use_poetry; then
find . -name "*.py" -exec poetry run python3 {} +
else
find . -name "*.py" -exec python3 {} +
fi

find . -name "*.py" | while read -r file; do
check_example "${file}"
done