feat: add YAML::XS shim that delegates to bundled YAML::PP#642
Merged
Conversation
Before this change `./jcpan -t YAML::XS` failed catastrophically with "Can't locate YAML/XS/LibYAML.pm in @inc" on every test, because the upstream YAML::XS distribution (YAML-LibYAML) is XS-only and PerlOnJava cannot load XS. We already ship a JVM-backed YAML::PP (SnakeYAML under the hood), so this commit adds two pure-Perl shims that re-expose YAML::PP under the YAML::XS namespace: - src/main/perl/lib/YAML/XS::LibYAML.pm Tiny stub that exports Load/Dump by delegating to YAML::PP. The cpan-installed upstream YAML::XS.pm in ~/.perlonjava/lib uses this to satisfy `use YAML::XS::LibYAML qw(Load Dump);`. - src/main/perl/lib/YAML/XS.pm Bundled fallback so `use YAML::XS;` works out of the box without first running jcpan. Implements Load/Dump/LoadFile/DumpFile and declares the standard YAML::XS package globals. With the shim in place `jcpan -t YAML::XS` configures, builds and runs the test suite, going from 0/49 test programs running to 17/49 passing (192/283 subtests). The remaining failures are YAML::PP/SnakeYAML semantic limitations (booleans, blessed/tied refs, !!perl/code, !!perl/regexp, !!perl/glob round-tripping, alias output format, upstream error message wording) and are not caused by the shim. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
./jcpan -t YAML::XSpreviously failed catastrophically. The CPAN distributionYAML::XS(a.k.a.YAML-LibYAML) is an XS wrapper around libyaml, and PerlOnJava cannot load XS, so every test died with:We already bundle a JVM-backed
YAML::PP(SnakeYAML under the hood), so this PR adds two pure-Perl shims that re-exposeYAML::PPunder theYAML::XSnamespace:src/main/perl/lib/YAML/XS/LibYAML.pm— minimal stub exportingLoad/Dump, used by the cpan-installed upstreamYAML/XS.pmin~/.perlonjava/lib.src/main/perl/lib/YAML/XS.pm— bundled fallback souse YAML::XS;works out of the box without first runningjcpan. ImplementsLoad/Dump/LoadFile/DumpFileand declares the standardYAML::XSpackage globals.Test plan
make(full unit test suite) passes../jperl -e 'use YAML::XS qw(Load Dump); print Dump(Load("a: 1\nb: [1,2,3]\n"))'round-trips correctly../jcpan -t YAML::XSnow configures, builds, and runs the test suite. Test programs go from 0/49 running to 17/49 passing (192/283 subtests pass).Out of scope
The remaining
YAML::XStest failures are all YAML::PP / SnakeYAML feature gaps, not shim bugs:$YAML::XS::Booleanmodes, JSON::PP boolean round-tripping)!!perl/code,!!perl/regexp,!!perl/globround-tripping$Indent/$QuoteNumericStringsand other config globals (accepted but not honoured by the shim)Fixing those would require enhancing
YAML::PPitself.Generated with Devin