Skip to content

fix: App::perlbrew support improvements — 68/73 tests pass#456

Merged
fglock merged 6 commits into
masterfrom
feature/interpreter-fixes-phase6
Apr 7, 2026
Merged

fix: App::perlbrew support improvements — 68/73 tests pass#456
fglock merged 6 commits into
masterfrom
feature/interpreter-fixes-phase6

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 7, 2026

Summary

Improvements to App::perlbrew CPAN test support, going from 57/73 to 68/73 passing tests.

Phase 7.1: TieHandle + selectedHandle fixes (57→65)

  • Fix TieHandle ClassCastException in RuntimeScalar.tiedStore/tiedFetch
  • Update selectedHandle when tying/untying the currently-selected STDOUT handle

Phase 7.2: Three more fixes (65→68)

  • FileSpec.path(): Read from Perl %ENV instead of System.getenv so $ENV{PATH} modifications are respected
  • Diamond operator: <$var/*.t> now interpolates variables using double-quote semantics
  • B.pm: svref_2object detects GLOB refs (returns B::GV), added B::GV::SV and B::SPECIAL
  • Stat/FileTestOperator: Unwrap DupIOHandle/BorrowedIOHandle (not just LayeredIOHandle)
  • RuntimeGlob: Save/restore selectedHandle during local(*STDOUT)

Remaining 5 failures

All share the Capture::Tiny + Test2::Plugin::IOEvents tied STDOUT interaction issue. Detailed root cause analysis documented in dev/modules/app_perlbrew.md.

Files Changed

  • ArgumentParser.java — Read PATH from Perl %ENV for -S flag
  • CompileOperator.java / EmitOperator.java — Diamond operator readline vs glob detection
  • StringParser.java — Variable interpolation in <> glob patterns
  • FileSpec.javapath() reads from Perl %ENV
  • Stat.java / FileTestOperator.java — Unwrap DupIOHandle/BorrowedIOHandle
  • RuntimeGlob.java — selectedHandle save/restore in dynamicSaveState/RestoreState
  • RuntimeScalar.java — TieHandle instanceof guards
  • B.pm — GLOB ref detection, B::GV::SV, B::SPECIAL class

Test plan

  • make passes (all unit tests green)
  • ./jcpan -t App::perlbrew — 68/73 pass (3 more tests fixed, no regressions)

Generated with Devin

@fglock fglock changed the title fix: TieHandle cast error in tiedStore/tiedFetch; update perlbrew plan fix: App::perlbrew support improvements — 68/73 tests pass Apr 7, 2026
fglock and others added 5 commits April 7, 2026 20:44
- Add instanceof TieHandle checks in RuntimeScalar.tiedStore() and
  tiedFetch() to avoid ClassCastException when Capture::Tiny ties
  filehandles (TieHandle extends RuntimeIO, not TiedVariableBase)
- Update app_perlbrew.md: Phase 6 complete (57/73 tests pass, up from
  18/73), categorize 16 remaining failures, add Phase 7 plan for
  tied STDOUT selectedHandle fix

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
When Test2::Plugin::IOEvents ties STDOUT, print without explicit
filehandle was bypassing the tie because RuntimeIO.selectedHandle
still pointed to the original untied handle.

Fix: TieOperators.tie() and untie() now check if the glob being
tied/untied is the currently-selected handle and update selectedHandle
accordingly. This ensures print goes through the TieHandle PRINT method.

stat(STDOUT) fix was NOT needed: analysis showed that _check_for_change()
comparing undef-to-undef is safe, and the TAP formatter dups STDOUT
before IOEvents ties it.

Result: App::perlbrew tests 57/73 -> 65/73 pass.

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

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

Document all 8 remaining test failures with symptoms, root causes,
code locations, and proposed fixes. Prioritized by complexity:
1. FileSpec.path() reads Java env instead of Perl %ENV
2. glob patterns don't interpolate variables
3. B::svref_2object missing GLOB ref detection
4. Capture::Tiny + tied STDOUT selectedHandle interaction (5 tests)

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Priority 1: FileSpec.path() now reads from Perl %ENV instead of
System.getenv, so $ENV{PATH} modifications are respected. Also
fix ArgumentParser.java for -S flag.

Priority 2: Diamond operator <$var/*.t> now interpolates variables
using double-quote semantics (StringParser, EmitOperator, CompileOperator).
Both JVM and bytecode backends updated to correctly distinguish
readline vs glob when operand is not a simple StringNode.

Priority 3: B::svref_2object now detects GLOB refs and returns B::GV.
Added B::GV::SV method and B::SPECIAL class for Test2::Util::Stash.

Priority 4A: Stat.java and FileTestOperator.java now unwrap
DupIOHandle and BorrowedIOHandle (not just LayeredIOHandle) to
reach the underlying CustomFileChannel for stat/file-test ops.

Priority 4B: RuntimeGlob.dynamicSaveState/Restore now saves and
restores selectedHandle, and initializes new glob with stub IO
when the old glob was the selected handle. This ensures print
follows localized STDOUT during local(*STDOUT).

Tests fixed: http-ua-detect-non-curl.t, unit-files-are-the-same.t,
util-looks-like.t

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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/interpreter-fixes-phase6 branch 2 times, most recently from 84692aa to 98a17e4 Compare April 7, 2026 19:08
…ments

PerlOnJava parsed `tied *STDOUT && expr` as `tied(*STDOUT && expr)` instead
of `(tied *STDOUT) && expr`. This caused Capture::Tiny to skip its
`local(*STDOUT)` call when STDOUT was tied by Test2::Plugin::IOEvents,
corrupting the selectedHandle and breaking print output capture.

The fix adds parseBackslashArgWithComma() which parses backslash prototype
arguments at named-unary precedence (level 15, same as isa) instead of comma
precedence (level 5). This matches Perl 5 behavior where comparison/logical
operators are NOT consumed but arithmetic operators ARE consumed.

App::perlbrew: 65/73 -> 66/73 tests pass.

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/interpreter-fixes-phase6 branch from 98a17e4 to 11a068d Compare April 7, 2026 19:50
@fglock fglock merged commit 512a239 into master Apr 7, 2026
2 checks passed
@fglock fglock deleted the feature/interpreter-fixes-phase6 branch April 7, 2026 20:28
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