From c0843ff841b47d170983db1a98565157432bf272 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Sun, 6 Sep 2026 04:50:22 +0000 Subject: [PATCH 1/5] test/with-pgenvblock: add additional test Extracted from discarded PR https://github.com/getodk/central/pull/2119 --- test/test-with-pgenvblock.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/test/test-with-pgenvblock.sh b/test/test-with-pgenvblock.sh index 5d72aafd5..e2221d08a 100755 --- a/test/test-with-pgenvblock.sh +++ b/test/test-with-pgenvblock.sh @@ -2,9 +2,39 @@ set -o pipefail shopt -s inherit_errexit -printf >&2 "Checking whether with-pgenvblock.pl works… " +log() { echo >&2 "[test-with-pgenvblock] $*"; } + +log "Testing..." + +log "Testing: local env with injected var..." # for the skeptical reader, on the below: # note that the environment setting (with `export`) runs in a subshell, and as such doesn't touch our own environment, # and as such thus also not the environment with-pgenvblock.pl's is launched with; and thus the PGBLA environment variable # that the `env` invocation sees comes from `with-pgenvblock.pl`'s reading of the env block file and nowhere else. files/service/with-pgenvblock.pl <(export PGBLA=hurray; cat /proc/self/environ) env | grep --quiet '^PGBLA=hurray$' || (printf >&2 "No, it doesn't\n"; false) && printf >&2 "Yes\n" +log " Passed OK." + +log "Testing: specific postgres-related variables..." +if diff \ + <( + env --ignore-environment \ + files/service/with-pgenvblock.pl \ + <(printf "A=1\0PGSSLMODE=2\0C=3\0PGDATABASE=4\0E=5\0NODE_EXTRA_CA_CERTS=5\0\G=7") \ + env \ + | tr '\0' '\n' + ) \ + <(cat < expected'" + log "!!!" + exit 1 +fi + +log "All tests passed OK." From 2507042e9021ab2408ea654f534dccc67fc5d45c Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Sun, 6 Sep 2026 06:35:08 +0000 Subject: [PATCH 2/5] switch tests; fix failure handling of old test --- test/test-with-pgenvblock.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/test-with-pgenvblock.sh b/test/test-with-pgenvblock.sh index e2221d08a..e99609000 100755 --- a/test/test-with-pgenvblock.sh +++ b/test/test-with-pgenvblock.sh @@ -6,15 +6,7 @@ log() { echo >&2 "[test-with-pgenvblock] $*"; } log "Testing..." -log "Testing: local env with injected var..." -# for the skeptical reader, on the below: -# note that the environment setting (with `export`) runs in a subshell, and as such doesn't touch our own environment, -# and as such thus also not the environment with-pgenvblock.pl's is launched with; and thus the PGBLA environment variable -# that the `env` invocation sees comes from `with-pgenvblock.pl`'s reading of the env block file and nowhere else. -files/service/with-pgenvblock.pl <(export PGBLA=hurray; cat /proc/self/environ) env | grep --quiet '^PGBLA=hurray$' || (printf >&2 "No, it doesn't\n"; false) && printf >&2 "Yes\n" -log " Passed OK." - -log "Testing: specific postgres-related variables..." +log " Testing: specific postgres-related variables..." if diff \ <( env --ignore-environment \ @@ -29,7 +21,7 @@ PGDATABASE=4 EOF ) then - log " Passed OK." + log " Passed OK." else log "!!!" log "!!! Test failed; see above for differences between '< actual' and '> expected'" @@ -37,4 +29,16 @@ else exit 1 fi +log " Testing: local env with injected var..." +# for the skeptical reader, on the below: +# note that the environment setting (with `export`) runs in a subshell, and as such doesn't touch our own environment, +# and as such thus also not the environment with-pgenvblock.pl's is launched with; and thus the PGBLA environment variable +# that the `env` invocation sees comes from `with-pgenvblock.pl`'s reading of the env block file and nowhere else. +if files/service/with-pgenvblock.pl <(export PGBLA=hurray; cat /proc/self/environ) env | grep --quiet '^PGBLA=huray$'; then + log " Passed OK." +else + log " !!! Test failed." + exit 1 +fi + log "All tests passed OK." From 0d4334d57578aab75139ee87d1ca242ec1412307 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Sun, 6 Sep 2026 06:36:03 +0000 Subject: [PATCH 3/5] refix test --- test/test-with-pgenvblock.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-with-pgenvblock.sh b/test/test-with-pgenvblock.sh index e99609000..9870d55d1 100755 --- a/test/test-with-pgenvblock.sh +++ b/test/test-with-pgenvblock.sh @@ -34,7 +34,7 @@ log " Testing: local env with injected var..." # note that the environment setting (with `export`) runs in a subshell, and as such doesn't touch our own environment, # and as such thus also not the environment with-pgenvblock.pl's is launched with; and thus the PGBLA environment variable # that the `env` invocation sees comes from `with-pgenvblock.pl`'s reading of the env block file and nowhere else. -if files/service/with-pgenvblock.pl <(export PGBLA=hurray; cat /proc/self/environ) env | grep --quiet '^PGBLA=huray$'; then +if files/service/with-pgenvblock.pl <(export PGBLA=hurray; cat /proc/self/environ) env | grep --quiet '^PGBLA=hurray$'; then log " Passed OK." else log " !!! Test failed." From e5c8b1edaf24c198557f31b983d368269863d585 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Sun, 6 Sep 2026 06:37:35 +0000 Subject: [PATCH 4/5] clearer logging/test name --- test/test-with-pgenvblock.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-with-pgenvblock.sh b/test/test-with-pgenvblock.sh index 9870d55d1..37492ee1c 100755 --- a/test/test-with-pgenvblock.sh +++ b/test/test-with-pgenvblock.sh @@ -29,7 +29,7 @@ else exit 1 fi -log " Testing: local env with injected var..." +log " Testing: local env + an injected var..." # for the skeptical reader, on the below: # note that the environment setting (with `export`) runs in a subshell, and as such doesn't touch our own environment, # and as such thus also not the environment with-pgenvblock.pl's is launched with; and thus the PGBLA environment variable From 5f9c4d5997673f01e9b0e93a26ae3ad387fba97d Mon Sep 17 00:00:00 2001 From: Alex Anderson <191496+alxndrsn@users.noreply.github.com> Date: Thu, 17 Sep 2026 11:24:07 +0300 Subject: [PATCH 5/5] less slash --- test/test-with-pgenvblock.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-with-pgenvblock.sh b/test/test-with-pgenvblock.sh index 37492ee1c..4212bdb38 100755 --- a/test/test-with-pgenvblock.sh +++ b/test/test-with-pgenvblock.sh @@ -11,7 +11,7 @@ if diff \ <( env --ignore-environment \ files/service/with-pgenvblock.pl \ - <(printf "A=1\0PGSSLMODE=2\0C=3\0PGDATABASE=4\0E=5\0NODE_EXTRA_CA_CERTS=5\0\G=7") \ + <(printf "A=1\0PGSSLMODE=2\0C=3\0PGDATABASE=4\0E=5\0NODE_EXTRA_CA_CERTS=5\0G=7") \ env \ | tr '\0' '\n' ) \