Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 555 forks source link

Proposal for Test Updating Project: dist/IO/t/*.t #22617

Open jkeenan opened 1 month ago

jkeenan commented 1 month ago

I'd like to propose a small project aimed at updating tests in the Perl core distribution. This proposal has two intended audiences:

The focus of the project will be the 8 test files found in dist/IO/t which do not use either Test::More or the core distribution's own t/test.pl to generate TAP output. These test files, which date from the earliest days of Perl 5 (or possibly earlier), each generate output by using manually coded print ok or print not ok statements.

$ ack -L '^use Test::More' ../dist/IO/t/*.t | xargs ack -L 'test\.pl' | xargs ls |sort
../dist/IO/t/io_const.t
../dist/IO/t/io_dup.t
../dist/IO/t/io_pipe.t
../dist/IO/t/io_poll.t
../dist/IO/t/io_sel.t
../dist/IO/t/io_sock.t
../dist/IO/t/io_tell.t
../dist/IO/t/io_unix.t

Since it is cumbersome to include test descriptions (alternatively called 'names' or 'labels') in that approach, 7 of these 8 files have no descriptions whatsoever and the eighth has only a handful. So when a particular unit test fails, all we get is a number.

This is particularly annoying when one of these tests fails during smoke-testing (as io_poll.t did for me within the past week).

A separate pull request should be prepared for each file (in part to encourage multiple participants in this project). The first commit in each p.r. should simply convert a given file to use Test::More without adding any new descriptions. The second commit should add the descriptions. In the course of preparing test descriptions participants will necessarily have to learn a lot about I/O operations whose fundamentals date back to the early days of Unix. (I myself have rarely written Perl code directly using these operations, much less testing them.)

Core Committers: Is there any reason we should not convert these files to Test::More? @toddr @atoomic @ilmari @tonycoz

Once we've handled any objections we'll make a more formal call for volunteers.

toddr commented 1 month ago

Sounds good to me

tonycoz commented 1 month ago

Some of the tests use fork(), eg. io_sock.t, io_unix.t, and may not be convertible to Test::More.

toddr commented 1 month ago

Test2 has fork support. I'm unclear how much of it is in core now?

oodler577 commented 1 month ago

@jkeenan I'm interested in helping if y'all move ahead with it

Grinnz commented 1 month ago

The whole Test2 core suite is core now, however note that updates to the IO dist could complicate its dual-life CPAN release (which works on many versions where the Test2 suite is not yet core). Though I don't see any reason not to add that dependency if it's useful. (And Test2::IPC, which seems to be the necessary component here, has been core for a decent while, but I don't know if it works with Test::More.)

exodist commented 1 month ago

Test2::IPC does work for Test::More.

I suggest using Test2::V0 over Test::More for debugging, and for performance. However if the deps are a problem Test2::IPC + Test::More will work and are supported on perl versions that include Test2::IPC but not Test2::V0.