Skip to content

feat(YAML): vendor real YAML.pm 1.31 instead of YAML::PP shim#596

Closed
fglock wants to merge 2 commits intomasterfrom
feature/real-yaml-pm
Closed

feat(YAML): vendor real YAML.pm 1.31 instead of YAML::PP shim#596
fglock wants to merge 2 commits intomasterfrom
feature/real-yaml-pm

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 28, 2026

Summary

Replace the 12-line YAML.pm shim (which delegated to YAML::PP and impersonated $YAML::VERSION = '1.31') with the actual pure-Perl YAML.pm 1.31 distribution. YAML::PP itself (Java-backed via YAMLPP.java + snakeyaml-engine) is kept unchanged as a separate bundled module — Storable.java already uses snakeyaml-engine directly and is unaffected.

This fixes the long-standing semantic mismatches that caused t/2-scalars.t to fail 5 of 12 sub-tests and made any test asserting YAML.pm-1.x output (~ for undef, plain "true"/"false", Can't parse single/Can't parse double errors) impossible to satisfy.

What changed

  • src/main/perl/lib/YAML.pm — replaced with real YAML.pm 1.31
  • src/main/perl/lib/YAML/{Any,Dumper,Error,Loader,Marshall,Mo,Node,Tag,Types}.pm — added
  • src/main/perl/lib/YAML/{Loader,Dumper}/Base.pm — added
  • src/test/resources/module/YAML/t/ — 7 upstream tests added to bundled-module suite
  • dev/modules/yaml_any_fixes.md — full investigation, design rationale, results

What did not change

  • src/main/java/org/perlonjava/runtime/perlmodule/YAMLPP.java — kept (use YAML::PP; is its own bundled module with its own unit test, docs, and CPAN consumers).
  • src/main/perl/lib/YAML/PP.pm — kept.
  • src/main/perl/lib/Storable.pm — unaffected.

Test plan

  • make — clean (no PerlOnJava unit-test regressions).
  • ./gradlew testModule --rerun-tasks — all 7 new YAML tests pass:
    • module/YAML/t/2-scalars.t (12/12 sub-tests; was 7/12 with the shim)
    • module/YAML/t/dump-synopsis.t
    • module/YAML/t/issue-149.t
    • module/YAML/t/issue-69.t
    • module/YAML/t/numify.t (uses B)
    • module/YAML/t/roundtrip.t (uses Test::Deep)
    • module/YAML/t/rt-90593.t
  • ./jperl -MYAML -e '...' and ./jperl -MYAML::PP -e '...' both work side-by-side.
  • The 2 pre-existing failures (Net-SSLeay/t/local/33_x509_create_cert.t, Text-CSV/t/55_combi.t) reproduce on master — unrelated to this PR (no diff in those module dirs).

Why not also include the rest of the YAML test suite?

35 of the 54 upstream t/*.t files use Test::Base, which dies at compile time with syntax error at .../Test/Base.pm line 53, near "=> [qw" because of a separate Spiffy source-filter leak in executePerlCode (documented as Bug 1 in dev/modules/yaml_any_fixes.md). They will be added in a follow-up PR alongside that fix.

Generated with Devin

fglock and others added 2 commits April 28, 2026 19:24
Previously src/main/perl/lib/YAML.pm was a 12-line wrapper around
YAML::PP that pinned $VERSION = '1.31' but produced YAML 1.2 output
(`null` instead of `~`, JSON-style booleans, snakeyaml error
messages).  This caused 5/12 failures in the YAML-1.31 distribution's
own t/2-scalars.t, and would never satisfy YAML.pm-1.x-specific
assertions in the rest of that test suite.

Vendor the real pure-Perl YAML.pm 1.31 distribution into
src/main/perl/lib/:

- YAML.pm (replaced)
- YAML/{Any,Dumper,Error,Loader,Marshall,Mo,Node,Tag,Types}.pm
- YAML/Loader/Base.pm
- YAML/Dumper/Base.pm

YAML::PP (Java-backed via YAMLPP.java + snakeyaml-engine) is kept
unchanged for users who specifically `use YAML::PP;` and for the
yaml_pp.t unit test.  Storable.java already uses snakeyaml-engine
directly and is unaffected.

Verified on the YAML-1.31 distribution itself:
  - t/000-compile-modules.t: 12/12 pass (all YAML modules load)
  - t/2-scalars.t:           12/12 pass (was 7/12)

Documented in dev/modules/yaml_any_fixes.md.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Drop seven tests from the upstream YAML-1.31 distribution into
src/test/resources/module/YAML/t/ so `make test-bundled-modules`
exercises the freshly-vendored real YAML.pm against its own test
suite:

  - 2-scalars.t       — full scalar round-trip + error matching
  - dump-synopsis.t   — dump example
  - issue-149.t       — load without trailing newline
  - issue-69.t        — inline collection trailing whitespace
  - numify.t          — B::svref_2object numification
  - roundtrip.t       — Test::Deep round-trip on `=` key
  - rt-90593.t        — RT bug regression

Verified via `./gradlew testModule --rerun-tasks`: all 7 YAML tests
pass.  The two pre-existing failures in the suite
(Net-SSLeay/t/local/33_x509_create_cert.t and Text-CSV/t/55_combi.t)
are unrelated to YAML and present on master.

The remaining tests in the upstream YAML distribution
(basic-tests.t, bugs-*, dump-*, load-*, marshall.t, etc.) all use
`Test::Base` and are blocked on the Spiffy source-filter leak
documented as "Bug 1" in dev/modules/yaml_any_fixes.md.  They will
land alongside that fix.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock
Copy link
Copy Markdown
Owner Author

fglock commented Apr 28, 2026

Subsumed by #597 — combined into a single PR per request.

@fglock fglock closed this Apr 28, 2026
@fglock fglock deleted the feature/real-yaml-pm branch April 28, 2026 19:45
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