Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Data::Dumper pure-perl tests #22896

Merged
merged 5 commits into from
Jan 9, 2025
Merged

Conversation

mauke
Copy link
Contributor

@mauke mauke commented Jan 8, 2025

Most of the tests in Data-Dumper were written under the assumption that the XS parts of the module may be unavailable. However, this part of the test suite hasn't seen much use in the last 15 or so years, so some of it has started failing. Some of this is due to outdated skip counts or assumptions that certain options force the use of the pure-perl implementation; these fail because tests were added/removed and the XS implementation has grown support for Useqq and Deparse. In other cases, the test assumes that XS is always available.

This PR updates the tests so they all pass even if XS is not available. (If instead we decide to make XS mandatory, we should remove all the "XS available?" checks from the tests to avoid further bit-rot of dead code.)


  • This set of changes does not require a perldelta entry.

mauke added 5 commits January 8, 2025 10:42
This is a follow-up to 67201d9, which
reduced the number of tests without adjusting the skip count.

Previously, testing without XS available resulted in:

    t/sortkeys.t .................. Dubious, test returned 255 (wstat 65280, 0xff00)
    All 22 subtests passed
            (less 13 skipped subtests: 9 okay)
    ...
    /sortkeys.t                (Wstat: 65280 (exited 255) Tests: 24 Failed: 2)
      Failed tests:  23-24
      Non-zero exit status: 255
      Parse errors: Bad plan.  You planned 22 tests but ran 24.
This is a follow-up to 5b50ddc, which
added 4 tests without adjusting the skip count.

Previously, testing without XS available resulted in:

    t/quotekeys.t ................. Dubious, test returned 255 (wstat 65280, 0xff00)
    Failed 4/18 subtests
            (less 5 skipped subtests: 9 okay)
    ...
    t/quotekeys.t               (Wstat: 65280 (exited 255) Tests: 14 Failed: 0)
      Non-zero exit status: 255
      Parse errors: Bad plan.  You planned 18 tests but ran 14.
This is a follow-up to commit b5048e7,
which added 'Deparse' support to XS, and commit
9baac1a, which added 'Useqq' support to
XS. There are no longer any configuration settings that implicitly force
the use of the pure Perl implementation (outside of 'Useperl' itself).

Previously, testing without XS available resulted in:

    t/dumpperl.t .................. 1/31 Undefined subroutine &Data::Dumper::Dumpxs called at .../dist/Data-Dumper/blib/lib/Data/Dumper.pm line 213.
    # Looks like your test exited with 255 just after 10.
    t/dumpperl.t .................. Dubious, test returned 255 (wstat 65280, 0xff00)
    Failed 21/31 subtests
    ...
    t/dumpperl.t                (Wstat: 65280 (exited 255) Tests: 10 Failed: 0)
      Non-zero exit status: 255
      Parse errors: Bad plan.  You planned 31 tests but ran 10.
This is a follow-up to b5048e7, which
added 'Deparse' support to XS and made both XS and pure Perl testing
mandatory. The other test files treat XS as optional, so this patch
follows that pattern. (If we decide that the XS part of Data::Dumper is
not optional, we should change all the other test files for
consistency.)

Previously, testing without XS available resulted in:

    t/deparse.t ................... Undefined subroutine &Data::Dumper::Dumpxs called at .../dist/Data-Dumper/blib/lib/Data/Dumper.pm line 213.
    # Looks like your test exited with 255 before it could output anything.
    t/deparse.t ................... Dubious, test returned 255 (wstat 65280, 0xff00)
    Failed 16/16 subtests
    ...
    t/deparse.t                 (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
      Non-zero exit status: 255
      Parse errors: Bad plan.  You planned 16 tests but ran 0.
This is a follow-up to 7d3a730, which
fixed an out-of-bounds write in Dumpxs when passed invalid UTF-8. This
test does not apply to the pure Perl implementation (which detects the
invalid input and cleanly throws an error instead).

Previously, testing without XS available would result in:

    t/bugs.t ...................... 1/24 Malformed UTF-8 character (fatal) at .../dist/Data-Dumper/blib/lib/Data/Dumper.pm line 587.
    # Looks like your test exited with 2 just after 6.
    t/bugs.t ...................... Dubious, test returned 2 (wstat 512, 0x200)
    Failed 18/24 subtests
    ...
    t/bugs.t                    (Wstat: 512 (exited 2) Tests: 6 Failed: 0)
      Non-zero exit status: 2
      Parse errors: Bad plan.  You planned 24 tests but ran 6.
@jkeenan
Copy link
Contributor

jkeenan commented Jan 8, 2025

This PR updates the tests so they all pass even if XS is not available. (If instead we decide to make XS mandatory, we should remove all the "XS available?" checks from the tests to avoid further bit-rot of dead code.)

Is there any way I can build a perl where, for the purpose of testing Data::Dumper, I can simulate an environment where XS is not available?

@mauke
Copy link
Contributor Author

mauke commented Jan 8, 2025

Is there any way I can build a perl where, for the purpose of testing Data::Dumper, I can simulate an environment where XS is not available?

This is a bit of a hack, but:

  1. Build (blead) perl as usual.
  2. cd dist/Data-Dumper
  3. PERL5LIB="$PWD/../../lib" ../../perl Makefile.PL
  4. PERL5LIB="$PWD/../../lib" make
  5. true > blib/arch/auto/Data/Dumper/Dumper.so
    (i.e. overwrite, but don't delete, the .so file with something useless)
  6. PERL5LIB="$PWD/../../lib" make test

Finally, when you're done, do PERL5LIB="$PWD/../../lib" make realclean to get the dist/Data-Dumper directory back into a state that the rest of the build system expects.

Copy link
Contributor

@tonycoz tonycoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't see an easy way to request a pure-perl build.

If we had that it would make sense to add that to Porting/test-dist-module.pl

@mauke mauke merged commit 3caa23e into Perl:blead Jan 9, 2025
33 of 34 checks passed
@mauke mauke deleted the fix-data-dumper-pp-tests branch January 9, 2025 06:55
@jkeenan
Copy link
Contributor

jkeenan commented Jan 9, 2025

Is there any way I can build a perl where, for the purpose of testing Data::Dumper, I can simulate an environment where XS is not available?

This is a bit of a hack, but:

1. Build (blead) perl as usual.

2. `cd dist/Data-Dumper`

3. `PERL5LIB="$PWD/../../lib" ../../perl Makefile.PL`

4. `PERL5LIB="$PWD/../../lib" make`

5. `true > blib/arch/auto/Data/Dumper/Dumper.so`
   (i.e. overwrite, but don't delete, the `.so` file with something useless)

6. `PERL5LIB="$PWD/../../lib" make test`

Finally, when you're done, do PERL5LIB="$PWD/../../lib" make realclean to get the dist/Data-Dumper directory back into a state that the rest of the build system expects.

That is indeed a hack, because after running command #6 above, you don't have a Data::Dumper that the rest of the test suite (make test_harness) expects. But by running this, first at 61bacb9 (last commit modifying dist/Data-Dumper before these changes) and at 3a16cb5 (blead after dist/Data-Dumper modified), I confirmed that this DWIMs. Thanks.

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.

3 participants