Skip to content

Commit

Permalink
Add testsuite supporty (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrfritsch authored Dec 1, 2021
1 parent 70d126e commit 96c75a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ DRUPAL_TESTING_COMPOSER_NAME=${DRUPAL_TESTING_COMPOSER_NAME:-$(jq -r .name "${DR
# vendor/myproject the project name will be myproject.
DRUPAL_TESTING_PROJECT_NAME=${DRUPAL_TESTING_PROJECT_NAME-$(jq -r --arg FALLBACK "$(echo "${DRUPAL_TESTING_COMPOSER_NAME}" | cut -d '/' -f 2)" '.extra."installer-name" // $FALLBACK' "${DRUPAL_TESTING_PROJECT_BASEDIR}/composer.json")}

# Path for phpunit to search for test files. Default is the current project folder.
DRUPAL_TESTING_TEST_PATH=${DRUPAL_TESTING_TEST_PATH:-""}

# The phpunit test group. To provide multiple groups, concatenate them with comma:
# E.g. DRUPAL_TESTING_TEST_GROUP="mygroup1,mygroup2"
DRUPAL_TESTING_TEST_GROUP=${DRUPAL_TESTING_TEST_GROUP:-""}
Expand All @@ -46,6 +49,10 @@ DRUPAL_TESTING_TEST_GROUP=${DRUPAL_TESTING_TEST_GROUP:-""}
# E.g. DRUPAL_TESTING_TEST_GROUP_EXCLUDE="mygroup1,mygroup2"
DRUPAL_TESTING_TEST_GROUP_EXCLUDE=${DRUPAL_TESTING_TEST_GROUP_EXCLUDE:-""}

# The phpunit testsuite. To provide multiple suites, concatenate them with comma:
# E.g. DRUPAL_TESTING_TEST_SUITE="functional,kernel"
DRUPAL_TESTING_TEST_SUITE=${DRUPAL_TESTING_TEST_SUITE:-""}

# Boolean value if coding styles should be tested with burdamagazinorg/thunder-dev-tools.
# By default coding styles are tested.
DRUPAL_TESTING_TEST_CODING_STYLES=${DRUPAL_TESTING_TEST_CODING_STYLES:-true}
Expand Down
15 changes: 12 additions & 3 deletions lib/stages/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ _stage_run_tests() {

local docroot
local composer_bin_dir
local project_location
local test_location
docroot=$(get_distribution_docroot)
composer_bin_dir=$(get_composer_bin_directory)
project_location=$(get_project_location)
test_location=$(get_project_location)

local test_selection=""
local phpunit=${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}/${composer_bin_dir}/phpunit" --debug"
Expand All @@ -31,6 +31,15 @@ _stage_run_tests() {
test_selection="${test_selection} --exclude-group ${DRUPAL_TESTING_TEST_GROUP_EXCLUDE}"
fi

if [[ ${DRUPAL_TESTING_TEST_SUITE} ]]; then
test_selection="${test_selection} --testsuite ${DRUPAL_TESTING_TEST_SUITE}"
test_location=""
fi

if [[ ${DRUPAL_TESTING_TEST_PATH} ]]; then
test_location="${DRUPAL_TESTING_TEST_PATH}"
fi

if [[ -f ${docroot}/${DRUPAL_TESTING_TEST_DUMP_FILE} ]]; then
# Database needs to be initialized, if the run was split into a build and a test run.
if [[ -x "$(command -v mysql)" ]]; then
Expand All @@ -43,7 +52,7 @@ _stage_run_tests() {
test_selection="${test_selection} --filter ${DRUPAL_TESTING_TEST_FILTER}"
fi

local runtest="php ${phpunit} --verbose --configuration ${docroot}/core ${test_selection} ${project_location}"
local runtest="php ${phpunit} --verbose --configuration ${docroot}/core ${test_selection} ${test_location}"

eval "${runtest}" || exit 1
}

0 comments on commit 96c75a1

Please sign in to comment.