Skip to content

test/with-pgenvblock: add additional test - #2204

Merged
alxndrsn merged 7 commits into
getodk:nextfrom
alxndrsn:pgenvblocktests
Sep 17, 2026
Merged

alxndrsn merged 7 commits into
getodk:nextfrom
alxndrsn:pgenvblocktests

Conversation

@alxndrsn

@alxndrsn alxndrsn commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Example outputs

Old version

Passing

$ ./test/test-with-pgenvblock.sh 
Checking whether with-pgenvblock.pl works… Yes

Failing

$ ./test/test-with-pgenvblock.sh 
Checking whether with-pgenvblock.pl works… No, it doesn't

New version

Passing

$ ./test/test-with-pgenvblock.sh 
[test-with-pgenvblock] Testing...
[test-with-pgenvblock]   Testing: specific postgres-related variables...
[test-with-pgenvblock]     Passed OK.
[test-with-pgenvblock]   Testing: local env with injected var...
[test-with-pgenvblock]     Passed OK.
[test-with-pgenvblock] All tests passed OK.

Failing first test

$ ./test/test-with-pgenvblock.sh 
[test-with-pgenvblock] Testing...
[test-with-pgenvblock]   Testing: specific postgres-related variables...
2c2
< PGDATBASE=4
---
> PGDATABASE=4
[test-with-pgenvblock] !!!
[test-with-pgenvblock] !!! Test failed; see above for differences between '< actual' and '> expected'
[test-with-pgenvblock] !!!

Failing second test

$ ./test/test-with-pgenvblock.sh 
[test-with-pgenvblock] Testing...
[test-with-pgenvblock]   Testing: specific postgres-related variables...
[test-with-pgenvblock]     Passed OK.
[test-with-pgenvblock]   Testing: local env with injected var...
[test-with-pgenvblock]     !!! Test failed.

Extracted from discarded PR #2119

Should help with #1793

What has been done to verify that this works as intended?

It's a new test - the test was run.

Also it allowed identification of #2203.

Why is this the best possible solution? Were any other approaches considered?

The logging adds clarity around execution of the existing test, and adds an additional test which makes specific test cases easier to add.

How does this change impact users? Describe intentional behavior changes from code updates. What are the regression risks?

No change - just tests.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

@alxndrsn
alxndrsn marked this pull request as ready for review September 6, 2026 05:08
@matthew-white

Copy link
Copy Markdown
Member

I went ahead and tagged @lognaturel, since IIRC she reviewed the original version of this code.

@alxndrsn
alxndrsn marked this pull request as draft September 6, 2026 05:59
@alxndrsn
alxndrsn removed the request for review from lognaturel September 6, 2026 05:59
@alxndrsn

alxndrsn commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

It looks like the old test relied on being the last-executed line, so no longer fails the script if the test fails.

# 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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure had to change because it wasn't triggering set -e handling due to its structure:

The shell does not exit if the command that fails is part of ... any command executed in a && or || list except the command following the final && or ||
-https://doc.guix.gnu.org/bash/latest/en/html_node/The-Set-Builtin.html

@alxndrsn
alxndrsn marked this pull request as ready for review September 6, 2026 06:48
@alxndrsn
alxndrsn requested a review from lognaturel September 6, 2026 06:48
Comment thread test/test-with-pgenvblock.sh Outdated
Comment thread test/test-with-pgenvblock.sh Outdated
@alxndrsn
alxndrsn merged commit 5930a08 into getodk:next Sep 17, 2026
7 checks passed
@alxndrsn
alxndrsn deleted the pgenvblocktests branch September 17, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants