Jacob Champion 4e1e417330 oauth: Add unit tests for multiplexer handling
To better record the internal behaviors of oauth-curl.c, add a unit test
suite for the socket and timer handling code. This is all based on TAP
and driven by our existing Test::More infrastructure.

This commit is a replay of 1443b6c0e, which was reverted due to
buildfarm failures. Compared with that, this version protects the build
targets in the Makefile with a with_libcurl conditional, and it tweaks
the code style in 001_oauth.pl.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Discussion: https://postgr.es/m/CAOYmi+nDZxJHaWj9_jRSyf8uMToCADAmOfJEggsKW-kY7aUwHA@mail.gmail.com
Discussion: https://postgr.es/m/CAOYmi+m=xY0P_uAzAP_884uF-GhQ3wrineGwc9AEnb6fYxVqVQ@mail.gmail.com
2025-08-25 09:27:45 -07:00

25 lines
962 B
Perl

# Copyright (c) 2025, PostgreSQL Global Development Group
use strict;
use warnings FATAL => 'all';
use PostgreSQL::Test::Utils;
use Test::More;
# Defer entirely to the oauth_tests executable. stdout/err is routed through
# Test::More so that our logging infrastructure can handle it correctly. Using
# IPC::Run::new_chunker seems to help interleave the two streams a little better
# than without.
#
# TODO: prove can also deal with native executables itself, which we could
# probably make use of via PROVE_TESTS on the Makefile side. But the Meson setup
# calls Perl directly, which would require more code to work around... and
# there's still the matter of logging.
my $builder = Test::More->builder;
my $out = $builder->output;
my $err = $builder->failure_output;
IPC::Run::run ['oauth_tests'],
'>' => (IPC::Run::new_chunker, sub { $out->print($_[0]) }),
'2>' => (IPC::Run::new_chunker, sub { $err->print($_[0]) })
or die "oauth_tests returned $?";