IO::As...pTests(3pm)

โœจ IO::As...pTests(3pm) โœจ

okay bestie so this is IO::Async::LoopTests โ€” yes the manpage title is all truncated and mysterious like that, it's giving mystery novel, but it's just Perl's User Contributed Perl Documentation section 3pm. come sit with me ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

IO::Async::LoopTests โ€” acceptance testing for IO::Async::Loop subclasses ๐Ÿงชโœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

use IO::Async::LoopTests;
run_tests( 'IO::Async::Loop::Shiney', 'io' );

like. two lines. that's the whole vibe check. ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So this module is literally a whole collection of test functions, and their one job is running acceptance tests on subclasses of IO::Async::Loop. ๐Ÿ“‹

Who's it for? Authors of those subclasses โ€” it's a facility provided so y'all can make sure your code actually conforms to the Loop API that IO::Async requires. no cap. if your subclass is out here doing its own thing and not matching the API, that's a problem, and this module is how you find out. periodt. ๐Ÿ‘‘


โฑ๏ธ TIMING โฑ๏ธ

Some of these tests need timers or timed delays โ€” can't test timer stuff without timers, ikykyk ๐Ÿ’€

Normally those delays are counted in units of seconds. But!!! if you set the environment variable TEST_QUICK_TIMERS to some true value, those same timers run 10 times quicker, measured in units of 0.1 seconds instead. โšก

When is that useful? When you're running the tests interactively and you don't wanna sit there forever waiting on them. valid tbh.

โš ๏ธ But keep the slower timers for automated smoke-testing machines!! They're preferred there specifically to help guard against false negatives that get reported simply because of scheduling delays or high system load while the testing is happening. don't come for me when your CI goes red for no reason bestie ๐Ÿ˜ญ

Here's how:

$ TEST_QUICK_TIMERS=1 ./Build test

๐Ÿ”ฅ FUNCTIONS ๐Ÿ”ฅ

๐Ÿ’ซ run_tests ๐Ÿ’ซ

run_tests( $class, @tests );

Runs a test (or a whole collection of tests, no shade, go big ๐Ÿซถ) against the loop subclass you hand it. And here's the cute part: the class being tested gets loaded by this function, so the containing script does not need to require it or use it first. it just handles it for you. main character energy honestly โœจ

Also important: this function calls plan to output its own expected test count, so the containing script should not do that itself. don't double up. ๐Ÿ™ˆ


๐Ÿ‘‘ TEST SUITES ๐Ÿ‘‘

These are the test suite names that exist, and you pass one as a name in the @tests argument to run_tests:

  • io โ€” tests the Loop's ability to watch filehandles for IO readiness ๐Ÿ‘€
  • timer โ€” tests the Loop's ability to handle timer events โฐ
  • signal โ€” tests the Loop's ability to watch POSIX signals ๐Ÿ“ก
  • idle โ€” tests the Loop's support for idle handlers ๐Ÿ˜ด
  • process โ€” tests the Loop's support for watching child processes by PID ๐Ÿ‘ถ (previously called child โ€” glow-up name change, we love to see it ๐Ÿ’…)
  • control โ€” tests that the run, stop, loop_once and loop_forever methods behave correctly ๐ŸŽฎ
  • metrics โ€” tests that metrics are generated appropriately using Metrics::Any ๐Ÿ“Š

๐ŸŒˆ AUTHOR ๐ŸŒˆ

Paul Evans <leonerd@leonerd.org.uk> ๐Ÿ’œ


aaaand that's the whole page bestie!! ๐ŸŒธ๐Ÿงš

this shipped as part of perl v5.40.1, dated 2026-02-21, from the User Contributed Perl Documentation collection โ€” so go forth, test your Loop subclass, and slay ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from