Skip to content

Fix Module::Runtime test failures#350

Merged
fglock merged 8 commits intomasterfrom
fix/module-runtime-tests
Mar 22, 2026
Merged

Fix Module::Runtime test failures#350
fglock merged 8 commits intomasterfrom
fix/module-runtime-tests

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Mar 22, 2026

Summary

Three fixes that reduce Module::Runtime test failures from 23 to 8 subtests:

1. Honor #line directive in use statement caller info

  • parseUseDeclaration now uses getSourceLocationAccurate() to get the #line-adjusted filename and line number for CallerStack.push()
  • Fixes t/import_error.t tests where eval'd use statements with #line directives were reporting wrong locations

2. Prevent %^H hints hash from leaking into require'd modules

  • doFile() now saves, clears, and restores %^H around PerlLanguageProvider.executePerlCode()
  • In Perl >= 5.11 (which we emulate), hints don't leak into required files
  • Fixes tests that check $^H{...} is undef in BEGIN blocks of required modules

3. Fix cached require failure error message

  • Changed Compilation failed in require at <file> to Attempt to reload <file> aborted.
  • Matches Perl's actual error message for cached compilation failures
  • Fixes the "broken module is visibly broken when re-required" tests

Test Results

Before: 23/360 subtests failed (5/11 test files)
After: 8/360 subtests failed (4/11 test files)

The remaining 8 failures are due to caller()[10] (hints hash per stack frame) returning undef - this is a known limitation that would require tracking compile-time hints per stack frame.

Test Plan

  • make passes (all unit tests)
  • ./jcpan -t Module::Runtime shows improvement

Generated with Devin

fglock and others added 8 commits March 22, 2026 08:31
…d message

Three fixes that reduce Module::Runtime test failures from 23 to 8:

1. Honor #line directive in use statement caller info
   - parseUseDeclaration now uses getSourceLocationAccurate() to get the
     #line-adjusted filename and line number for CallerStack.push()
   - Fixes t/import_error.t tests where eval'd use statements with #line
     directives were reporting wrong locations

2. Prevent %^H hints hash from leaking into require'd modules
   - doFile() now saves, clears, and restores %^H around PerlLanguageProvider.executePerlCode()
   - In Perl >= 5.11 (which we emulate), hints don't leak into required files
   - Fixes tests that check $^H{...} is undef in BEGIN blocks of required modules

3. Fix cached require failure error message
   - Changed 'Compilation failed in require at <file>' to 'Attempt to reload <file> aborted.'
   - Matches Perl's actual error message for cached compilation failures
   - Fixes the 'broken module is visibly broken when re-required' tests

Remaining 8 failures are due to caller()[10] (hints hash per stack frame)
returning undef - this is a known limitation requiring more complex tracking.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Base.java: Add isa check before adding to @isa, matching Perl
  base.pm behavior (skip redundant base classes when Middle->isa(Parent))
- PerlCompilerException.java, FileTestOperator.java: Add missing period
  before " at file line N" in error messages

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…e error messages

- NameNormalizer: Add normalizePackageName() to convert Foo'Bar to Foo::Bar
- InheritanceResolver, DFS: Normalize package names when reading @isa
- Universal.isa: Normalize argument for consistent comparison
- ModuleOperators: Include module name hint and @inc entries in
  "Can't locate" error message, matching Perl 5.17.5+ behavior

All 8 parent.pm tests now pass.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- RegexFlags: Enable UNICODE_CHARACTER_CLASS so \w, \d, \s match
  Unicode characters by default (matches Perl behavior)
- FileSpec.abs2rel: Fix to use user.dir property for relative base paths
  (Java Path.toAbsolutePath() ignores System.setProperty changes)
- FileSpec.rel2abs: Same fix for relative base paths

Module::Metadata tests: 137/138 pass (1 taint test expected to fail)

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
In Perl, $Foo::x and $main::Foo::x refer to the same variable, but
PerlOnJava stores top-level package symbols without the 'main::'
prefix. This caused %main:: (the main stash) to not include entries
like 'Foo::' for top-level packages.

The fix extends HashSpecialVariable.entrySet() to also include keys
that start with a top-level package name (e.g., "Foo::test") when
enumerating %main::. This allows Class::Inspector::_subnames to
correctly find all child packages.

Test results:
- Class::Inspector: 55/56 tests pass (1 failure is unrelated INC hook issue)
- All unit tests pass

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
When substr() is called with a negative offset that goes before the
beginning of the string, Perl's behavior is:

1. If the adjusted length would still be positive, clip offset to 0
   and reduce length by the overshoot amount (no warning)
   Example: substr("a", -2, 2) returns "a"

2. If the adjusted length would be non-positive, warn and return undef
   Example: substr("hello", -10, 1) warns and returns undef

This also fixes the 4-argument substr replacement behavior to correctly
replace only the extracted portion when clipping occurs.
Example: substr("ab", -3, 2, "X") returns "a" and sets str to "Xb"

Test results:
- All unit tests pass
- Class::Inspector tests pass (no more substr outside of string warnings)

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Instead of unconditionally enabling UNICODE_CHARACTER_CLASS (which broke
308 tests in re/charset.t), now properly track the /u modifier and only
enable Unicode character class matching when /u is specified.

This fixes the regressions in:
- re/charset.t: 5282/5552 (matches master)
- uni/variables.t: 66880/66880 (matches master)
- re/regex_sets.t: restored to master level
- re/pat.t: restored to master level

The /u flag can be used to enable Unicode matching:
  /\w+/u  # matches Unicode word characters

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Perl's error message for a cached compilation failure includes both:
- 'Attempt to reload <file> aborted.'
- 'Compilation failed in require at <file>'

The previous fix only included the first part, which broke
comp/require.t test 32. Now includes both parts to match Perl.

Fixes: comp/require.t 1743/1747 (matches master)

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit d546ec4 into master Mar 22, 2026
2 checks passed
@fglock fglock deleted the fix/module-runtime-tests branch March 22, 2026 17:34
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