unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] t/feed: fix uninitialized variable warnings
Date: Mon, 16 Sep 2024 09:53:59 +0000	[thread overview]
Message-ID: <20240916095359.96854-1-e@80x24.org> (raw)

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);

                 reply	other threads:[~2024-09-16  9:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240916095359.96854-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).