> On 1 Dec 2022, at 16:18, Peter Eisentraut <peter.eisentr...@enterprisedb.com> 
> wrote:
> 
> I wanted to test the different pg_upgrade transfer modes (--link, --clone), 
> but that was not that easy, because there is more than one place in the test 
> script you have to find and manually change.  So I wrote a little patch to 
> make that easier.  It's still manual, but it's a start.  (In principle, we 
> could automatically run the tests with each supported mode in a loop, but 
> that would be very slow.)

Wouldn't it be possible, and less change-code-manual, to accept this via an
extension to PROVE_FLAGS?  Any options after :: to prove are passed to the
test(s) [0] so we could perhaps inspect @ARGV for the mode if we invent a new
way to pass arguments.  Something along the lines of the untested sketch
below in the pg_upgrade test:

+# Optionally set the file transfer mode for the tests via arguments to PROVE
+my $mode = (@ARGV);
+$mode = '--copy' unless defined;

.. together with an extension to Makefile.global.in ..

-   $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if 
$(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
+   $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if 
$(PROVE_TESTS),$(PROVE_TESTS),t/*.pl) $(PROVE_TEST_ARGS)

.. should *I think* allow for passing the mode to the tests via:

make -C src/bin/pg_upgrade check PROVE_TEST_ARGS=":: --link"

The '::' part should of course ideally be injected automatically but the above
is mostly thinking out loud pseudocode so I didn't add that.

This could probably benefit other tests as well, to make it eas{y|ier} to run
extended testing on certain buildfarm animals or in the CFBot CI on specific
patches in the commitfest.

> While doing that, I also found it strange that the default transfer mode 
> (referred to as "copy" internally) did not have any external representation, 
> so it is awkward to refer to it in text, and obscure to see where it is used 
> for example in those test scripts.  So I added an option --copy, which 
> effectively does nothing, but it's not uncommon to have options that select 
> default behaviors explicitly.  (I also thought about something like a "mode" 
> option with an argument, but given that we already have --link and --clone, 
> this seemed the most sensible.)

Agreed, +1 on adding --copy regardless of the above.

--
Daniel Gustafsson               https://vmware.com/

[0] https://perldoc.perl.org/prove#Arguments-to-Tests

Reply via email to