Skip to content

WIP: Add parallel test execution to jcpan (-j flag)#426

Merged
fglock merged 2 commits into
masterfrom
feature/jcpan-parallel-tests
Apr 3, 2026
Merged

WIP: Add parallel test execution to jcpan (-j flag)#426
fglock merged 2 commits into
masterfrom
feature/jcpan-parallel-tests

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 3, 2026

Summary

Add parallel test execution to jcpan and fix the Module::Build dependency chain for DateTime::Format::ICal.

Parallel test execution (-j N flag)

  • jcpan/jcpan.bat: Parse -j N, export HARNESS_OPTIONS=jN
  • TAP::Parser::Iterator::Process: Enable IO::Select on pipe handles in the non-fork fallback path, allowing the TAP::Parser::Multiplexer to use select()-based I/O multiplexing
jcpan -j 4 -t Module::Name    # 4 parallel test jobs
jcpan -t Module::Name          # sequential (default, unchanged)

Benchmark (Path::Tiny, 30 test files): 36s sequential -> 18.5s with -j 4 (~2x speedup)

Module::Build chained shebang fix

  • CPAN::Distribution: ./Build relies on chained shebangs which don't work when jperl is a bash wrapper script. Fixed _build_command() and the install path to use $^X Build when archname contains java.

Module::Build auto-pureperl

  • Module::Build::Base: Auto-enable pureperl_only when a module declares allow_pureperl and no C compiler is available. Modules like Params::Validate now build their pure-Perl backend instead of failing on XS compilation.

Devel::Peek stub

  • Minimal stub providing SvREFCNT() (returns 1 — JVM uses tracing GC) and Dump(). Needed as test_requires for Params::Validate.

Result

$ ./jcpan -j 4 -t DateTime::Format::ICal
t/00load.t ........ ok
t/01datetime.t .... ok
t/02duration.t .... ok
t/03period.t ...... ok
t/04recurrence.t .. ok
All tests successful.
Files=5, Tests=134
Result: PASS

Files changed

File Change
jcpan Parse -j N, export HARNESS_OPTIONS
jcpan.bat Same for Windows
TAP::Parser::Iterator::Process IO::Select on pipe handles
CPAN::Distribution $^X Build instead of ./Build on PerlOnJava
Module::Build::Base Auto-pureperl when no compiler
Devel::Peek New stub module
dev/modules/datetime_format_ical.md Tracking doc

Test plan

  • make passes (all unit tests)
  • jprove -j 4 works with unit tests
  • jcpan -j 4 -t Path::Tiny same results as sequential
  • jcpan -j 4 -t DateTime::Format::ICal — all 134 tests pass
  • jcpan -f -i Params::Validate installs successfully
  • jcpan -f -i DateTime::Set installs and tests pass
  • Test on Windows

Generated with Devin

fglock and others added 2 commits April 3, 2026 13:50
Add -j N option to jcpan for running CPAN module tests in parallel.
This leverages TAP::Harness built-in parallel execution support via
the HARNESS_OPTIONS environment variable.

Key changes:
- jcpan/jcpan.bat: Parse -j N flag, export HARNESS_OPTIONS=jN
- TAP::Parser::Iterator::Process: Enable IO::Select on pipe handles
  even without IPC::Open3 (which requires fork). This allows the
  TAP::Parser::Multiplexer to use select-based I/O multiplexing
  for parallel test execution on PerlOnJava.

Usage:
  jcpan -j 4 -t Module::Name    # Run tests with 4 parallel jobs
  jcpan -t Module::Name          # Sequential (default, unchanged)

Tested with Path::Tiny (30 test files):
  Sequential: 36s wall clock
  Parallel -j 4: 18.5s wall clock (about 2x speedup)

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fix the dependency chain for DateTime::Format::ICal on PerlOnJava:

- CPAN::Distribution: Fix chained shebang issue where ./Build is
  executed by bash instead of jperl (jperl is a bash wrapper, so
  the kernel cannot chain shebangs). Use $^X Build when archname
  contains java. Also fix install path which bypasses _build_command()
  and uses mbuild_install_build_command from CPAN config.

- Module::Build::Base: Auto-enable pureperl_only when a module declares
  allow_pureperl and no C compiler is available. This lets modules like
  Params::Validate build their pure-Perl backend without trying (and
  failing) to compile XS code.

- Devel::Peek stub: Minimal stub providing SvREFCNT() (returns 1, since
  JVM uses tracing GC) and Dump(). Needed as test_requires dependency
  for Params::Validate.

Result: jcpan -j 4 -t DateTime::Format::ICal passes all 134 tests.

Generated with Devin (https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/jcpan-parallel-tests branch from a22c3cd to 2d047cb Compare April 3, 2026 11:51
@fglock fglock marked this pull request as ready for review April 3, 2026 12:00
@fglock fglock merged commit 9407209 into master Apr 3, 2026
2 checks passed
@fglock fglock deleted the feature/jcpan-parallel-tests branch April 3, 2026 12:01
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.

1 participant