From 835056d707e12efb6454bc714544f3a14ae27852 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Sat, 26 Nov 2022 11:37:58 +1300 Subject: [PATCH] tests(chore): Use `REPOSITORY_ROOT` export var from Makefile Allows for using `load` with an absolute path instead of a relative one, which makes it possible to group tests into different directories. Parallel tests differ slightly, loading the newer `helper/common.bash` and `helper/setup.bash` files instead of the older `test_helper/common.bash` which serial tests continue to use. --- test/test_helper/common.bash | 4 ++-- test/test_helper/tls.bash | 2 +- test/tests/parallel/set1/clamav.bats | 3 ++- test/tests/parallel/set1/default_relay_host.bats | 3 ++- test/tests/parallel/set2/spam_bounced.bats | 5 ++--- test/tests/parallel/set3/dovecot_inet_protocol.bats | 3 ++- test/tests/parallel/set3/helper-functions.bats | 3 ++- test/tests/serial/mail_changedetector.bats | 2 +- test/tests/serial/mail_disabled_clamav_spamassassin.bats | 2 +- test/tests/serial/mail_dnsbl.bats | 2 +- test/tests/serial/mail_fail2ban.bats | 2 +- test/tests/serial/mail_fetchmail.bats | 2 +- test/tests/serial/mail_fetchmail_parallel.bats | 2 +- test/tests/serial/mail_hostname.bats | 2 +- test/tests/serial/mail_lmtp_ip.bats | 2 +- test/tests/serial/mail_pop3.bats | 2 +- test/tests/serial/mail_postfix_inet.bats | 2 +- test/tests/serial/mail_postscreen.bats | 2 +- test/tests/serial/mail_privacy.bats | 2 +- test/tests/serial/mail_quotas_disabled.bats | 2 +- test/tests/serial/mail_smtponly.bats | 2 +- test/tests/serial/mail_spam_junk_folder.bats | 2 +- test/tests/serial/mail_special_use_folders.bats | 2 +- test/tests/serial/mail_ssl_letsencrypt.bats | 4 ++-- test/tests/serial/mail_ssl_manual.bats | 2 +- test/tests/serial/mail_time.bats | 2 +- test/tests/serial/mail_tls_dhparams.bats | 2 +- test/tests/serial/mail_undef_spam_subject.bats | 2 +- test/tests/serial/mail_with_imap.bats | 2 +- test/tests/serial/mail_with_ldap.bats | 2 +- test/tests/serial/mail_with_mdbox.bats | 2 +- test/tests/serial/mail_with_postgrey.bats | 2 +- .../tests/serial/mail_with_postgrey_disabled_by_default.bats | 2 +- test/tests/serial/mail_with_relays.bats | 2 +- test/tests/serial/mail_with_sdbox.bats | 2 +- test/tests/serial/no_container.bats | 2 +- test/tests/serial/open_dkim.bats | 2 +- test/tests/serial/permit_docker.bats | 2 +- test/tests/serial/security_tls_cipherlists.bats | 2 +- test/tests/serial/sedfile.bats | 2 +- test/tests/serial/setup-cli.bats | 2 +- test/tests/serial/test_helper.bats | 4 +--- test/tests/serial/tests.bats | 2 +- 43 files changed, 50 insertions(+), 49 deletions(-) diff --git a/test/test_helper/common.bash b/test/test_helper/common.bash index 46b92317..1ce9d587 100644 --- a/test/test_helper/common.bash +++ b/test/test_helper/common.bash @@ -1,7 +1,7 @@ #!/bin/bash -load 'test_helper/bats-support/load' -load 'test_helper/bats-assert/load' +load "${REPOSITORY_ROOT}/test/test_helper/bats-support/load" +load "${REPOSITORY_ROOT}/test/test_helper/bats-assert/load" NAME=${NAME:-mailserver-testing:ci} diff --git a/test/test_helper/tls.bash b/test/test_helper/tls.bash index 7ced47fb..4987a66f 100644 --- a/test/test_helper/tls.bash +++ b/test/test_helper/tls.bash @@ -1,6 +1,6 @@ #!/bin/bash -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Helper methods for testing TLS. # `_should_*` methods are useful for common high-level functionality. diff --git a/test/tests/parallel/set1/clamav.bats b/test/tests/parallel/set1/clamav.bats index 2a42cc13..760e3dfb 100644 --- a/test/tests/parallel/set1/clamav.bats +++ b/test/tests/parallel/set1/clamav.bats @@ -1,4 +1,5 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/helper/setup" +load "${REPOSITORY_ROOT}/test/helper/common" TEST_NAME_PREFIX='ClamAV:' CONTAINER_NAME='dms-test-clamav' diff --git a/test/tests/parallel/set1/default_relay_host.bats b/test/tests/parallel/set1/default_relay_host.bats index b22420ed..399f7423 100644 --- a/test/tests/parallel/set1/default_relay_host.bats +++ b/test/tests/parallel/set1/default_relay_host.bats @@ -1,4 +1,5 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/helper/setup" +load "${REPOSITORY_ROOT}/test/helper/common" function setup() { local PRIVATE_CONFIG diff --git a/test/tests/parallel/set2/spam_bounced.bats b/test/tests/parallel/set2/spam_bounced.bats index 4848087e..5e5421ec 100644 --- a/test/tests/parallel/set2/spam_bounced.bats +++ b/test/tests/parallel/set2/spam_bounced.bats @@ -1,6 +1,5 @@ -load 'test_helper/common' -# Globals referenced from `test_helper/common`: -# TEST_NAME +load "${REPOSITORY_ROOT}/test/helper/setup" +load "${REPOSITORY_ROOT}/test/helper/common" # Can run tests in parallel?: No # Shared static container name: TEST_NAME diff --git a/test/tests/parallel/set3/dovecot_inet_protocol.bats b/test/tests/parallel/set3/dovecot_inet_protocol.bats index ab31db4a..513a73d3 100644 --- a/test/tests/parallel/set3/dovecot_inet_protocol.bats +++ b/test/tests/parallel/set3/dovecot_inet_protocol.bats @@ -1,4 +1,5 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/helper/setup" +load "${REPOSITORY_ROOT}/test/helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/parallel/set3/helper-functions.bats b/test/tests/parallel/set3/helper-functions.bats index 2c10c9e1..ca155155 100644 --- a/test/tests/parallel/set3/helper-functions.bats +++ b/test/tests/parallel/set3/helper-functions.bats @@ -1,4 +1,5 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/helper/setup" +load "${REPOSITORY_ROOT}/test/helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_changedetector.bats b/test/tests/serial/mail_changedetector.bats index 3a3be488..2a48bd07 100644 --- a/test/tests/serial/mail_changedetector.bats +++ b/test/tests/serial/mail_changedetector.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Note if tests fail asserting against `supervisorctl tail changedetector` output, # use `supervisorctl tail - changedetector` instead to increase log output. diff --git a/test/tests/serial/mail_disabled_clamav_spamassassin.bats b/test/tests/serial/mail_disabled_clamav_spamassassin.bats index 13d3e73e..83e6a398 100644 --- a/test/tests/serial/mail_disabled_clamav_spamassassin.bats +++ b/test/tests/serial/mail_disabled_clamav_spamassassin.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_dnsbl.bats b/test/tests/serial/mail_dnsbl.bats index 1df1d4e3..d4c3a5d4 100644 --- a/test/tests/serial/mail_dnsbl.bats +++ b/test/tests/serial/mail_dnsbl.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" CONTAINER="mail_dnsbl_enabled" CONTAINER2="mail_dnsbl_disabled" diff --git a/test/tests/serial/mail_fail2ban.bats b/test/tests/serial/mail_fail2ban.bats index 11405d61..a3f927d7 100644 --- a/test/tests/serial/mail_fail2ban.bats +++ b/test/tests/serial/mail_fail2ban.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_fetchmail.bats b/test/tests/serial/mail_fetchmail.bats index 2eac5534..77c468f2 100644 --- a/test/tests/serial/mail_fetchmail.bats +++ b/test/tests/serial/mail_fetchmail.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_fetchmail_parallel.bats b/test/tests/serial/mail_fetchmail_parallel.bats index 68f98c52..b1792de2 100644 --- a/test/tests/serial/mail_fetchmail_parallel.bats +++ b/test/tests/serial/mail_fetchmail_parallel.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_hostname.bats b/test/tests/serial/mail_hostname.bats index 31df350c..f55a69c3 100644 --- a/test/tests/serial/mail_hostname.bats +++ b/test/tests/serial/mail_hostname.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { diff --git a/test/tests/serial/mail_lmtp_ip.bats b/test/tests/serial/mail_lmtp_ip.bats index 91981d12..2ceca916 100644 --- a/test/tests/serial/mail_lmtp_ip.bats +++ b/test/tests/serial/mail_lmtp_ip.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG PRIVATE_ETC diff --git a/test/tests/serial/mail_pop3.bats b/test/tests/serial/mail_pop3.bats index d4873d47..ab10b19d 100644 --- a/test/tests/serial/mail_pop3.bats +++ b/test/tests/serial/mail_pop3.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_postfix_inet.bats b/test/tests/serial/mail_postfix_inet.bats index 24dd463f..22656aa9 100644 --- a/test/tests/serial/mail_postfix_inet.bats +++ b/test/tests/serial/mail_postfix_inet.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Test case # --------- diff --git a/test/tests/serial/mail_postscreen.bats b/test/tests/serial/mail_postscreen.bats index d1e3b6e1..aa2f958a 100644 --- a/test/tests/serial/mail_postscreen.bats +++ b/test/tests/serial/mail_postscreen.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup() { # Getting mail container IP diff --git a/test/tests/serial/mail_privacy.bats b/test/tests/serial/mail_privacy.bats index e8d560f8..f5195916 100644 --- a/test/tests/serial/mail_privacy.bats +++ b/test/tests/serial/mail_privacy.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_quotas_disabled.bats b/test/tests/serial/mail_quotas_disabled.bats index 3afac83b..a012614e 100644 --- a/test/tests/serial/mail_quotas_disabled.bats +++ b/test/tests/serial/mail_quotas_disabled.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Test case # --------- diff --git a/test/tests/serial/mail_smtponly.bats b/test/tests/serial/mail_smtponly.bats index ecdb2625..fe258036 100644 --- a/test/tests/serial/mail_smtponly.bats +++ b/test/tests/serial/mail_smtponly.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { docker run --rm -d --name mail_smtponly \ diff --git a/test/tests/serial/mail_spam_junk_folder.bats b/test/tests/serial/mail_spam_junk_folder.bats index 8dcf454f..e335d06f 100644 --- a/test/tests/serial/mail_spam_junk_folder.bats +++ b/test/tests/serial/mail_spam_junk_folder.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Test case # --------- diff --git a/test/tests/serial/mail_special_use_folders.bats b/test/tests/serial/mail_special_use_folders.bats index e0ef03f8..b4bd2ac2 100644 --- a/test/tests/serial/mail_special_use_folders.bats +++ b/test/tests/serial/mail_special_use_folders.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_ssl_letsencrypt.bats b/test/tests/serial/mail_ssl_letsencrypt.bats index 06053de5..c16b9625 100644 --- a/test/tests/serial/mail_ssl_letsencrypt.bats +++ b/test/tests/serial/mail_ssl_letsencrypt.bats @@ -1,5 +1,5 @@ -load 'test_helper/common' -load 'test_helper/tls' +load "${REPOSITORY_ROOT}/test/test_helper/common" +load "${REPOSITORY_ROOT}/test/test_helper/tls" # Globals referenced from `test_helper/common`: # TEST_NAME TEST_FQDN TEST_TMP_CONFIG diff --git a/test/tests/serial/mail_ssl_manual.bats b/test/tests/serial/mail_ssl_manual.bats index 52f07913..d2c34cc5 100644 --- a/test/tests/serial/mail_ssl_manual.bats +++ b/test/tests/serial/mail_ssl_manual.bats @@ -1,5 +1,5 @@ #!/usr/bin/env bats -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { # Internal copies made by `start-mailserver.sh`: diff --git a/test/tests/serial/mail_time.bats b/test/tests/serial/mail_time.bats index 9e7f22a9..6bf7eb42 100644 --- a/test/tests/serial/mail_time.bats +++ b/test/tests/serial/mail_time.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_tls_dhparams.bats b/test/tests/serial/mail_tls_dhparams.bats index 9edd0e16..274b1dd1 100644 --- a/test/tests/serial/mail_tls_dhparams.bats +++ b/test/tests/serial/mail_tls_dhparams.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Test case # --------- diff --git a/test/tests/serial/mail_undef_spam_subject.bats b/test/tests/serial/mail_undef_spam_subject.bats index b2831e27..301e0ddc 100644 --- a/test/tests/serial/mail_undef_spam_subject.bats +++ b/test/tests/serial/mail_undef_spam_subject.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_with_imap.bats b/test/tests/serial/mail_with_imap.bats index ffb609b7..1b3d54d5 100644 --- a/test/tests/serial/mail_with_imap.bats +++ b/test/tests/serial/mail_with_imap.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_with_ldap.bats b/test/tests/serial/mail_with_ldap.bats index 882beddc..1f206c24 100644 --- a/test/tests/serial/mail_with_ldap.bats +++ b/test/tests/serial/mail_with_ldap.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { pushd test/docker-openldap/ || return 1 diff --git a/test/tests/serial/mail_with_mdbox.bats b/test/tests/serial/mail_with_mdbox.bats index dd751adb..eaec9ef6 100644 --- a/test/tests/serial/mail_with_mdbox.bats +++ b/test/tests/serial/mail_with_mdbox.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_with_postgrey.bats b/test/tests/serial/mail_with_postgrey.bats index 8a5e79d8..9fd4fb12 100644 --- a/test/tests/serial/mail_with_postgrey.bats +++ b/test/tests/serial/mail_with_postgrey.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_with_postgrey_disabled_by_default.bats b/test/tests/serial/mail_with_postgrey_disabled_by_default.bats index 2ebbdc30..82041ccc 100644 --- a/test/tests/serial/mail_with_postgrey_disabled_by_default.bats +++ b/test/tests/serial/mail_with_postgrey_disabled_by_default.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup() { local PRIVATE_CONFIG diff --git a/test/tests/serial/mail_with_relays.bats b/test/tests/serial/mail_with_relays.bats index 0122e23e..ae42d812 100644 --- a/test/tests/serial/mail_with_relays.bats +++ b/test/tests/serial/mail_with_relays.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { # We use a temporary config directory since we'll be dynamically editing diff --git a/test/tests/serial/mail_with_sdbox.bats b/test/tests/serial/mail_with_sdbox.bats index 487fb4de..5fd416c2 100644 --- a/test/tests/serial/mail_with_sdbox.bats +++ b/test/tests/serial/mail_with_sdbox.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG diff --git a/test/tests/serial/no_container.bats b/test/tests/serial/no_container.bats index 723a1146..2b31879e 100644 --- a/test/tests/serial/no_container.bats +++ b/test/tests/serial/no_container.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" function setup_file() { # Fail early if the test image is already running: diff --git a/test/tests/serial/open_dkim.bats b/test/tests/serial/open_dkim.bats index 9d1e68e7..535a2092 100644 --- a/test/tests/serial/open_dkim.bats +++ b/test/tests/serial/open_dkim.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" export IMAGE_NAME CONTAINER_NAME TEST_FILE diff --git a/test/tests/serial/permit_docker.bats b/test/tests/serial/permit_docker.bats index c4cff178..fb18d072 100644 --- a/test/tests/serial/permit_docker.bats +++ b/test/tests/serial/permit_docker.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" NON_DEFAULT_DOCKER_MAIL_NETWORK_NAME=non-default-docker-mail-network setup_file() { diff --git a/test/tests/serial/security_tls_cipherlists.bats b/test/tests/serial/security_tls_cipherlists.bats index a60e1f14..c13cf7bb 100644 --- a/test/tests/serial/security_tls_cipherlists.bats +++ b/test/tests/serial/security_tls_cipherlists.bats @@ -1,5 +1,5 @@ #!/usr/bin/env bats -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Globals ${BATS_TMPDIR} and ${NAME} # `${NAME}` defaults to `mailserver-testing:ci` diff --git a/test/tests/serial/sedfile.bats b/test/tests/serial/sedfile.bats index c19c2fc1..5b8c593f 100644 --- a/test/tests/serial/sedfile.bats +++ b/test/tests/serial/sedfile.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" CONTAINER='sedfile' TEST_FILE='/tmp/sedfile-test.txt' diff --git a/test/tests/serial/setup-cli.bats b/test/tests/serial/setup-cli.bats index 4805b3c9..083a3754 100644 --- a/test/tests/serial/setup-cli.bats +++ b/test/tests/serial/setup-cli.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" # Globals referenced from `test_helper/common`: # TEST_NAME (should match the filename, minus the bats extension) diff --git a/test/tests/serial/test_helper.bats b/test/tests/serial/test_helper.bats index fa6dd12c..a86c05fb 100644 --- a/test/tests/serial/test_helper.bats +++ b/test/tests/serial/test_helper.bats @@ -1,6 +1,4 @@ -load 'test_helper/bats-support/load' -load 'test_helper/bats-assert/load' -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" @test "repeat_until_success_or_timeout returns instantly on success" { SECONDS=0 diff --git a/test/tests/serial/tests.bats b/test/tests/serial/tests.bats index d085c96c..71c70d47 100644 --- a/test/tests/serial/tests.bats +++ b/test/tests/serial/tests.bats @@ -1,4 +1,4 @@ -load 'test_helper/common' +load "${REPOSITORY_ROOT}/test/test_helper/common" setup_file() { local PRIVATE_CONFIG