diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 105ba53..5c02118 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,11 +34,16 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: ddev/github-action-add-on-test@v2 with: + disable_checkout_action: true ddev_version: ${{ matrix.ddev_version }} token: ${{ secrets.GITHUB_TOKEN }} debug_enabled: ${{ github.event.inputs.debug_enabled }} addon_repository: ${{ env.GITHUB_REPOSITORY }} addon_ref: ${{ env.GITHUB_REF }} - test_command: eval BATS_LIB_PATH=$(brew --prefix)/lib TEST_DRUPAL_CORE=${{ matrix.drupal_version }} bats tests + test_command: eval TEST_DRUPAL_CORE=${{ matrix.drupal_version }} ./tests/bats/bin/bats tests diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c7ef022 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "tests/bats"] + path = tests/bats + url = https://github.com/bats-core/bats-core.git +[submodule "tests/helpers/bats-assert"] + path = tests/helpers/bats-assert + url = https://github.com/bats-core/bats-assert.git +[submodule "tests/helpers/bats-support"] + path = tests/helpers/bats-support + url = https://github.com/bats-core/bats-support.git diff --git a/README.md b/README.md index afbdb83..47ee33d 100644 --- a/README.md +++ b/README.md @@ -107,14 +107,17 @@ ddev phpcbf -q ## Add-on tests Tests are done with Bats. It is a simple testing framework that just uses Bash. -To run a Bats test locally, you have to [install bats-core][bats-core] first. -Then you can run `bats ./tests` within the root of this project. + +To run tests locally you need to first install the git submodules with: +`git submodule init`. + +Then you can run `./tests/bats/bin/bats ./tests` within the root of this project. Tests will be run using the default drupal core of the contrib. You can test with a different Drupal core version by providing it in a `TEST_DRUPAL_CORE` environment variable. -i.e. `TEST_DRUPAL_CORE=11 bats ./tests`. +i.e. `TEST_DRUPAL_CORE=11 ./tests/bats/bin/bats ./tests`. Tests are triggered either manually, automatically on every push to the repository, or periodically each night. The automated tests are agains all of @@ -127,7 +130,6 @@ Also, consider adding tests to test for bugs or new features on your PR. To learn more about Bats see the [documentation][bats-docs]. -[bats-core]: https://bats-core.readthedocs.io/en/stable/installation.html [bats-docs]: https://bats-core.readthedocs.io/en/stable/ ## Troubleshooting diff --git a/tests/bats b/tests/bats new file mode 160000 index 0000000..89a7fae --- /dev/null +++ b/tests/bats @@ -0,0 +1 @@ +Subproject commit 89a7fae3b651d5c2f42a3874ec32e821014814eb diff --git a/tests/full.bats b/tests/full.bats index 573f2bd..d59ce8b 100644 --- a/tests/full.bats +++ b/tests/full.bats @@ -1,5 +1,5 @@ -bats_load_library 'bats-support' -bats_load_library 'bats-assert' +load helpers/bats-support/load.bash +load helpers/bats-assert/load.bash setup_file() { if [ -n "$TEST_DRUPAL_CORE" ] && [ "$TEST_DRUPAL_CORE" != "10" ] && [ "$TEST_DRUPAL_CORE" != "11" ]; then diff --git a/tests/helpers/bats-assert b/tests/helpers/bats-assert new file mode 160000 index 0000000..e2d855b --- /dev/null +++ b/tests/helpers/bats-assert @@ -0,0 +1 @@ +Subproject commit e2d855bc78619ee15b0c702b5c30fb074101159f diff --git a/tests/helpers/bats-support b/tests/helpers/bats-support new file mode 160000 index 0000000..9bf10e8 --- /dev/null +++ b/tests/helpers/bats-support @@ -0,0 +1 @@ +Subproject commit 9bf10e876dd6b624fe44423f0b35e064225f7556