diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 2130e34..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -image: - - Visual Studio 2017 - - Visual Studio 2019 - -platform: - - x86 - - x64 - -configuration: - - Release - -for: - -- - matrix: - only: - - platform: x86 - configuration: Release - build_script: - - .ci\build_windows_x86.bat - -- - matrix: - only: - - platform: x64 - configuration: Release - build_script: - - .ci\build_windows_x64.bat diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..09e95e1 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,16 @@ +name: coverage + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-10.15 + name: "coverage" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install lcov by Homebrew + run: brew install lcov + - name: Build && Test && Upload + run: .ci/build_coverage.sh diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml new file mode 100644 index 0000000..07e86ea --- /dev/null +++ b/.github/workflows/darwin.yml @@ -0,0 +1,24 @@ +name: darwin + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/macos + - { os: "macos-10.15", xcode: "10.3" } + - { os: "macos-10.15", xcode: "11.7" } + - { os: "macos-10.15", xcode: "12.4" } + name: "xcode-${{matrix.config.xcode}}" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Select Xcode + run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app" + - name: Build && Test + run: .ci/build_darwin.sh diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..c785bc7 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,31 @@ +name: linux + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/linux + - { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" } + - { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" } + - { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" } + - { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" } + - { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" } + - { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" } + - { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" } + - { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" } + name: "${{matrix.config.cxx}}" + steps: + - name: Setup + run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}" + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Build && Test + run: .ci/build_linux.sh + env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" } diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..1486034 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,23 @@ +name: windows + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/win + - { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" } + - { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" } + - { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" } + - { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" } + name: "${{matrix.config.vs}} ${{matrix.config.arch}}" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Build && Test + run: .ci\build_windows_${{matrix.config.arch}}.bat diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 43462e1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,89 +0,0 @@ -git: - depth: false - quiet: true - -language: cpp - -jobs: - include: - - # - # linux (g++) - # - - - os: linux - dist: bionic - stage: linux - name: g++-7 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-7"] } } - env: CC=gcc-7 CXX=g++-7 - script: .ci/build_linux.sh - - - os: linux - dist: bionic - stage: linux - name: g++-8 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-8"] } } - env: CC=gcc-8 CXX=g++-8 - script: .ci/build_linux.sh - - # - # linux (clang++) - # - - - os: linux - dist: bionic - stage: linux - name: clang++-5.0 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-5.0"] } } - env: CC=clang-5.0 CXX=clang++-5.0 - script: .ci/build_linux.sh - - - os: linux - dist: bionic - stage: linux - name: clang++-6.0 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-6.0"] } } - env: CC=clang-6.0 CXX=clang++-6.0 - script: .ci/build_linux.sh - - # - # darwin - # - - - os: osx - osx_image: xcode10 - stage: darwin - name: xcode10 - script: .ci/build_darwin.sh - - - os: osx - osx_image: xcode11 - stage: darwin - name: xcode11 - script: .ci/build_darwin.sh - - # - # windows - # - - - os: windows - stage: windows - name: x86 - script: .ci/build_windows_x86.bat - - - os: windows - stage: windows - name: x64 - script: .ci/build_windows_x64.bat - - # - # coverage - # - - - os: osx - osx_image: xcode10 - stage: coverage - name: coverage - addons: { homebrew: { packages: ["lcov"], update: true } } - script: .ci/build_coverage.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 616c574..57fd977 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) if(NOT DEFINED PROJECT_NAME) set(BUILD_AS_STANDALONE ON) +else() + set(BUILD_AS_STANDALONE OFF) endif() project(promise.hpp) @@ -14,6 +16,15 @@ target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) find_package(Threads REQUIRED) target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads) +target_compile_options(${PROJECT_NAME} + INTERFACE + $<$,$>: + -Wno-c++98-compat-pedantic + -Wno-ctad-maybe-unsupported + -Wno-padded + -Wno-unknown-warning-option + -Wno-weak-vtables>) + if(BUILD_AS_STANDALONE) option(BUILD_WITH_UNTESTS "Build with unit tests" ON) if(BUILD_WITH_UNTESTS) diff --git a/README.md b/README.md index 2a957cb..b422701 100644 --- a/README.md +++ b/README.md @@ -2,33 +2,33 @@ > C++ asynchronous promises like a Promises/A+ -[![travis][badge.travis]][travis] -[![appveyor][badge.appveyor]][appveyor] +[![linux][badge.linux]][linux] +[![darwin][badge.darwin]][darwin] +[![windows][badge.windows]][windows] [![codecov][badge.codecov]][codecov] [![language][badge.language]][language] [![license][badge.license]][license] -[![paypal][badge.paypal]][paypal] -[badge.travis]: https://img.shields.io/travis/BlackMATov/promise.hpp/main.svg?logo=travis -[badge.appveyor]: https://img.shields.io/appveyor/ci/BlackMATov/promise-hpp/main.svg?logo=appveyor -[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/promise.hpp/main.svg?logo=codecov -[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg -[badge.license]: https://img.shields.io/badge/license-MIT-blue.svg -[badge.paypal]: https://img.shields.io/badge/donate-PayPal-orange.svg?logo=paypal&colorA=00457C +[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/promise.hpp/darwin/main?label=Xcode&logo=xcode +[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/promise.hpp/linux/main?label=GCC%2FClang&logo=linux +[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/promise.hpp/windows/main?label=Visual%20Studio&logo=visual-studio +[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/promise.hpp/main?logo=codecov +[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow +[badge.license]: https://img.shields.io/badge/license-MIT-blue -[travis]: https://travis-ci.org/BlackMATov/promise.hpp -[appveyor]: https://ci.appveyor.com/project/BlackMATov/promise-hpp +[darwin]: https://github.com/BlackMATov/promise.hpp/actions?query=workflow%3Adarwin +[linux]: https://github.com/BlackMATov/promise.hpp/actions?query=workflow%3Alinux +[windows]: https://github.com/BlackMATov/promise.hpp/actions?query=workflow%3Awindows [codecov]: https://codecov.io/gh/BlackMATov/promise.hpp [language]: https://en.wikipedia.org/wiki/C%2B%2B17 [license]: https://en.wikipedia.org/wiki/MIT_License -[paypal]: https://www.paypal.me/matov [promise]: https://github.com/BlackMATov/promise.hpp ## Requirements - [gcc](https://www.gnu.org/software/gcc/) **>= 7** -- [clang](https://clang.llvm.org/) **>= 5.0** +- [clang](https://clang.llvm.org/) **>= 7** - [msvc](https://visualstudio.microsoft.com/) **>= 2017** ## Installation diff --git a/untests/CMakeLists.txt b/untests/CMakeLists.txt index a656c78..71bf191 100644 --- a/untests/CMakeLists.txt +++ b/untests/CMakeLists.txt @@ -22,10 +22,17 @@ target_link_libraries(${PROJECT_NAME} promise.hpp) target_compile_options(${PROJECT_NAME} PRIVATE - $<$: - /W4 /bigobj> + $<$: /bigobj /wd4702>) + +target_compile_options(${PROJECT_NAME} PRIVATE - $<$,$,$>: - -Wall -Wextra -Wpedantic>) + $<$: + /WX /W4> + PRIVATE + $<$: + -Werror -Wall -Wextra -Wpedantic> + PRIVATE + $<$,$>: + -Werror -Weverything -Wconversion>) add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/untests/doctest/doctest.hpp b/untests/doctest/doctest.hpp index c1fc7ee..cf95de5 100644 --- a/untests/doctest/doctest.hpp +++ b/untests/doctest/doctest.hpp @@ -4,8 +4,8 @@ #define STATIC_REQUIRE(...)\ static_assert(__VA_ARGS__, #__VA_ARGS__);\ - REQUIRE(__VA_ARGS__); + REQUIRE(__VA_ARGS__) #define STATIC_REQUIRE_FALSE(...)\ static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\ - REQUIRE(!(__VA_ARGS__)); + REQUIRE(!(__VA_ARGS__)) diff --git a/untests/jobber_tests.cpp b/untests/jobber_tests.cpp index 687901a..5351cc6 100644 --- a/untests/jobber_tests.cpp +++ b/untests/jobber_tests.cpp @@ -60,16 +60,16 @@ TEST_CASE("jobber") { REQUIRE(v5 == 4); } { - const float pi = 3.14159265358979323846264338327950288f; + const double pi = 3.14159265358979323846264338327950288; jb::jobber j(1); - auto p0 = j.async([](float angle){ + auto p0 = j.async([](double angle){ return std::sin(angle); }, pi); - auto p1 = j.async([](float angle){ + auto p1 = j.async([](double angle){ return std::cos(angle); }, pi * 2); - REQUIRE(p0.get() == doctest::Approx(0.f).epsilon(0.01f)); - REQUIRE(p1.get() == doctest::Approx(1.f).epsilon(0.01f)); + REQUIRE(p0.get() == doctest::Approx(0.0).epsilon(0.01)); + REQUIRE(p1.get() == doctest::Approx(1.0).epsilon(0.01)); } { jb::jobber j(1); @@ -303,29 +303,29 @@ TEST_CASE("jobber") { jb::jobber j(2); jb::jobber g(2); - std::vector> jp(50); + std::vector> jp(50); for ( auto& jpi : jp ) { jpi = j.async([&g](){ - std::vector> gp(50); + std::vector> gp(50); for ( std::size_t i = 0; i < gp.size(); ++i ) { - gp[i] = g.async([](float angle){ + gp[i] = g.async([](double angle){ return std::sin(angle); - }, static_cast(i)); + }, static_cast(i)); } - return std::accumulate(gp.begin(), gp.end(), 0.f, - [](float r, jb::promise& f){ + return std::accumulate(gp.begin(), gp.end(), 0.0, + [](double r, jb::promise& f){ return r + f.get(); }); }); } - float r0 = std::accumulate(jp.begin(), jp.end(), 0.f, - [](float r, jb::promise& f){ + double r0 = std::accumulate(jp.begin(), jp.end(), 0.0, + [](double r, jb::promise& f){ return r + f.get(); }); - float r1 = 0.f; + double r1 = 0.0; for ( std::size_t i = 0; i < 50; ++i ) { - r1 += std::sin(static_cast(i)); + r1 += std::sin(static_cast(i)); } - REQUIRE(r0 == doctest::Approx(r1 * 50.f).epsilon(0.01f)); + REQUIRE(r0 == doctest::Approx(r1 * 50.0).epsilon(0.01)); } } diff --git a/untests/promise_tests.cpp b/untests/promise_tests.cpp index 6355ac3..d722d8b 100644 --- a/untests/promise_tests.cpp +++ b/untests/promise_tests.cpp @@ -1303,28 +1303,28 @@ TEST_CASE("promise") { } SUBCASE("then_tuple") { { - float check_42_float = 0.f; + double check_42_double = 0.0; pr::make_resolved_promise() .then_tuple([](){ return std::make_tuple( pr::make_resolved_promise(32), - pr::make_resolved_promise(10.f)); - }).then([&check_42_float](const std::tuple& t){ - check_42_float = std::get<0>(t) + std::get<1>(t); + pr::make_resolved_promise(10.0)); + }).then([&check_42_double](const std::tuple& t){ + check_42_double = std::get<0>(t) + std::get<1>(t); }); - REQUIRE(check_42_float == doctest::Approx(42.f).epsilon(0.01f)); + REQUIRE(check_42_double == doctest::Approx(42.0).epsilon(0.01)); } { - float check_42_float = 0.f; + double check_42_double = 0.0; pr::make_resolved_promise(42) .then_tuple([](int){ return std::make_tuple( pr::make_resolved_promise(32), - pr::make_resolved_promise(10.f)); - }).then([&check_42_float](const std::tuple& t){ - check_42_float = std::get<0>(t) + std::get<1>(t); + pr::make_resolved_promise(10.0)); + }).then([&check_42_double](const std::tuple& t){ + check_42_double = static_cast(std::get<0>(t)) + std::get<1>(t); }); - REQUIRE(check_42_float == doctest::Approx(42.f).epsilon(0.01f)); + REQUIRE(check_42_double == doctest::Approx(42.0).epsilon(0.01)); } { bool call_fail_with_logic_error = false;