fix: enable jcpan -t Text::vCard and Directory::Scratch#585
Merged
Conversation
Investigation of `jcpan -t Text::vCard` (16/18 test programs failing) and
the related Directory::Scratch test failures uncovered eight independent
PerlOnJava bugs. Fixing them gets both modules to a clean test pass
(Text::vCard 155/155, Directory::Scratch 691/691) and fixes a number of
general-purpose IO/parser issues along the way.
Bundled-module fixes (Text::vCard prereqs)
- MIME::QuotedPrint declares `$VERSION` and re-exports `encode`/`decode`
aliases, so `use MIME::QuotedPrint 3.07` and direct calls to
`MIME::QuotedPrint::encode/decode` work.
- File::Spec now sets `@ISA = ("File::Spec::$platform")` per `$^O`
instead of just `(Exporter)`. Modules like Directory::Scratch and
Path::Class derive the platform from `$File::Spec::ISA[0]`; without
this they passed an empty string to `_spec_class()` and died with
"Invalid system type ''".
- New `Unicode::LineBreak` shim providing the minimal `Unicode::GCString`
API (new/length/substr/as_string/columns) that Text::vCard's Node.pm
uses. Implemented in pure Perl using `\X` for grapheme splitting.
Interpreter & operator fixes
- `bless` now emits the standard "Use of uninitialized value $class in
bless" and "Explicit blessing to '' (assuming package main)" warnings
when given an undef class, matching upstream Perl. Tests like
`like $@, qr/Use of uninitialized value/` previously got an empty $@.
- `chmod $mode, @paths` no longer silently no-ops. `Operator.chmod`
was iterating `runtimeList.elements` directly, so an unflattened
RuntimeArray slot stringified as `ARRAY(0x...)`. Now flattens via
`addToList(...)` like `UnlinkOperator` does.
- `chomp` / `chop` are now parsed as named-unary operators when used
without parentheses, so `is(chomp @A, 3, "ok")` parses as
`is(chomp(@A), 3, "ok")` instead of letting chomp gobble all of
is()'s arguments. Matches Perl behaviour and the deparse output.
- Slurp-mode `<$fh>` (`local $/;`) on an empty file now returns the
empty string on the first call and undef on the second call.
Previously it returned undef immediately, which broke
`Path::Tiny->slurp` on empty files (and Directory::Scratch built on
top of that).
- `flock` no longer leaks JVM-wide shared locks across abandoned
Perl handles. Path::Tiny's slurp-then-append-with-truncate idiom
used to fail with "Resource deadlock avoided" because the SHARED
registry entry from the slurp's lexical $fh outlived the Perl scope.
Added a `Cleaner`-based safety net plus a reactive
`reclaimAbandonedSharedLock` retry path on EX-lock acquisition.
Verification
- `make` (PerlOnJava unit tests): all green.
- `./jcpan -t Text::vCard`: 18/18 test programs, 155/155 subtests.
- `./jcpan -t Directory::Scratch` (run from blib via Test::Harness):
35/35 test programs, 691/691 subtests.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
4529d00 to
8616f15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Investigation of
jcpan -t Text::vCard(originally 16/18 test programs failing, 9/11 subtests failed) and the related Directory::Scratch test failures uncovered eight independent PerlOnJava bugs. This PR fixes all of them, taking both modules to a clean test pass and fixing several general-purpose IO/parser issues along the way.Bundled-module fixes (Text::vCard prereqs)
MIME::QuotedPrintdeclares$VERSIONand re-exportsencode/decodealiases. Without$VERSION,use MIME::QuotedPrint 3.07died with "does not define$MIME::QuotedPrint::VERSION".File::Specnow sets@ISA = ("File::Spec::$platform")based on$^Oinstead of just(Exporter). Modules like Directory::Scratch and Path::Class derive the platform from$File::Spec::ISA[0]; without this they passed an empty string to_spec_class()and died with "Invalid system type ''".Unicode::LineBreakshim providing the minimalUnicode::GCStringAPI (new/length/substr/as_string/columns) thatText::vCard::Nodeuses. Pure Perl, splits with\Xfor graphemes.Interpreter & operator fixes
blessnow emits the upstream "Use of uninitialized value$classin bless" and "Explicit blessing to '' (assuming package main)" warnings when given an undef class, matching real Perl. Tests likelike $@, qr/Use of uninitialized value/previously got an empty$@.chmod $mode, @pathsno longer silently no-ops.Operator.chmodwas iteratingruntimeList.elementsdirectly, so an unflattenedRuntimeArrayslot stringified asARRAY(0x...). Now flattens viaaddToList(...)likeUnlinkOperator.chomp/chopare now parsed as named-unary operators when used without parentheses. Sois(chomp @a, 3, "ok")parses asis(chomp(@a), 3, "ok")— matching real Perl deparse output — instead of lettingchompgobble all ofis()'s arguments.<$fh>on an empty file now returns the empty string on the first call andundefonly on the second call. Previously it returnedundefimmediately, which brokePath::Tiny->slurpon empty files (and Directory::Scratch on top of that).flockno longer leaks JVM-wide shared locks across abandoned Perl handles. Path::Tiny's slurp-then-append-with-truncate idiom used to fail with"Resource deadlock avoided"because the SHARED registry entry from the slurp's lexical$fhoutlived the Perl scope. Added aCleaner-based safety net plus a reactivereclaimAbandonedSharedLockretry path on EX-lock acquisition.Test plan
make— full PerlOnJava unit-test suite passes../jcpan -t Text::vCard— 18/18 test programs, 155/155 subtests pass../jcpan -t Directory::Scratch(run via Test::Harness fromblib) — 35/35 test programs, 691/691 subtests pass.Files changed
Generated with Devin