From 8a19c1a3736c6b928ebc3503edaf0bd289366bcc Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 22 Apr 2017 16:58:15 -0400 Subject: Make PostgresNode::append_conf append a newline automatically. Although the documentation for append_conf said clearly that it didn't add a newline, many test authors seem to have forgotten that ... or maybe they just consulted the example at the top of the POD documentation, which clearly shows adding a config entry without bothering to add a trailing newline. The worst part of that is that it works, as long as you don't do it more than once, since the backend isn't picky about whether config files end with newlines. So there's not a strong forcing function reminding test authors not to do it like that. Upshot is that this is a terribly fragile way to go about things, and there's at least one existing test case that is demonstrably broken and not testing what it thinks it is. Let's just make append_conf append a newline, instead; that is clearly way safer than the old definition. I also cleaned up a few call sites that were unnecessarily ugly. (I left things alone in places where it's plausible that additional config lines would need to be added someday.) Back-patch the change in append_conf itself to 9.6 where it was added, as having a definitional inconsistency between branches would obviously be pretty hazardous for back-patching TAP tests. The other changes are just cosmetic and don't need to be back-patched. Discussion: https://postgr.es/m/19751.1492892376@sss.pgh.pa.us --- src/test/modules/commit_ts/t/004_restart.pl | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/test/modules/commit_ts') diff --git a/src/test/modules/commit_ts/t/004_restart.pl b/src/test/modules/commit_ts/t/004_restart.pl index a0a24971d20..b686925a7e0 100644 --- a/src/test/modules/commit_ts/t/004_restart.pl +++ b/src/test/modules/commit_ts/t/004_restart.pl @@ -7,10 +7,7 @@ use Test::More tests => 16; my $node_master = get_new_node('master'); $node_master->init(allows_streaming => 1); -$node_master->append_conf( - 'postgresql.conf', qq( -track_commit_timestamp = on -)); +$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = on'); $node_master->start; my ($ret, $stdout, $stderr); @@ -75,10 +72,7 @@ is($after_restart_ts, $before_restart_ts, # Now disable commit timestamps -$node_master->append_conf( - 'postgresql.conf', qq( -track_commit_timestamp = off -)); +$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = off'); $node_master->stop('fast'); $node_master->start; @@ -110,10 +104,7 @@ like( 'expected error from disabled tx when committs disabled'); # Re-enable, restart and ensure we can still get the old timestamps -$node_master->append_conf( - 'postgresql.conf', qq( -track_commit_timestamp = on -)); +$node_master->append_conf('postgresql.conf', 'track_commit_timestamp = on'); $node_master->stop('fast'); $node_master->start; -- cgit v1.2.3