* [PATCH] t/feed: fix uninitialized variable warnings
@ 2024-09-16 9:53 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-09-16 9:53 UTC (permalink / raw)
To: meta
These warnings only happened under test conditions and never
when running under any PSGI servers. In retrospect, t/feed.t is
likely redundant nowadays and ought to be folded into existing
PSGI tests so we don't have to consider setup problems like
these.
Fixes: bbe582cdfa429 ("view: fix addr2urlmap with Plack::Builder::mount")
---
t/feed.t | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/t/feed.t b/t/feed.t
index cc5ae277..8e80b531 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -1,5 +1,5 @@
#!perl -w
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
@@ -10,17 +10,6 @@ use PublicInbox::Inbox;
my $have_xml_treepp = eval { require XML::TreePP; 1 };
my ($tmpdir, $for_destroy) = tmpdir();
-sub string_feed {
- my $res = PublicInbox::Feed::generate($_[0]);
- my $body = $res->[2];
- my $str = '';
- while (defined(my $chunk = $body->getline)) {
- $str .= $chunk;
- }
- $body->close;
- $str;
-}
-
my $git_dir = "$tmpdir/gittest";
my $ibx = create_inbox 'v1', tmpdir => $git_dir, sub {
my ($im, $ibx) = @_;
@@ -46,13 +35,28 @@ EOF
$ibx->{url} = [ 'http://example.com/test' ];
$ibx->{feedmax} = 3;
+my $ctx = {
+ ibx => $ibx,
+ env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'http' },
+};
+my $string_feed = sub {
+ my $res = PublicInbox::Feed::generate($ctx);
+ my $body = $res->[2];
+ my $str = '';
+ while (defined(my $chunk = $body->getline)) {
+ $str .= $chunk;
+ }
+ $body->close;
+ $str;
+};
+
my $im = $ibx->importer(0);
# spam check
{
# check initial feed
{
- my $feed = string_feed({ ibx => $ibx });
+ my $feed = $string_feed->();
SKIP: {
skip 'XML::TreePP missing', 3 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($feed);
@@ -86,7 +90,7 @@ EOF
# check spam shows up
{
- my $spammy_feed = string_feed({ ibx => $ibx });
+ my $spammy_feed = $string_feed->();
SKIP: {
skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($spammy_feed);
@@ -104,7 +108,7 @@ EOF
# spam no longer shows up
{
- my $feed = string_feed({ ibx => $ibx });
+ my $feed = $string_feed->();
SKIP: {
skip 'XML::TreePP missing', 2 unless $have_xml_treepp;
my $t = XML::TreePP->new->parse($feed);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-16 9:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 9:53 [PATCH] t/feed: fix uninitialized variable warnings Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).