Skip to content

Commit

Permalink
test files: rename xxx_test.sh to xxx.bats, fix shebang (#541)
Browse files Browse the repository at this point in the history
* test files: rename xxx_test.sh to xxx.bats, fix shebang

* pr.yml: remove md, add bats.

* Fix a help file (thanks to Glenn)

* Also trigger running tests for renamed files

Co-authored-by: Glenn Jackman <[email protected]>
  • Loading branch information
braoult and glennj authored Sep 17, 2021
1 parent e8a34bd commit 79a2d5a
Show file tree
Hide file tree
Showing 186 changed files with 193 additions and 193 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
run: |
pr_endpoint=$(jq -r '"repos/\(.repository.full_name)/pulls/\(.pull_request.number)"' "$GITHUB_EVENT_PATH")
gh api "$pr_endpoint/files" --paginate --jq '
.[] |
select(.status == "added" or .status == "modified") |
select(.filename | match("\\.(md|sh|bash)$")) |
.[] |
select(.status == "added" or .status == "modified" or .status == "renamed") |
select(.filename | match("\\.(sh|bash|bats)$")) |
.filename
' | xargs -r bash .github/scripts/pr
2 changes: 1 addition & 1 deletion POLICIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ document, which thoroughly discusses the structure of an exercise.

### Exercise Test Structure

The tests will not enforce using a specific function, unless the problems are complex or requires it (ex: https://github.com/exercism/bash/blob/main/exercises/practice/list-ops/list_ops_test.sh)
The tests will not enforce using a specific function, unless the problems are complex or requires it (ex: https://github.com/exercism/bash/blob/main/exercises/practice/list-ops/list_ops.bats)

```
run bash exercise.sh "string"
Expand Down
2 changes: 1 addition & 1 deletion bin/canonical_data_check
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ do
echo "$slug: needs update (v$track_data_version -> v$canonical_data_version)."
fi

test_file="$path_to_track/exercises/$slug/${slug//-/_}_test.sh"
test_file="$path_to_track/exercises/$slug/${slug//-/_}.bats"
test_file_version=$( awk '/# local version: / {print $NF}' "$test_file" )

# the test file version number must include the .meta
Expand Down
4 changes: 2 additions & 2 deletions bin/validate_one_exercise
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exercise_name=${exercise//-/_} # replace "-" with "_" to follow convention
solution="./.meta/example.sh"

[[ -f ${exercise_name}.sh ]] || die "Missing stub file for $exercise"
[[ -f ${exercise_name}_test.sh ]] || die "Missing tests file for $exercise"
[[ -f ${exercise_name}.bats ]] || die "Missing tests file for $exercise"
[[ -f ${solution} ]] || die "Missing solution file for $exercise"

echo "Processing $exercise"
Expand All @@ -32,4 +32,4 @@ trap cleanup EXIT
cp "${solution}" "${exercise_name}.sh"

# Run the tests
bats "${exercise_name}_test.sh"
bats "${exercise_name}.bats"
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"%{snake_slug}.sh"
],
"test": [
"%{snake_slug}_test.sh"
"%{snake_slug}.bats"
],
"example": [
".meta/example.sh"
Expand Down
2 changes: 1 addition & 1 deletion docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ leader in the bash testing area. For these examples we are using
Run the tests for the hypothetical "whatever" exercise like this:
```bash
cd /path/to/your/exercise_workspace/bash/whatever
bats whatever_test.sh
bats whatever.bats
```

For help on the meaning of the various `assert*` commands in the
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/acronym/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"acronym.sh"
],
"test": [
"acronym_test.sh"
"acronym.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.7.0.1
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/affine-cipher/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"affine_cipher.sh"
],
"test": [
"affine_cipher_test.sh"
"affine_cipher.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/all-your-base/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"all_your_base.sh"
],
"test": [
"all_your_base_test.sh"
"all_your_base.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.3.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"allergies.sh"
],
"test": [
"allergies_test.sh"
"allergies.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/anagram/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"anagram.sh"
],
"test": [
"anagram_test.sh"
"anagram.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.5.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/armstrong-numbers/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"armstrong_numbers.sh"
],
"test": [
"armstrong_numbers_test.sh"
"armstrong_numbers.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.1.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"atbash_cipher.sh"
],
"test": [
"atbash_cipher_test.sh"
"atbash_cipher.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.2.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/beer-song/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"beer_song.sh"
],
"test": [
"beer_song_test.sh"
"beer_song.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.1.0.1
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary-search/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"binary_search.sh"
],
"test": [
"binary_search_test.sh"
"binary_search.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.3.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bob/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"bob.sh"
],
"test": [
"bob_test.sh"
"bob.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.6.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/bowling/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bowling.sh"
],
"test": [
"bowling_test.sh"
"bowling.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.2.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/change/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"change.sh"
],
"test": [
"change_test.sh"
"change.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.3.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/clock/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clock.sh"
],
"test": [
"clock_test.sh"
"clock.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.4.0.1
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/collatz-conjecture/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"collatz_conjecture.sh"
],
"test": [
"collatz_conjecture_test.sh"
"collatz_conjecture.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.2.1.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/crypto-square/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"crypto_square.sh"
],
"test": [
"crypto_square_test.sh"
"crypto_square.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 3.2.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/darts/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"darts.sh"
],
"test": [
"darts_test.sh"
"darts.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.2.0.1
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/diamond/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"diamond.sh"
],
"test": [
"diamond_test.sh"
"diamond.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.1.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/difference-of-squares/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"difference_of_squares.sh"
],
"test": [
"difference_of_squares_test.sh"
"difference_of_squares.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.2.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/diffie-hellman/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"diffie_hellman.sh"
],
"test": [
"diffie_hellman_test.sh"
"diffie_hellman.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/dnd-character/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dnd_character.sh"
],
"test": [
"dnd_character_test.sh"
"dnd_character.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 1.1.0.0
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/error-handling/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"error_handling.sh"
],
"test": [
"error_handling_test.sh"
"error_handling.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 0.0.1
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/food-chain/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"food_chain.sh"
],
"test": [
"food_chain_test.sh"
"food_chain.bats"
],
"example": [
".meta/example.sh"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bats
load bats-extra

# local version: 2.1.0.0
Expand Down
Loading

0 comments on commit 79a2d5a

Please sign in to comment.