makamaka / JSON

perl implementation of JSON encoder/decoder
42 stars 40 forks source link

Add Cpanel::JSON::XS support #17

Closed bulk88 closed 5 years ago

bulk88 commented 10 years ago

Since schmorp dropped support for Visual C ( http://ppm4.activestate.com/MSWin32-x86/5.16/1600/M/ML/MLEHMANN/JSON-XS-3.01.d/log-20131030T032436.txt ) and told me to go fuck myself, I now exclusively use Cpanel::JSON::XS.

Previous support_cpanel branch failed like this.

C:\sources\json>set PERL_JSON_BACKEND=Cpanel::JSON::XS

C:\sources\json>perl makefile.pl
Loading lib/JSON.pm failed. B module can't install?
perl says : The value of environmental variable 'PERL_JSON_BACKEND' is invalid.
at (eval 10) line 2.
Compilation failed in require at (eval 10) line 2.
Set the environmental variable 'PERL_DL_NONLAZY' to 0.
And see ExtUtils::MM_Unix.
No Makefile created.

C:\sources\json>

So I fixed that, and rebased the branch on top master. Some tests fail tho.

C:\sources\json>perl makefile.pl
Welcome to JSON (v.2.90)
=============================

 *************************** CAUTION **************************************
 *                                                                        *
 * INCOMPATIBLE CHANGE (JSON::XS version 2.90)                            *
 *                                                                        *
 * JSON.pm had patched JSON::XS::Boolean and JSON::PP::Boolean internally *
 * on loading time for making these modules inherit JSON::Boolean.        *
 * But since JSON::XS v3.0 it use Types::Serialiser as boolean class.     *
 * Then now JSON.pm breaks boolean classe overload features and           *
 * -support_by_pp if JSON::XS v3.0 or later is installed.                 *
 *                                                                        *
 * JSON::true and JSON::false returned JSON::Boolean objects.             *
 * For workaround, they return JSON::PP::Boolean objects in this version. *
 *                                                                        *
 *     isa_ok(JSON::true, 'JSON::PP::Boolean');                           *
 *                                                                        *
 * And it discards a feature:                                             *
 *                                                                        *
 *     ok(JSON::true eq 'true');                                          *
 *                                                                        *
 * In other word, JSON::PP::Boolean overload numeric only.                *
 *                                                                        *
 *     ok( JSON::true == 1 );                                             *
 *                                                                        *
 **************************************************************************

 ************************** CAUTION **************************
 * This is 'JSON version 2' and there are many differences   *
 * to version 1.xx                                           *
 * Please check your applications useing old version.        *
 *   See to 'INCOMPATIBLE CHANGES TO OLD VERSION' and 'TIPS' *
 *************************************************************

Checking if your kit is complete...
Warning: the following files are missing in your kit:
        META.yml
Please inform the author.
Generating a nmake-style Makefile
Writing Makefile for JSON
Writing MYMETA.yml and MYMETA.json

C:\sources\json>nmake test

Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation.  All rights reserved.

cp lib/JSON/backportPP/Compat5006.pm blib\lib\JSON\backportPP\Compat5006.pm
cp lib/JSON/backportPP/Boolean.pm blib\lib\JSON\backportPP\Boolean.pm
cp lib/JSON/backportPP.pm blib\lib\JSON\backportPP.pm
cp lib/JSON/backportPP/Compat5005.pm blib\lib\JSON\backportPP\Compat5005.pm
cp lib/JSON.pm blib\lib\JSON.pm
        C:\perl519\bin\perl.exe "-MExtUtils::Command::MM" "-MTest::Harness" "-e"
 "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.
t
t/00_load.t ................. ok
t/00_pod.t .................. skipped: Test::Pod 1.00 required for testing POD
t/01_utf8.t ................. ok
t/02_error.t ................ ok
t/03_types.t ................ ok
t/06_pc_pretty.t ............ ok
t/07_pc_esc.t ............... ok
t/08_pc_base.t .............. ok
t/09_pc_extra_number.t ...... ok
t/10_pc_keysort.t ........... ok
t/11_pc_expo.t .............. ok
t/12_blessed.t .............. ok
t/13_limit.t ................ ok
t/14_latin1.t ............... ok
t/15_prefix.t ............... ok
t/16_tied.t ................. ok
t/17_relaxed.t .............. ok
t/18_json_checker.t ......... ok
t/19_incr.t ................. ok
t/20_unknown.t .............. ok
t/21_evans_bugrep.t ......... ok
t/22_comment_at_eof.t ....... ok
t/99_binary.t ............... ok
t/e00_func.t ................ ok
t/e01_property.t ............ ok
t/e02_bool.t ................ ok
t/e03_bool2.t ............... ok
t/e04_sortby.t .............. ok
t/e05_esc_slash.t ........... ok
t/e06_allow_barekey.t ....... ok
t/e07_allow_singlequote.t ... ok
t/e08_decode.t .............. ok
t/e09_encode.t .............. ok
t/e10_bignum.t .............. ok
t/e11_conv_blessed_univ.t ... ok
t/e12_upgrade.t ............. ok
t/e13_overloaded_eq.t ....... ok
t/e14_decode_prefix.t ....... ok
t/e15_tie_ixhash.t .......... ok
t/e16_incr_parse_fixed.t .... ok
t/e90_misc.t ................ ok
t/x00_load.t ................ # load JSON::XS v.2.3404
t/x00_load.t ................ ok
t/x02_error.t ............... ok
t/x12_blessed.t ............. ok
t/x16_tied.t ................ ok
t/x17_strange_overload.t .... ok
t/xe01_property.t ........... ok
t/xe02_bool.t ............... 1/8
#   Failed test 'An object of class 'JSON::XS::Boolean' isa 'JSON::PP::Boolean''

#   at t/xe02_bool.t line 32.
#     The object of class 'JSON::XS::Boolean' isn't a 'JSON::PP::Boolean'
# Looks like you failed 1 test of 8.
t/xe02_bool.t ............... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/8 subtests
t/xe03_bool2.t .............. 1/16
#   Failed test 'An object of class 'JSON::XS::Boolean' isa 'JSON::PP::Boolean''

#   at t/xe03_bool2.t line 18.
#     The object of class 'JSON::XS::Boolean' isn't a 'JSON::PP::Boolean'

#   Failed test 'An object of class 'JSON::XS::Boolean' isa 'JSON::PP::Boolean''

#   at t/xe03_bool2.t line 19.
#     The object of class 'JSON::XS::Boolean' isn't a 'JSON::PP::Boolean'
# Looks like you failed 2 tests of 16.
t/xe03_bool2.t .............. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/16 subtests
t/xe04support_by_pp.t ....... ok
t/xe05_indent_length.t ...... ok
t/xe08_decode.t ............. ok
t/xe10_bignum.t ............. ok
t/xe11_conv_blessed_univ.t .. ok
t/xe12_boolean.t ............
#   Failed test 'An object of class 'JSON::XS::Boolean' isa 'JSON::PP::Boolean''

t/xe12_boolean.t ............ 1/4 #   at t/xe12_boolean.t line 24.
#     The object of class 'JSON::XS::Boolean' isn't a 'JSON::PP::Boolean'
encountered object 'true', but neither allow_blessed nor convert_blessed setting
s are enabled at t/xe12_boolean.t line 31.
# Looks like you planned 4 tests but ran 3.
# Looks like you failed 1 test of 3 run.
# Looks like your test exited with 255 just after 3.
t/xe12_boolean.t ............ Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 2/4 subtests
t/xe19_xs_and_suportbypp.t .. ok
t/xe20_croak_message.t ...... ok
t/xe21_is_pp.t .............. ok

Test Summary Report
-------------------
t/xe02_bool.t             (Wstat: 256 Tests: 8 Failed: 1)
  Failed test:  8
  Non-zero exit status: 1
t/xe03_bool2.t            (Wstat: 512 Tests: 16 Failed: 2)
  Failed tests:  4-5
  Non-zero exit status: 2
t/xe12_boolean.t          (Wstat: 65280 Tests: 3 Failed: 1)
  Failed test:  1
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 4 tests but ran 3.
Files=58, Tests=3800, 11 wallclock secs ( 0.64 usr +  0.03 sys =  0.67 CPU)
Result: FAIL
Failed 3/58 test programs. 4/3800 subtests failed.
NMAKE : fatal error U1077: 'C:\perl519\bin\perl.exe' : return code '0xff'
Stop.

C:\sources\json>

Not sure if this is a JSON.pm side issue or a Cpanel::JSON::XS issue.

bulk88 commented 8 years ago

Bump.

charsbar commented 8 years ago

Hi. The current master should work with Cpanel::JSON::XS by setting PERL_JSON_BACKEND=Cpanel::JSON::XS (though it may spit redefine warnings depending on the loading order; see https://github.com/rurban/Cpanel-JSON-XS/issues/65 , which I'm working on). Could you test it if it also works for you?

charsbar commented 5 years ago

Closed.