pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
466 stars 134 forks source link

Unit tests fail on macOS big sur #144

Closed Spuriosity1 closed 3 years ago

Spuriosity1 commented 3 years ago

I recently tried to install this library by building from source.

System configuration: macOS 11.2 Big Sur nlohmann/json installed via Homebrew: brew install nlohmann-json, installed version 3.9.1 Output of ls /usr/local/lib | grep json: libnlohmann_json_schema_validator.a Output of ls /usr/local/include/nlohmann:

adl_serializer.hpp              detail                          json.hpp                        ordered_map.hpp
byte_container_with_subtype.hpp json-schema.hpp                 json_fwd.hpp                    thirdparty

Build sequence:

git clone https://github.com/pboettch/json-schema-validator.git
mkdir build && cd build
cmake ..
make
make install
ctest

giving output:

37% tests passed, 52 tests failed out of 82

Total Test time (real) =  48.86 sec

The following tests FAILED:
     11 - JSON-Suite::additionalItems (Failed)
     12 - JSON-Suite::additionalProperties (Failed)
     13 - JSON-Suite::allOf (Failed)
     14 - JSON-Suite::anyOf (Failed)
     15 - JSON-Suite::boolean_schema (Failed)
     16 - JSON-Suite::const (Failed)
     17 - JSON-Suite::contains (Failed)
     18 - JSON-Suite::default (Failed)
     19 - JSON-Suite::definitions (Failed)
     20 - JSON-Suite::dependencies (Failed)
     21 - JSON-Suite::enum (Failed)
     22 - JSON-Suite::exclusiveMaximum (Failed)
     23 - JSON-Suite::exclusiveMinimum (Failed)
     24 - JSON-Suite::format (Failed)
     25 - JSON-Suite::if-then-else (Failed)
     26 - JSON-Suite::items (Failed)
     27 - JSON-Suite::maxItems (Failed)
     28 - JSON-Suite::maxLength (Failed)
     29 - JSON-Suite::maxProperties (Failed)
     30 - JSON-Suite::maximum (Failed)
     31 - JSON-Suite::minItems (Failed)
     32 - JSON-Suite::minLength (Failed)
     33 - JSON-Suite::minProperties (Failed)
     34 - JSON-Suite::minimum (Failed)
     35 - JSON-Suite::multipleOf (Failed)
     36 - JSON-Suite::not (Failed)
     37 - JSON-Suite::oneOf (Failed)
     38 - JSON-Suite::pattern (Failed)
     39 - JSON-Suite::patternProperties (Failed)
     40 - JSON-Suite::properties (Failed)
     41 - JSON-Suite::propertyNames (Failed)
     42 - JSON-Suite::ref (Failed)
     43 - JSON-Suite::refRemote (Failed)
     44 - JSON-Suite::required (Failed)
     45 - JSON-Suite::type (Failed)
     46 - JSON-Suite::uniqueItems (Failed)
     48 - JSON-Suite::Optional::content (Failed)
     51 - JSON-Suite::Optional::Format::date-time (Failed)
     52 - JSON-Suite::Optional::Format::date (Failed)
     54 - JSON-Suite::Optional::Format::email (Failed)
     55 - JSON-Suite::Optional::Format::hostname (Failed)
     58 - JSON-Suite::Optional::Format::ipv4 (Failed)
     59 - JSON-Suite::Optional::Format::ipv6 (Failed)
     63 - JSON-Suite::Optional::Format::regex (Failed)
     65 - JSON-Suite::Optional::Format::time (Failed)
     69 - Build::cmake-install (Failed)
     72 - Issue::12 (Failed)
     75 - Issue::143-ok (Failed)
     77 - Issue::48 (Failed)
     78 - Issue::54 (Failed)
     79 - Issue::75 (Failed)
     80 - Issue::9 (Failed)
Errors while running CTest
pboettch commented 3 years ago

Is this a duplicate of #141? Check if you have bash installed - a recent version (>4.0 (dating from 2009 afair)).

Spuriosity1 commented 3 years ago

I have GNU bash version 5.0.16 installed, but I ran the above in zsh version 5.8 (apple darwin). I tried rebuilding in bash (after clearing the build directory) and got the same output.

pboettch commented 3 years ago

Could you run ctest -V -R JSON-Suite::not to see more details of the error.

Spuriosity1 commented 3 years ago
UpdateCTestConfiguration  from :/*****/json-schema-validator/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/*****/json-schema-validator/build/DartConfiguration.tcl
Test project /*****/json-schema-validator/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 36
    Start 36: JSON-Suite::not

36: Test command: /*****/json-schema-validator/test/test-pipe-in.sh "/*****/json-schema-validator/build/test/JSON-Schema-Test-Suite/json-schema-test" "/*****/json-schema-validator/test/JSON-Schema-Test-Suite/tests/draft7/not.json"
36: Test timeout computed to be: 10000000
36: /*****/json-schema-validator/test/test-pipe-in.sh: line 10: arr: bad array subscript
1/1 Test #36: JSON-Suite::not ..................***Failed    0.01 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.03 sec

The following tests FAILED:
     36 - JSON-Suite::not (Failed)
Errors while running CTest

Looks like the same error #141 had. I called ctest in bash-5.0, but maybe it's running the tests in the default shell?

pboettch commented 3 years ago

What does which bash give you?

Spuriosity1 commented 3 years ago

/usr/local/bin/bash This is a symlink to Homebrew's installation: brew list bash gives

$ brew list bash
/usr/local/Cellar/bash/5.0.16/bin/bash
/usr/local/Cellar/bash/5.0.16/bin/bashbug
/usr/local/Cellar/bash/5.0.16/include/bash/ (58 files)
/usr/local/Cellar/bash/5.0.16/lib/bash/ (29 files)
/usr/local/Cellar/bash/5.0.16/lib/pkgconfig/bash.pc
/usr/local/Cellar/bash/5.0.16/share/doc/ (10 files)
/usr/local/Cellar/bash/5.0.16/share/info/bash.info
/usr/local/Cellar/bash/5.0.16/share/locale/ (38 files)
/usr/local/Cellar/bash/5.0.16/share/man/ (2 files)
pboettch commented 3 years ago

That's the problem:

The script is looking for bash to be in /bin.

Spuriosity1 commented 3 years ago

Right, /bin/bash is the macOS default, which is bash 3.0.

pboettch commented 3 years ago

So what now? How to fix it? Do you have an idea?

Spuriosity1 commented 3 years ago

I just patched it by replacing arr[-1] with ${arr[${#arr[@]}-1]}, I'll submit a pull request (#150)