Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

Problem

The form.t test file fails with HTTP::Message version 7.01 and later due to a change in how HTTP requests are stringified. In HTTP::Message 7.01+, the as_string() method no longer includes a trailing newline, causing test failures when comparing expected vs actual output.

This is the same issue reported in libwww-perl/libwww-perl#491.

Solution

Added a helper function is_maybe_nl() that handles both versions of HTTP::Message by detecting when the actual output is missing a trailing newline that exists in the expected output, and normalizing them before comparison:

sub is_maybe_nl {
    my ($got, $expected, $message) = @_;
    
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    
    if ($got !~ m{\n$} && $expected =~ m{\n$}) {
        chomp($expected);
    }
    
    is($got, $expected, $message);
}

Updated 5 test assertions that check POST requests with message bodies to use is_maybe_nl() instead of is(). These tests now pass with both older (< 7.01) and newer (≥ 7.01) versions of HTTP::Message.

Changes

  • Added is_maybe_nl() helper function for version-agnostic string comparison
  • Replaced is() with is_maybe_nl() for POST request assertions (lines 100, 480, 489, 619, 634)
  • Added trailing newline to done_testing; for consistency
  • Updated .gitignore to exclude MYMETA build artifacts

Fixes compatibility with HTTP::Message 7.01+ while maintaining backward compatibility with earlier versions.

Original prompt

This section details on the original issue you should resolve

<issue_title>form.t fails with HTTP::Message 7.01</issue_title>
<issue_description>same problem as libwww-perl/libwww-perl#491

HTML-Form-6.12.patch fixes the tests</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #56


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix form.t failure with HTTP::Message 7.01 Fix form.t compatibility with HTTP::Message 7.01+ Oct 22, 2025
Copilot AI requested a review from oalders October 22, 2025 15:15
Copilot finished work on behalf of oalders October 22, 2025 15:15
@haarg
Copy link
Member

haarg commented Oct 22, 2025

Newlines should not be optional. The HTTP::Message prereq should be bumped.

@oalders
Copy link
Member

oalders commented Oct 22, 2025

Newlines should not be optional. The HTTP::Message prereq should be bumped.

I see that was in the original patch. I'll rework it to do just the bump. That was a helpful start, but I'll update it.

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.68%. Comparing base (90132a6) to head (b086572).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #57   +/-   ##
=======================================
  Coverage   85.68%   85.68%           
=======================================
  Files           9        9           
  Lines         545      545           
  Branches      165      165           
=======================================
  Hits          467      467           
  Misses         38       38           
  Partials       40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oalders oalders marked this pull request as ready for review October 22, 2025 17:24
Copilot AI and others added 2 commits October 22, 2025 18:26
Co-authored-by: oalders <96205+oalders@users.noreply.github.com>
Co-authored-by: oalders <96205+oalders@users.noreply.github.com>

Bump HTTP::Request version from 6 to 7.01

and update tests to reflect the new requirement

Update Changes
@oalders oalders force-pushed the copilot/fix-form-t-http-message-error branch from d068252 to b086572 Compare October 22, 2025 17:27
@oalders oalders merged commit 2f738e9 into master Oct 22, 2025
41 checks passed
@oalders oalders deleted the copilot/fix-form-t-http-message-error branch October 22, 2025 17:45
@haarg
Copy link
Member

haarg commented Oct 22, 2025

This still seems wrong to me. Using chomp means the newline is acceptable if it exists or not. I think it should be testing the exact output.

@oalders
Copy link
Member

oalders commented Oct 22, 2025

We chomp the expected output to strip the trailing newline out of the HEREDOC and then test what we actually got using is() -- so this should be a straight check for equality on the exact output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

form.t fails with HTTP::Message 7.01

3 participants