Skip to content

Commit

Permalink
ci: Allow for single exercise test exection (exercism#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre authored Nov 11, 2024
1 parent 92ef74b commit 1df6486
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ composer test:run

This is included in `composer ci` to run the CI checks locally.

### Run a specific test

If you want to run tests for one specific exercise, you can do it with following cli command.

```shell
composer test:run -- exercise-name
# e.g
composer test:run -- book-store
```

If you want to run all starting with let's say 'b' you can run

```shell
composer test:run -- "b*"
```

## Running Style Checker

This project uses a slightly [modified][local-file-phpcs-config] version of [PSR-12].
Expand Down
9 changes: 7 additions & 2 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ file_ext="php"
function main {
has_failures=0

all_practice_exercise_dirs=$(find ./exercises/practice -maxdepth 1 -mindepth 1 -type d | sort)
name_filter=()
if [ $# -ge 1 ] && [ -n "$1" ]; then
name_filter=("-name" "$1")
fi

all_practice_exercise_dirs=$(find ./exercises/practice -maxdepth 1 -mindepth 1 -type d "${name_filter[@]}" | sort)
for exercise_dir in $all_practice_exercise_dirs; do
test "${exercise_dir}" "example"
if [[ $? -ne 0 ]]; then
has_failures=1
fi
done

all_concept_exercise_dirs=$(find ./exercises/concept -maxdepth 1 -mindepth 1 -type d | sort)
all_concept_exercise_dirs=$(find ./exercises/concept -maxdepth 1 -mindepth 1 -type d "${name_filter[@]}" | sort)
for exercise_dir in $all_concept_exercise_dirs; do
test "${exercise_dir}" "exemplar"
if [[ $? -ne 0 ]]; then
Expand Down

0 comments on commit 1df6486

Please sign in to comment.