| From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | New test function replace_conf() to get rid of unlink/append pattern |
| Date: | 2026-10-12 09:18:13 |
| Message-ID: | A766CB15-4F27-4593-9983-C366D5279397@yesql.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
We have a fairly common pattern in the TAP tests where we first unlink() a
config file and then do append_conf() on it in order to rewrite it from
scratch. There's nothing wrong with it but it's IMO not as readable as it can
be (especially when unlink and append_conf are vertically separated), and
slightly errorprone as the unlink requires one to assemble the path whereas
append_conf does that automatically (yes, I have done that exact mistake during
hacking).
To make the TAP tests more readable I propose a utility function which combines
these two operations, replace_conf(). It works just like how unlink() together
with append_conf() does but in fewer and more readable lines of code. I chose
replace rather than rewrite since it IMO more clearly signals that nothing in
the file is kept.
--
Daniel Gustafsson
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Add-replace_conf-test-utility-function.patch | application/octet-stream | 27.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-10-12 09:19:26 | Re: Fix detection of truncated zstd-compressed backups |
| Previous Message | Dean Rasheed | 2026-10-12 09:17:42 | Re: [PG19] Wrong results from NOT NULL-based expression simplification |