Skip to content

Commit

Permalink
Excluded tests from test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Feb 15, 2024
1 parent e3ffbfc commit e75b099
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
38 changes: 17 additions & 21 deletions .drevops/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ setup() {
# Enforce architecture if not provided for ARM. Note that this may not work
# if bash uses Rosetta or other emulators, in which case the test should run
# with the variable explicitly set.
# LCOV_EXCL_START
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
export DOCKER_DEFAULT_PLATFORM=linux/amd64
fi

if [ -n "${DOCKER_DEFAULT_PLATFORM:-}" ]; then
step "Using ${DOCKER_DEFAULT_PLATFORM} platform architecture."
fi
# LCOV_EXCL_STOP

# Register a path to libraries.
export BATS_LIB_PATH="${BATS_TEST_DIRNAME}/../node_modules"
Expand Down Expand Up @@ -265,7 +267,6 @@ assert_files_not_present_common() {
local dir="${1:-$(pwd)}"
local suffix="${2:-sw}"
local suffix_abbreviated="${3:-sw}"
local has_required_files="${4:-0}"
local webroot="${5:-web}"

pushd "${dir}" >/dev/null || exit 1
Expand All @@ -287,26 +288,19 @@ assert_files_not_present_common() {
assert_file_not_exists "docs/faqs.md"
assert_file_not_exists ".ahoy.yml"

if [ "${has_required_files:-}" -eq 1 ]; then
assert_file_exists "README.md"
assert_file_exists ".circleci/config.yml"
assert_file_exists "${webroot}/sites/default/settings.php"
assert_file_exists "${webroot}/sites/default/services.yml"
else
assert_file_not_exists "README.md"
assert_file_not_exists ".circleci/config.yml"
assert_file_not_exists "${webroot}/sites/default/settings.php"
assert_file_not_exists "${webroot}/sites/default/services.yml"
# Scaffolding files not exist.
assert_file_not_exists "${webroot}/.editorconfig"
assert_file_not_exists "${webroot}/.eslintignore"
assert_file_not_exists "${webroot}/.gitattributes"
assert_file_not_exists "${webroot}/.htaccess"
assert_file_not_exists "${webroot}/autoload.php"
assert_file_not_exists "${webroot}/index.php"
assert_file_not_exists "${webroot}/robots.txt"
assert_file_not_exists "${webroot}/update.php"
fi
assert_file_not_exists "README.md"
assert_file_not_exists ".circleci/config.yml"
assert_file_not_exists "${webroot}/sites/default/settings.php"
assert_file_not_exists "${webroot}/sites/default/services.yml"
# Scaffolding files not exist.
assert_file_not_exists "${webroot}/.editorconfig"
assert_file_not_exists "${webroot}/.eslintignore"
assert_file_not_exists "${webroot}/.gitattributes"
assert_file_not_exists "${webroot}/.htaccess"
assert_file_not_exists "${webroot}/autoload.php"
assert_file_not_exists "${webroot}/index.php"
assert_file_not_exists "${webroot}/robots.txt"
assert_file_not_exists "${webroot}/update.php"

popd >/dev/null || exit 1
}
Expand Down Expand Up @@ -1332,6 +1326,7 @@ download_installer() {

git fetch installer_origin "${TEST_INSTALLER_REF}" >/dev/null

# LCOV_EXCL_START
if git branch -a | grep -q "remotes/installer_origin/${TEST_INSTALLER_REF}$"; then
echo "Checking out the installer from branch ref: ${TEST_INSTALLER_REF}" >&3
git checkout "${TEST_INSTALLER_REF}" >/dev/null
Expand All @@ -1342,6 +1337,7 @@ download_installer() {
echo "The provided reference does not match any branch or commit." >&3
exit 1
fi
# LCOV_EXCL_STOP

echo "Checkout successful."

Expand Down
9 changes: 1 addition & 8 deletions .drevops/tests/bats/_helper.deployment.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

assert_deployment_files_present() {
local dir="${1:-$(pwd)}"
local has_custom_profile="${2:-0}"
local webroot="${3:-web}"
local webroot="web"

pushd "${dir}" >/dev/null || exit 1

Expand Down Expand Up @@ -40,12 +39,6 @@ assert_deployment_files_present() {
# We are passing .env configs to allow to control the project from a single place.
assert_file_exists .env

if [ "${has_custom_profile:-}" -eq 1 ]; then
# Site profile present.
assert_dir_exists "${webroot}/profiles/custom/star_wars_profile"
assert_file_exists "${webroot}/profiles/custom/star_wars_profile/star_wars_profile.info.yml"
fi

# Site core module present.
assert_dir_exists "${webroot}/modules/custom/sw_core"
assert_file_exists "${webroot}/modules/custom/sw_core/sw_core.info.yml"
Expand Down
4 changes: 3 additions & 1 deletion .drevops/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ prepare_sut() {

assert_not_empty "${DREVOPS_DEV_VOLUMES_MOUNTED}"

assert_files_not_present_common "" "" "" "" "${webroot}"
assert_files_not_present_common "" "" "" "${webroot}"

substep "Initialise the project with default settings"

Expand All @@ -37,10 +37,12 @@ prepare_sut() {
touch .idea/idea_file.txt
assert_file_exists .idea/idea_file.txt

# LCOV_EXCL_START
if uname -a | grep -q ARM64; then
substep "Override local Docker Compose for ARM."
cp docker-compose.override.default.yml docker-compose.override.yml
fi
# LCOV_EXCL_STOP
}

docker_remove_image() {
Expand Down
4 changes: 4 additions & 0 deletions scripts/drevops/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ if [ -n "${DREVOPS_DB_DOCKER_IMAGE:-}" ]; then
./scripts/drevops/restore-docker-image.sh "${DREVOPS_DB_DOCKER_IMAGE}" "${DREVOPS_DB_DIR}/db.tar"
# If the image does not exist and base image was provided - use the base
# image which allows "clean slate" for the database.
# LCOV_EXCL_START
if [ ! -f "${DREVOPS_DB_DIR}/db.tar" ] && [ -n "${DREVOPS_DB_DOCKER_IMAGE_BASE:-}" ]; then
note "Database Docker image was not found. Using base image ${DREVOPS_DB_DOCKER_IMAGE_BASE}."
export DREVOPS_DB_DOCKER_IMAGE="${DREVOPS_DB_DOCKER_IMAGE_BASE}"
fi
# LCOV_EXCL_STOP
echo
fi

Expand Down Expand Up @@ -147,6 +149,7 @@ echo
# Note that this will create package-lock.json file if it does not exist.
# We are not re-running compilation in CI as it is not used - these assets
# are already compiled as a part of the Docker build.
# LCOV_EXCL_START
if [ -n "${DRUPAL_THEME:-}" ] && [ -z "${CI:-}" ]; then
info "Installing front-end dependencies."
docker compose exec ${dcopts[@]} cli bash -c 'npm --prefix ${DREVOPS_WEBROOT}/themes/custom/${DRUPAL_THEME} install' >"${npm_verbose_output}"
Expand All @@ -159,6 +162,7 @@ if [ -n "${DRUPAL_THEME:-}" ] && [ -z "${CI:-}" ]; then
pass "Created Livereload socket."
echo
fi
# LCOV_EXCL_STOP

# Provision site.
# Pass environment variables to the container from the environment.
Expand Down
2 changes: 2 additions & 0 deletions scripts/drevops/deploy-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fi

[ ! -f "${DREVOPS_DEPLOY_SSH_FILE:-}" ] && fail "SSH key file ${DREVOPS_DEPLOY_SSH_FILE} does not exist." && exit 1

# LCOV_EXCL_START
if ssh-add -l | grep -q "${DREVOPS_DEPLOY_SSH_FILE}"; then
note "SSH agent has ${DREVOPS_DEPLOY_SSH_FILE} key loaded."
else
Expand All @@ -92,6 +93,7 @@ else
ssh-add -D >/dev/null
ssh-add "${DREVOPS_DEPLOY_SSH_FILE}"
fi
# LCOV_EXCL_STOP

# Disable strict host key checking in CI.
[ -n "${CI:-}" ] && mkdir -p "${HOME}/.ssh/" && echo -e "\nHost *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null\n" >>"${HOME}/.ssh/config"
Expand Down
2 changes: 2 additions & 0 deletions scripts/drevops/deploy-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ fi

[ ! -f "${DREVOPS_DEPLOY_SSH_FILE}" ] && fail "SSH key file ${DREVOPS_DEPLOY_SSH_FILE} does not exist." && exit 1

# LCOV_EXCL_START
if ssh-add -l | grep -q "${DREVOPS_DEPLOY_SSH_FILE}"; then
note "SSH agent has ${DREVOPS_DEPLOY_SSH_FILE} key loaded."
else
Expand All @@ -100,6 +101,7 @@ else
ssh-add -D >/dev/null
ssh-add "${DREVOPS_DEPLOY_SSH_FILE}"
fi
# LCOV_EXCL_STOP

# Disable strict host key checking in CI.
[ -n "${CI:-}" ] && mkdir -p "${HOME}/.ssh/" && echo -e "\nHost *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null\n" >>"${HOME}/.ssh/config"
Expand Down
2 changes: 2 additions & 0 deletions scripts/drevops/export-db-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ docker save -o "${archive_file}" "${new_image}"
if [ -f "${archive_file}" ] && [ -s "${archive_file}" ]; then
note "Saved exported database image archive file ${archive_file}."
else
# LCOV_EXCL_START
fail "Unable to save database image archive file ${archive_file}." && exit 1
# LCOV_EXCL_STOP
fi

pass "Finished Docker database image export."

0 comments on commit e75b099

Please sign in to comment.