Skip to content

Commit 1df6486

Browse files
authored
ci: Allow for single exercise test exection (#849)
1 parent 92ef74b commit 1df6486

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ composer test:run
4040

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

43+
### Run a specific test
44+
45+
If you want to run tests for one specific exercise, you can do it with following cli command.
46+
47+
```shell
48+
composer test:run -- exercise-name
49+
# e.g
50+
composer test:run -- book-store
51+
```
52+
53+
If you want to run all starting with let's say 'b' you can run
54+
55+
```shell
56+
composer test:run -- "b*"
57+
```
58+
4359
## Running Style Checker
4460

4561
This project uses a slightly [modified][local-file-phpcs-config] version of [PSR-12].

bin/test.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ file_ext="php"
1313
function main {
1414
has_failures=0
1515

16-
all_practice_exercise_dirs=$(find ./exercises/practice -maxdepth 1 -mindepth 1 -type d | sort)
16+
name_filter=()
17+
if [ $# -ge 1 ] && [ -n "$1" ]; then
18+
name_filter=("-name" "$1")
19+
fi
20+
21+
all_practice_exercise_dirs=$(find ./exercises/practice -maxdepth 1 -mindepth 1 -type d "${name_filter[@]}" | sort)
1722
for exercise_dir in $all_practice_exercise_dirs; do
1823
test "${exercise_dir}" "example"
1924
if [[ $? -ne 0 ]]; then
2025
has_failures=1
2126
fi
2227
done
2328

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

0 commit comments

Comments
 (0)