From fba2e9d88c71d955160d49dd66e1beef88106a01 Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 09:17:37 +0500 Subject: [PATCH 1/8] Temporary reduce test suite and force verbose build --- .github/workflows/codeql-analysis.yml | 54 ----- .github/workflows/macos.yml | 17 -- .github/workflows/ubuntu.yml | 16 -- .github/workflows/windows.yml | 68 ------- .travis.yml | 278 +------------------------- 5 files changed, 5 insertions(+), 428 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/ubuntu.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 5ee44a04e6..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: "Code scanning - action" - -on: - push: - branches: [develop, ] - pull_request: - # The branches below must be a subset of the branches above - branches: [develop] - schedule: - - cron: '0 19 * * 1' - -jobs: - CodeQL-Build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index 5b178ad055..0000000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: macOS - -on: [push, pull_request] - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index 1a47a885c0..0000000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Ubuntu - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 --output-on-failure diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 5846cf7500..0000000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Windows - -on: [push, pull_request] - -jobs: - msvc2019: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - - clang9: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - - name: install Clang - run: curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe ; 7z x LLVM9.exe -y -o"C:/Program Files/LLVM" - - name: cmake - run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - - clang10: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - - name: install Clang - run: curl -fsSL -o LLVM10.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe ; 7z x LLVM10.exe -y -o"C:/Program Files/LLVM" - - name: cmake - run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On - - name: build - run: cmake --build build --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - - clang-cl-10-x64: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On - - name: build - run: cmake --build build --config Debug --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure - - clang-cl-10-x86: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - - name: cmake - run: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -T ClangCL -DJSON_BuildTests=On - - name: build - run: cmake --build build --config Debug --parallel 10 - - name: test - run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure diff --git a/.travis.yml b/.travis.yml index bf749c1e33..745443bb7e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,207 +17,8 @@ group: edge matrix: include: - # Valgrind - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_Valgrind=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'valgrind', 'ninja-build'] - - # clang sanitizer - - os: linux - compiler: clang - env: - - COMPILER=clang++-7 - - CMAKE_OPTIONS=-DJSON_Sanitizer=ON - - UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-6', 'clang-7', 'ninja-build'] - before_script: - - export PATH=$PATH:/usr/lib/llvm-7/bin - - # cppcheck - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - SPECIAL=cppcheck - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'cppcheck', 'ninja-build'] - after_success: - - make cppcheck - - # no exceptions - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_NoExceptions=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'ninja-build'] - - # check amalgamation - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - SPECIAL=amalgamation - - MULTIPLE_HEADERS=ON - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'astyle', 'ninja-build'] - after_success: - - make check-amalgamation - - # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) - - - os: linux - compiler: gcc - dist: bionic - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'ninja-build'] - before_script: - - pip install --user cpp-coveralls - after_success: - - coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp' - env: - - COMPILER=g++-7 - - CMAKE_OPTIONS=-DJSON_Coverage=ON - - MULTIPLE_HEADERS=ON - - # Coverity (only for branch coverity_scan) - - - os: linux - compiler: clang - before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] - packages: ['g++-6', 'clang-3.6', 'ninja-build'] - coverity_scan: - project: - name: "nlohmann/json" - description: "Build submitted via Travis CI" - notification_email: niels.lohmann@gmail.com - build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .." - build_command: "make -C coverity_build" - branch_pattern: coverity_scan - env: - - SPECIAL=coverity - - COMPILER=clang++-3.6 - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" - - # OSX / Clang - - - os: osx - osx_image: xcode9.3 - - - os: osx - osx_image: xcode9.4 - - - os: osx - osx_image: xcode10 - - - os: osx - osx_image: xcode10.1 - - - os: osx - osx_image: xcode10.2 - - - os: osx - osx_image: xcode11.2 - - - os: osx - osx_image: xcode12 - - - os: osx - osx_image: xcode12 - env: - - IMPLICIT_CONVERSIONS=OFF - # Linux / GCC - - os: linux - compiler: gcc - env: COMPILER=g++-4.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-4.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-6 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8', 'ninja-build'] - - - os: linux - compiler: gcc - env: COMPILER=g++-9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - - os: linux - compiler: gcc - env: - - COMPILER=g++-9 - - IMPLICIT_CONVERSIONS=OFF - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-9', 'ninja-build'] - - os: linux compiler: gcc env: @@ -230,78 +31,6 @@ matrix: # Linux / Clang - - os: linux - compiler: clang - env: COMPILER=clang++-3.5 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5'] - packages: ['g++-6', 'clang-3.5', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.6 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] - packages: ['g++-6', 'clang-3.6', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] - packages: ['g++-6', 'clang-3.7', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.8 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.8', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-3.9 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'clang-3.9', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-4.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] - packages: ['g++-6', 'clang-4.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-5.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0'] - packages: ['g++-6', 'clang-5.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-6.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['g++-6', 'clang-6.0', 'ninja-build'] - - - os: linux - compiler: clang - env: COMPILER=clang++-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] - packages: ['g++-6', 'clang-7', 'ninja-build'] - - os: linux compiler: clang env: @@ -333,10 +62,13 @@ script: # by default, use implicit conversions - if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi + # force verbose build + - CMAKE_OPTIONS+=" -DCMAKE_VERBOSE_MAKEFILE=ON" + # compile and execute unit tests - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release - - ctest -C Release --timeout 2700 -V -j + - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release --target test-conversions + - ctest -C Release --timeout 2700 -V -R test-conversions -j - cd .. # check if homebrew works (only checks develop branch) From df5943da52c890147e1860be7905830c6f35eac9 Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 12:10:45 +0500 Subject: [PATCH 2/8] Temporary remove appveyor tests too --- appveyor.yml | 147 --------------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5836f88d0e..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: '{build}' - -environment: - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Debug - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Debug - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Debug - COMPILER: mingw - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Ninja - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - COMPILER: mingw - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Ninja - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x86 - name: with_win_header - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x86 - CXX_FLAGS: "/permissive- /std:c++latest /utf-8" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x86 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 14 2015 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - configuration: Release - platform: x64 - CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000" - LINKER_FLAGS: "/STACK:4000000" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - configuration: Release - platform: x64 - CXX_FLAGS: "" - LINKER_FLAGS: "" - CMAKE_OPTIONS: "" - GENERATOR: Visual Studio 16 2019 - -init: - - cmake --version - - msbuild /version - -install: - - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip - - if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul - - if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH% - - if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% - - if "%COMPILER%"=="mingw" g++ --version - - if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32 - -before_build: - # for with_win_header build, inject the inclusion of Windows.h to the single-header library - - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } - - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - - if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") - -build_script: - - cmake --build . --config "%configuration%" - -test_script: - - if "%configuration%"=="Release" ctest -C "%configuration%" -V -j - # On Debug builds, skip test-unicode_all - # as it is extremely slow to run and cause - # occasional timeouts on AppVeyor. - # More info: https://github.com/nlohmann/json/pull/1570 - - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j From 1943399433be493237b6cfe4ca3a75d06f230ca9 Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 09:40:21 +0500 Subject: [PATCH 3/8] Fix C++ standard requirements for travis --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 745443bb7e..39f1100d8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ matrix: compiler: gcc env: - COMPILER=g++-9 - - CXXFLAGS=-std=c++2a + - CXX_STANDARD=17 addons: apt: sources: ['ubuntu-toolchain-r-test'] @@ -35,7 +35,7 @@ matrix: compiler: clang env: - COMPILER=clang++-7 - - CXXFLAGS=-std=c++1z + - CXX_STANDARD=17 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] @@ -62,13 +62,16 @@ script: # by default, use implicit conversions - if [[ "${IMPLICIT_CONVERSIONS}" == "" ]]; then export IMPLICIT_CONVERSIONS=ON; fi + # append CXX_STANDARD to CMAKE_OPTIONS if required + - CMAKE_OPTIONS+=${CXX_STANDARD:+ -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DCMAKE_CXX_STANDARD_REQUIRED=ON} + # force verbose build - CMAKE_OPTIONS+=" -DCMAKE_VERBOSE_MAKEFILE=ON" # compile and execute unit tests - mkdir -p build && cd build - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release --target test-conversions - - ctest -C Release --timeout 2700 -V -R test-conversions -j + - ctest -C Release --timeout 2700 -V -R test-conversions -j - cd .. # check if homebrew works (only checks develop branch) From 5eddcc134df81791b455e7eb0e3d4ef3a623ce0e Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 10:05:51 +0500 Subject: [PATCH 4/8] Allow to use string_view from std::experimental --- include/nlohmann/detail/macro_scope.hpp | 19 ++++++++++++ include/nlohmann/json.hpp | 2 +- single_include/nlohmann/json.hpp | 21 ++++++++++++- test/src/unit-conversions.cpp | 39 ++++++++++++------------- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 77acf04c76..8dd34ac97c 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -31,6 +31,25 @@ #define JSON_HAS_CPP_14 #endif +namespace nlohmann { +namespace std_aliases { } +using namespace std_aliases; +} + +#if defined(JSON_HAS_CPP_17) + #if __has_include() + #include + namespace nlohmann::std_aliases { + using std::string_view; + } + #elif __has_include() + #include + namespace nlohmann::std_aliases { + using std::experimental::string_view; + } + #endif +#endif + // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index cd56dafdc4..e9bb1afd43 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3230,7 +3230,7 @@ class basic_json !detail::is_basic_json::value && !std::is_same>::value #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - && !std::is_same::value + && !std::is_same::value #endif && detail::is_detected::value , int >::type = 0 > diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e9dbc87dad..2ba6c40512 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2048,6 +2048,25 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HAS_CPP_14 #endif +namespace nlohmann { +namespace std_aliases { } +using namespace std_aliases; +} + +#if defined(JSON_HAS_CPP_17) + #if __has_include() + #include + namespace nlohmann::std_aliases { + using std::string_view; + } + #elif __has_include() + #include + namespace nlohmann::std_aliases { + using std::experimental::string_view; + } + #endif +#endif + // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push @@ -19736,7 +19755,7 @@ class basic_json !detail::is_basic_json::value && !std::is_same>::value #if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - && !std::is_same::value + && !std::is_same::value #endif && detail::is_detected::value , int >::type = 0 > diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index c71e230d96..091c4130ce 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -32,6 +32,7 @@ SOFTWARE. #define JSON_TESTS_PRIVATE #include using nlohmann::json; +using namespace nlohmann::std_aliases; #include #include @@ -48,10 +49,6 @@ using nlohmann::json; #define JSON_HAS_CPP_14 #endif -#if defined(JSON_HAS_CPP_17) - #include -#endif - TEST_CASE("value conversion") { SECTION("get an object (explicit)") @@ -465,7 +462,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string_view s = j.get(); + string_view s = j.get(); CHECK(json(s) == j); } #endif @@ -514,27 +511,27 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("exception in case of a non-string type using string_view") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); - CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); - CHECK_THROWS_WITH(json(json::value_t::null).get(), + CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be string, but is null"); - CHECK_THROWS_WITH(json(json::value_t::object).get(), + CHECK_THROWS_WITH(json(json::value_t::object).get(), "[json.exception.type_error.302] type must be string, but is object"); - CHECK_THROWS_WITH(json(json::value_t::array).get(), + CHECK_THROWS_WITH(json(json::value_t::array).get(), "[json.exception.type_error.302] type must be string, but is array"); - CHECK_THROWS_WITH(json(json::value_t::boolean).get(), + CHECK_THROWS_WITH(json(json::value_t::boolean).get(), "[json.exception.type_error.302] type must be string, but is boolean"); - CHECK_THROWS_WITH(json(json::value_t::number_integer).get(), + CHECK_THROWS_WITH(json(json::value_t::number_integer).get(), "[json.exception.type_error.302] type must be string, but is number"); - CHECK_THROWS_WITH(json(json::value_t::number_unsigned).get(), + CHECK_THROWS_WITH(json(json::value_t::number_unsigned).get(), "[json.exception.type_error.302] type must be string, but is number"); - CHECK_THROWS_WITH(json(json::value_t::number_float).get(), + CHECK_THROWS_WITH(json(json::value_t::number_float).get(), "[json.exception.type_error.302] type must be string, but is number"); } #endif @@ -562,7 +559,7 @@ TEST_CASE("value conversion") SECTION("std::string_view") { std::string s = "previous value"; - std::string_view sv = s; + string_view sv = s; j.get_to(sv); CHECK(json(sv) == j); } @@ -617,7 +614,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string_view s = j.get(); + string_view s = j.get(); CHECK(json(s) == j); } #endif From 5a0d8f4ea556b6c63ba27b81b85711dec38bfa77 Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 10:48:49 +0500 Subject: [PATCH 5/8] Restore full test suite --- .github/workflows/codeql-analysis.yml | 54 +++++ .github/workflows/macos.yml | 17 ++ .github/workflows/ubuntu.yml | 16 ++ .github/workflows/windows.yml | 68 +++++++ .travis.yml | 275 +++++++++++++++++++++++++- appveyor.yml | 147 ++++++++++++++ 6 files changed, 575 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/ubuntu.yml create mode 100644 .github/workflows/windows.yml create mode 100644 appveyor.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..5ee44a04e6 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,54 @@ +name: "Code scanning - action" + +on: + push: + branches: [develop, ] + pull_request: + # The branches below must be a subset of the branches above + branches: [develop] + schedule: + - cron: '0 19 * * 1' + +jobs: + CodeQL-Build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000000..5b178ad055 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,17 @@ +name: macOS + +on: [push, pull_request] + +jobs: + build: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v1 + - name: cmake + run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: build + run: cmake --build build --parallel 10 + - name: test + run: cd build ; ctest -j 10 --output-on-failure diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000000..1a47a885c0 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,16 @@ +name: Ubuntu + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: cmake + run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: build + run: cmake --build build --parallel 10 + - name: test + run: cd build ; ctest -j 10 --output-on-failure diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000000..5846cf7500 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,68 @@ +name: Windows + +on: [push, pull_request] + +jobs: + msvc2019: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: cmake + run: cmake -S . -B build -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: build + run: cmake --build build --parallel 10 + - name: test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + + clang9: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: install Clang + run: curl -fsSL -o LLVM9.exe https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe ; 7z x LLVM9.exe -y -o"C:/Program Files/LLVM" + - name: cmake + run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: build + run: cmake --build build --parallel 10 + - name: test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + + clang10: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: install Clang + run: curl -fsSL -o LLVM10.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe ; 7z x LLVM10.exe -y -o"C:/Program Files/LLVM" + - name: cmake + run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: build + run: cmake --build build --parallel 10 + - name: test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + + clang-cl-10-x64: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: cmake + run: cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On + - name: build + run: cmake --build build --config Debug --parallel 10 + - name: test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + + clang-cl-10-x86: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: cmake + run: cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 -T ClangCL -DJSON_BuildTests=On + - name: build + run: cmake --build build --config Debug --parallel 10 + - name: test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure diff --git a/.travis.yml b/.travis.yml index 39f1100d8c..b12d5540c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,207 @@ group: edge matrix: include: + # Valgrind + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - CMAKE_OPTIONS=-DJSON_Valgrind=ON + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'valgrind', 'ninja-build'] + + # clang sanitizer + - os: linux + compiler: clang + env: + - COMPILER=clang++-7 + - CMAKE_OPTIONS=-DJSON_Sanitizer=ON + - UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] + packages: ['g++-6', 'clang-7', 'ninja-build'] + before_script: + - export PATH=$PATH:/usr/lib/llvm-7/bin + + # cppcheck + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - SPECIAL=cppcheck + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'cppcheck', 'ninja-build'] + after_success: + - make cppcheck + + # no exceptions + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - CMAKE_OPTIONS=-DJSON_NoExceptions=ON + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'ninja-build'] + + # check amalgamation + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - SPECIAL=amalgamation + - MULTIPLE_HEADERS=ON + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'astyle', 'ninja-build'] + after_success: + - make check-amalgamation + + # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) + + - os: linux + compiler: gcc + dist: bionic + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-7', 'ninja-build'] + before_script: + - pip install --user cpp-coveralls + after_success: + - coveralls --build-root test --include include/nlohmann --gcov 'gcov-7' --gcov-options '\-lp' + env: + - COMPILER=g++-7 + - CMAKE_OPTIONS=-DJSON_Coverage=ON + - MULTIPLE_HEADERS=ON + + # Coverity (only for branch coverity_scan) + + - os: linux + compiler: clang + before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] + packages: ['g++-6', 'clang-3.6', 'ninja-build'] + coverity_scan: + project: + name: "nlohmann/json" + description: "Build submitted via Travis CI" + notification_email: niels.lohmann@gmail.com + build_command_prepend: "mkdir coverity_build ; cd coverity_build ; cmake .. ; cd .." + build_command: "make -C coverity_build" + branch_pattern: coverity_scan + env: + - SPECIAL=coverity + - COMPILER=clang++-3.6 + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" + + # OSX / Clang + + - os: osx + osx_image: xcode9.3 + + - os: osx + osx_image: xcode9.4 + + - os: osx + osx_image: xcode10 + + - os: osx + osx_image: xcode10.1 + + - os: osx + osx_image: xcode10.2 + + - os: osx + osx_image: xcode11.2 + + - os: osx + osx_image: xcode12 + + - os: osx + osx_image: xcode12 + env: + - IMPLICIT_CONVERSIONS=OFF + # Linux / GCC + - os: linux + compiler: gcc + env: COMPILER=g++-4.8 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.8', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-4.9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-5 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-5', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-6 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-6', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-7', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-8 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-8', 'ninja-build'] + + - os: linux + compiler: gcc + env: COMPILER=g++-9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-9', 'ninja-build'] + + - os: linux + compiler: gcc + env: + - COMPILER=g++-9 + - IMPLICIT_CONVERSIONS=OFF + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-9', 'ninja-build'] + - os: linux compiler: gcc env: @@ -31,6 +230,78 @@ matrix: # Linux / Clang + - os: linux + compiler: clang + env: COMPILER=clang++-3.5 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5'] + packages: ['g++-6', 'clang-3.5', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-3.6 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] + packages: ['g++-6', 'clang-3.6', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-3.7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] + packages: ['g++-6', 'clang-3.7', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-3.8 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-6', 'clang-3.8', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-3.9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-6', 'clang-3.9', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-4.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] + packages: ['g++-6', 'clang-4.0', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-5.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0'] + packages: ['g++-6', 'clang-5.0', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-6.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] + packages: ['g++-6', 'clang-6.0', 'ninja-build'] + + - os: linux + compiler: clang + env: COMPILER=clang++-7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-7'] + packages: ['g++-6', 'clang-7', 'ninja-build'] + - os: linux compiler: clang env: @@ -70,8 +341,8 @@ script: # compile and execute unit tests - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release --target test-conversions - - ctest -C Release --timeout 2700 -V -R test-conversions -j + - cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -DJSON_ImplicitConversions=${IMPLICIT_CONVERSIONS} -DJSON_BuildTests=On -GNinja && cmake --build . --config Release + - ctest -C Release --timeout 2700 -V -j - cd .. # check if homebrew works (only checks develop branch) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000..5836f88d0e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,147 @@ +version: '{build}' + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 16 2019 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Debug + platform: x64 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 16 2019 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + COMPILER: mingw + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Ninja + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + COMPILER: mingw + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Ninja + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x86 + name: with_win_header + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release + platform: x86 + CXX_FLAGS: "/permissive- /std:c++latest /utf-8" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Release + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "-DJSON_ImplicitConversions=OFF" + GENERATOR: Visual Studio 16 2019 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Release + platform: x64 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 16 2019 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release + platform: x64 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release + platform: x64 + CXX_FLAGS: "/permissive- /std:c++latest /Zc:__cplusplus /utf-8 /F4000000" + LINKER_FLAGS: "/STACK:4000000" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + configuration: Release + platform: x64 + CXX_FLAGS: "" + LINKER_FLAGS: "" + CMAKE_OPTIONS: "" + GENERATOR: Visual Studio 16 2019 + +init: + - cmake --version + - msbuild /version + +install: + - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip + - if "%COMPILER%"=="mingw" 7z x ninja.zip -oC:\projects\deps\ninja > nul + - if "%COMPILER%"=="mingw" set PATH=C:\projects\deps\ninja;%PATH% + - if "%COMPILER%"=="mingw" set PATH=C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% + - if "%COMPILER%"=="mingw" g++ --version + - if "%platform%"=="x86" set GENERATOR_PLATFORM=Win32 + +before_build: + # for with_win_header build, inject the inclusion of Windows.h to the single-header library + - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } + - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } + - if "%GENERATOR%"=="Ninja" (cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") else (cmake . -G "%GENERATOR%" -A "%GENERATOR_PLATFORM%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" -DJSON_BuildTests=On "%CMAKE_OPTIONS%") + +build_script: + - cmake --build . --config "%configuration%" + +test_script: + - if "%configuration%"=="Release" ctest -C "%configuration%" -V -j + # On Debug builds, skip test-unicode_all + # as it is extremely slow to run and cause + # occasional timeouts on AppVeyor. + # More info: https://github.com/nlohmann/json/pull/1570 + - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode" -C "%configuration%" -V -j From f7f75c8d2ad729fe136589ad3de1c5c2b7bbbe13 Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 19:45:15 +0500 Subject: [PATCH 6/8] Exclude test with std::variant when it's unavailable --- test/src/unit-regression1.cpp | 4 ---- test/src/unit-regression2.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/src/unit-regression1.cpp b/test/src/unit-regression1.cpp index 9dcc75b092..ff9ff6d8b5 100644 --- a/test/src/unit-regression1.cpp +++ b/test/src/unit-regression1.cpp @@ -47,10 +47,6 @@ using nlohmann::json; #define JSON_HAS_CPP_17 #endif -#ifdef JSON_HAS_CPP_17 - #include -#endif - #include "fifo_map.hpp" ///////////////////////////////////////////////////////////////////// diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index ca50cdd41d..c832f7d5a5 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -48,7 +48,10 @@ using nlohmann::json; #endif #ifdef JSON_HAS_CPP_17 - #include + #if __has_include() + #define HAS_STD_VARIANT + #include + #endif #endif ///////////////////////////////////////////////////////////////////// @@ -247,7 +250,7 @@ TEST_CASE("regression tests 2") CHECK(diffs.size() == 1); // Note the change here, was 2 } -#ifdef JSON_HAS_CPP_17 +#ifdef HAS_STD_VARIANT SECTION("issue #1292 - Serializing std::variant causes stack overflow") { static_assert( From 7b627c7bff60e9eb1286e464701ee5d0ab8ddcfc Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 20:17:56 +0500 Subject: [PATCH 7/8] Use old emplace_back even with C++17 clang-7 has old signature returning void --- single_include/nlohmann/json.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 2ba6c40512..7965b4857b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -21957,12 +21957,8 @@ class basic_json } // add element to array (perfect forwarding) -#ifdef JSON_HAS_CPP_17 - return m_value.array->emplace_back(std::forward(args)...); -#else m_value.array->emplace_back(std::forward(args)...); return m_value.array->back(); -#endif } /*! From 5f566f090b3f11f19e2e28c331de87f5836fe38d Mon Sep 17 00:00:00 2001 From: Alexander Karzhenkov Date: Fri, 21 Aug 2020 23:02:16 +0500 Subject: [PATCH 8/8] Synchronize single-header and basic variants of json.hpp --- include/nlohmann/json.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index e9bb1afd43..a82c1bed5c 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5432,12 +5432,8 @@ class basic_json } // add element to array (perfect forwarding) -#ifdef JSON_HAS_CPP_17 - return m_value.array->emplace_back(std::forward(args)...); -#else m_value.array->emplace_back(std::forward(args)...); return m_value.array->back(); -#endif } /*!