From 3d9e1383feef9d94fbfbf44bc11fbb4c7146f805 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Fri, 30 Nov 2018 05:07:18 -0600 Subject: [PATCH] refactor: cmake setup (#23) * feat: Initial refactor of cmake Refactor cmake and project organization to be more modular and to better conform to best practices. * chore: Remove unused file * fix: Correct build errors Corrected tests link errors by reverting GTest back to hunter package instead of submodule. Removed Windows compile flags for /MT * fix: Added missing header * chore: Moved helpers to private header * fix: Made http public header * chore: Removed unused headers * fix: Remove unnecessary strings Changed tests to just compare native types instead of converting to strings when not needed. * fix: Fix PlatformIO builds Fixed PlatformIO builds to work with new folder structure. Removed submodule python script in favor of just ignoring the directory. This will allow desktop and IoT to better co-exist in the same source tree. Remove [common] section of test/platformio.ini as it did not seem to actually be respected. * fix: Remove old submodule * fix: Correct test binary path * fix: Corrected tests * chore: Added Windows build files to .gitignore * fix: Correct test where blocks can be a zero value * fix: Add missing macro Added missing adapter macro to GTest adapter. Will submit PR to AUnit library for proper fix. --- .circleci/script_desktop.sh | 2 +- .gitignore | 4 ++ .gitmodules | 7 +- CMakeLists.txt | 31 ++++----- platformio.ini | 4 +- src/CMakeLists.txt | 49 +++++++------- src/api/two/votes/two_votes.cpp | 1 + src/{ => include/cpp-client}/api/api.h | 0 src/{ => include/cpp-client}/api/api_base.h | 0 .../api/one/accounts/one_accounts.h | 0 .../cpp-client}/api/one/blocks/one_blocks.h | 1 - .../api/one/delegates/one_delegates.h | 1 - .../cpp-client}/api/one/loader/one_loader.h | 0 .../cpp-client}/api/one/one_api.h | 0 .../cpp-client}/api/one/one_paths.h | 0 .../cpp-client}/api/one/peers/one_peers.h | 1 - .../api/one/signatures/one_signatures.h | 0 .../api/one/transactions/one_transactions.h | 1 - .../cpp-client}/api/two/blocks/two_blocks.h | 1 - .../api/two/delegates/two_delegates.h | 1 - .../cpp-client}/api/two/node/two_node.h | 1 - .../cpp-client}/api/two/peers/two_peers.h | 1 - .../api/two/transactions/two_transactions.h | 1 - .../cpp-client}/api/two/two_api.h | 0 .../cpp-client}/api/two/two_paths.h | 0 .../cpp-client}/api/two/votes/two_votes.h | 1 - .../cpp-client}/api/two/wallets/two_wallets.h | 1 - src/{ => include/cpp-client}/arkClient.h | 0 .../cpp-client}/connection/connection.h | 0 src/{ => include/cpp-client}/http/http.h | 0 {include => src}/stl/array | 0 {include => src}/stl/cassert | 0 {include => src}/stl/cctype | 0 {include => src}/stl/cstddef | 0 {include => src}/stl/cstdint | 0 {include => src}/stl/cstdio | 0 {include => src}/stl/cstring | 0 {include => src}/stl/details/to_string.h | 0 {include => src}/stl/memory | 0 test/.travis.yml | 67 ------------------- test/CMakeLists.txt | 22 +++--- test/api/one/one_loader.cpp | 2 +- test/api/one/one_transactions.cpp | 2 +- test/api/two/two_blocks.cpp | 16 ++--- test/api/two/two_delegates.cpp | 2 +- test/api/two/two_peers.cpp | 4 +- test/api/two/two_wallets.cpp | 3 +- test/iot/gtest/gtest.h | 2 + test/{include => lib}/ArduinoJson | 0 test/lib/googletest | 1 + test/platformio.ini | 15 ++--- test/rm_submodules.py | 9 --- 52 files changed, 83 insertions(+), 171 deletions(-) rename src/{ => include/cpp-client}/api/api.h (100%) rename src/{ => include/cpp-client}/api/api_base.h (100%) rename src/{ => include/cpp-client}/api/one/accounts/one_accounts.h (100%) rename src/{ => include/cpp-client}/api/one/blocks/one_blocks.h (96%) rename src/{ => include/cpp-client}/api/one/delegates/one_delegates.h (96%) rename src/{ => include/cpp-client}/api/one/loader/one_loader.h (100%) rename src/{ => include/cpp-client}/api/one/one_api.h (100%) rename src/{ => include/cpp-client}/api/one/one_paths.h (100%) rename src/{ => include/cpp-client}/api/one/peers/one_peers.h (95%) rename src/{ => include/cpp-client}/api/one/signatures/one_signatures.h (100%) rename src/{ => include/cpp-client}/api/one/transactions/one_transactions.h (96%) rename src/{ => include/cpp-client}/api/two/blocks/two_blocks.h (96%) rename src/{ => include/cpp-client}/api/two/delegates/two_delegates.h (96%) rename src/{ => include/cpp-client}/api/two/node/two_node.h (94%) rename src/{ => include/cpp-client}/api/two/peers/two_peers.h (95%) rename src/{ => include/cpp-client}/api/two/transactions/two_transactions.h (96%) rename src/{ => include/cpp-client}/api/two/two_api.h (100%) rename src/{ => include/cpp-client}/api/two/two_paths.h (100%) rename src/{ => include/cpp-client}/api/two/votes/two_votes.h (95%) rename src/{ => include/cpp-client}/api/two/wallets/two_wallets.h (97%) rename src/{ => include/cpp-client}/arkClient.h (100%) rename src/{ => include/cpp-client}/connection/connection.h (100%) rename src/{ => include/cpp-client}/http/http.h (100%) rename {include => src}/stl/array (100%) rename {include => src}/stl/cassert (100%) rename {include => src}/stl/cctype (100%) rename {include => src}/stl/cstddef (100%) rename {include => src}/stl/cstdint (100%) rename {include => src}/stl/cstdio (100%) rename {include => src}/stl/cstring (100%) rename {include => src}/stl/details/to_string.h (100%) rename {include => src}/stl/memory (100%) delete mode 100644 test/.travis.yml rename test/{include => lib}/ArduinoJson (100%) create mode 160000 test/lib/googletest delete mode 100644 test/rm_submodules.py diff --git a/.circleci/script_desktop.sh b/.circleci/script_desktop.sh index f47e0ac9..abfdd9b0 100644 --- a/.circleci/script_desktop.sh +++ b/.circleci/script_desktop.sh @@ -3,4 +3,4 @@ cmake . -DCMAKE_BUILD_TYPE=Coverage cmake --build . # run Gtest -./bin/Ark-Cpp-Client-tests +./test/Ark-Cpp-Client-tests diff --git a/.gitignore b/.gitignore index 30948b8d..b9a96763 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,7 @@ /ALL_BUILD.vcxproj.filters /ALL_BUILD.vcxproj /src/Win32 +/test/Debug +/src/Debug +/test/Release +/src/Release diff --git a/.gitmodules b/.gitmodules index 2b5ceab2..14949f5e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ -[submodule "test/include/ArduinoJson"] - path = test/include/ArduinoJson +[submodule "test/lib/ArduinoJson"] + path = test/lib/ArduinoJson url = https://github.com/bblanchon/ArduinoJson +[submodule "test/lib/googletest"] + path = test/lib/googletest + url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a0e8f1e0..96e01f04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.2.2) + set(HUNTER_STATUS_DEBUG ON) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/toolchain.cmake") @@ -8,35 +9,27 @@ HunterGate( URL "https://github.com/ruslo/hunter/archive/v0.23.29.tar.gz" SHA1 "797be99a8a4f4666766257563fad8aa3aa032da2" ) - project(Ark-Cpp-Client) -set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin) - -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib) - -set(PROJECT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/test/include) +set(CMAKE_CXX_STANDARD 11) -# clone submodules -execute_process( - COMMAND git submodule update --init --recursive - WORKING_DIRECTORY ${PROJECT_INCLUDE_DIR} -) +set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}) if (MSVC) - add_definitions( - -D_CRT_SECURE_NO_WARNINGS + add_definitions( + -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DNOMINMAX ) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") -elseif (UNIX) - set (CMAKE_CXX_FLAGS "-std=c++11") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") endif() -include_directories("${PROJECT_SOURCE_DIR}") +# clone submodules +execute_process( + COMMAND git submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +) add_subdirectory(src) add_subdirectory(test) + diff --git a/platformio.ini b/platformio.ini index 32a89bcf..8a971b8b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ platform = espressif8266 board = huzzah framework = arduino -build_flags = -I./src/ +build_flags = -I./src/ -I./src/include/cpp-client src_filter = +<*> -<.git/> - - - - -<_3rdParty> - upload_speed = 921600 @@ -22,6 +22,6 @@ upload_speed = 921600 platform = espressif32 board = esp32dev framework = arduino -build_flags = -I./src/ +build_flags = -I./src/ -I./src/include/cpp-client src_filter = +<*> -<.git/> - - - - -<_3rdParty> - upload_speed = 921600 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bcb4ece..4fa1d6a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,35 +3,31 @@ cmake_minimum_required(VERSION 3.2.2) project(Ark-Cpp-Client-lib) -set (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${PROJECT_SOURCE_DIR}) - hunter_add_package(CURL) find_package(CURL CONFIG REQUIRED) set(PLATFORM_SRC - ${PROJECT_SOURCE_DIR}/http/os/http.cpp + http/os/http.cpp ) set(API_ONE_SRC - ${PROJECT_SOURCE_DIR}/api/one/accounts/one_accounts.cpp - ${PROJECT_SOURCE_DIR}/api/one/blocks/one_blocks.cpp - ${PROJECT_SOURCE_DIR}/api/one/delegates/one_delegates.cpp - ${PROJECT_SOURCE_DIR}/api/one/loader/one_loader.cpp - ${PROJECT_SOURCE_DIR}/api/one/peers/one_peers.cpp - ${PROJECT_SOURCE_DIR}/api/one/signatures/one_signatures.cpp - ${PROJECT_SOURCE_DIR}/api/one/transactions/one_transactions.cpp + api/one/accounts/one_accounts.cpp + api/one/blocks/one_blocks.cpp + api/one/delegates/one_delegates.cpp + api/one/loader/one_loader.cpp + api/one/peers/one_peers.cpp + api/one/signatures/one_signatures.cpp + api/one/transactions/one_transactions.cpp ) set(API_TWO_SRC - ${PROJECT_SOURCE_DIR}/api/two/blocks/two_blocks.cpp - ${PROJECT_SOURCE_DIR}/api/two/delegates/two_delegates.cpp - ${PROJECT_SOURCE_DIR}/api/two/node/two_node.cpp - ${PROJECT_SOURCE_DIR}/api/two/peers/two_peers.cpp - ${PROJECT_SOURCE_DIR}/api/two/transactions/two_transactions.cpp - ${PROJECT_SOURCE_DIR}/api/two/votes/two_votes.cpp - ${PROJECT_SOURCE_DIR}/api/two/wallets/two_wallets.cpp + api/two/blocks/two_blocks.cpp + api/two/delegates/two_delegates.cpp + api/two/node/two_node.cpp + api/two/peers/two_peers.cpp + api/two/transactions/two_transactions.cpp + api/two/votes/two_votes.cpp + api/two/wallets/two_wallets.cpp ) add_library(Ark-Cpp-Client-lib STATIC @@ -40,11 +36,18 @@ add_library(Ark-Cpp-Client-lib STATIC ${API_TWO_SRC} ) -target_link_libraries(Ark-Cpp-Client-lib - PUBLIC - CURL::libcurl +set(cpp_client_build_include_dirs + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include/cpp-client +) +include_directories(${cpp_client_build_include_dirs}) + +target_include_directories( ${PROJECT_NAME} + PUBLIC ${cpp_client_build_include_dirs} ) +target_link_libraries(${PROJECT_NAME} PUBLIC CURL::libcurl) + if (MSVC) - target_link_libraries(Ark-Cpp-Client-lib PUBLIC crypt32) + target_link_libraries(${PROJECT_NAME} PUBLIC crypt32) endif() diff --git a/src/api/two/votes/two_votes.cpp b/src/api/two/votes/two_votes.cpp index 5aa340e1..565efa9c 100644 --- a/src/api/two/votes/two_votes.cpp +++ b/src/api/two/votes/two_votes.cpp @@ -2,6 +2,7 @@ #include "api/two/votes/two_votes.h" #include +#include std::string Ark::Client::API::TWO::Votes::get(const char *const identifier) { diff --git a/src/api/api.h b/src/include/cpp-client/api/api.h similarity index 100% rename from src/api/api.h rename to src/include/cpp-client/api/api.h diff --git a/src/api/api_base.h b/src/include/cpp-client/api/api_base.h similarity index 100% rename from src/api/api_base.h rename to src/include/cpp-client/api/api_base.h diff --git a/src/api/one/accounts/one_accounts.h b/src/include/cpp-client/api/one/accounts/one_accounts.h similarity index 100% rename from src/api/one/accounts/one_accounts.h rename to src/include/cpp-client/api/one/accounts/one_accounts.h diff --git a/src/api/one/blocks/one_blocks.h b/src/include/cpp-client/api/one/blocks/one_blocks.h similarity index 96% rename from src/api/one/blocks/one_blocks.h rename to src/include/cpp-client/api/one/blocks/one_blocks.h index 8f344010..66bedecc 100644 --- a/src/api/one/blocks/one_blocks.h +++ b/src/include/cpp-client/api/one/blocks/one_blocks.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/one/one_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/one/delegates/one_delegates.h b/src/include/cpp-client/api/one/delegates/one_delegates.h similarity index 96% rename from src/api/one/delegates/one_delegates.h rename to src/include/cpp-client/api/one/delegates/one_delegates.h index 02cb8228..6d610a69 100644 --- a/src/api/one/delegates/one_delegates.h +++ b/src/include/cpp-client/api/one/delegates/one_delegates.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/one/one_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/one/loader/one_loader.h b/src/include/cpp-client/api/one/loader/one_loader.h similarity index 100% rename from src/api/one/loader/one_loader.h rename to src/include/cpp-client/api/one/loader/one_loader.h diff --git a/src/api/one/one_api.h b/src/include/cpp-client/api/one/one_api.h similarity index 100% rename from src/api/one/one_api.h rename to src/include/cpp-client/api/one/one_api.h diff --git a/src/api/one/one_paths.h b/src/include/cpp-client/api/one/one_paths.h similarity index 100% rename from src/api/one/one_paths.h rename to src/include/cpp-client/api/one/one_paths.h diff --git a/src/api/one/peers/one_peers.h b/src/include/cpp-client/api/one/peers/one_peers.h similarity index 95% rename from src/api/one/peers/one_peers.h rename to src/include/cpp-client/api/one/peers/one_peers.h index 4f41bbd8..2e289349 100644 --- a/src/api/one/peers/one_peers.h +++ b/src/include/cpp-client/api/one/peers/one_peers.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/one/one_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/one/signatures/one_signatures.h b/src/include/cpp-client/api/one/signatures/one_signatures.h similarity index 100% rename from src/api/one/signatures/one_signatures.h rename to src/include/cpp-client/api/one/signatures/one_signatures.h diff --git a/src/api/one/transactions/one_transactions.h b/src/include/cpp-client/api/one/transactions/one_transactions.h similarity index 96% rename from src/api/one/transactions/one_transactions.h rename to src/include/cpp-client/api/one/transactions/one_transactions.h index cca881f6..7e493423 100644 --- a/src/api/one/transactions/one_transactions.h +++ b/src/include/cpp-client/api/one/transactions/one_transactions.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/one/one_paths.h" -#include "helpers/helpers.h" #include namespace Ark { diff --git a/src/api/two/blocks/two_blocks.h b/src/include/cpp-client/api/two/blocks/two_blocks.h similarity index 96% rename from src/api/two/blocks/two_blocks.h rename to src/include/cpp-client/api/two/blocks/two_blocks.h index 87e8b57b..4762e9b8 100644 --- a/src/api/two/blocks/two_blocks.h +++ b/src/include/cpp-client/api/two/blocks/two_blocks.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/delegates/two_delegates.h b/src/include/cpp-client/api/two/delegates/two_delegates.h similarity index 96% rename from src/api/two/delegates/two_delegates.h rename to src/include/cpp-client/api/two/delegates/two_delegates.h index 8305ba0e..5485e10f 100644 --- a/src/api/two/delegates/two_delegates.h +++ b/src/include/cpp-client/api/two/delegates/two_delegates.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/node/two_node.h b/src/include/cpp-client/api/two/node/two_node.h similarity index 94% rename from src/api/two/node/two_node.h rename to src/include/cpp-client/api/two/node/two_node.h index d661526a..936e0e76 100644 --- a/src/api/two/node/two_node.h +++ b/src/include/cpp-client/api/two/node/two_node.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/peers/two_peers.h b/src/include/cpp-client/api/two/peers/two_peers.h similarity index 95% rename from src/api/two/peers/two_peers.h rename to src/include/cpp-client/api/two/peers/two_peers.h index 00a60ca2..234d2eb0 100644 --- a/src/api/two/peers/two_peers.h +++ b/src/include/cpp-client/api/two/peers/two_peers.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/transactions/two_transactions.h b/src/include/cpp-client/api/two/transactions/two_transactions.h similarity index 96% rename from src/api/two/transactions/two_transactions.h rename to src/include/cpp-client/api/two/transactions/two_transactions.h index 90f74664..4cad3a75 100644 --- a/src/api/two/transactions/two_transactions.h +++ b/src/include/cpp-client/api/two/transactions/two_transactions.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/two_api.h b/src/include/cpp-client/api/two/two_api.h similarity index 100% rename from src/api/two/two_api.h rename to src/include/cpp-client/api/two/two_api.h diff --git a/src/api/two/two_paths.h b/src/include/cpp-client/api/two/two_paths.h similarity index 100% rename from src/api/two/two_paths.h rename to src/include/cpp-client/api/two/two_paths.h diff --git a/src/api/two/votes/two_votes.h b/src/include/cpp-client/api/two/votes/two_votes.h similarity index 95% rename from src/api/two/votes/two_votes.h rename to src/include/cpp-client/api/two/votes/two_votes.h index 6e3a0c8a..ec306fbd 100644 --- a/src/api/two/votes/two_votes.h +++ b/src/include/cpp-client/api/two/votes/two_votes.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" namespace Ark { namespace Client { diff --git a/src/api/two/wallets/two_wallets.h b/src/include/cpp-client/api/two/wallets/two_wallets.h similarity index 97% rename from src/api/two/wallets/two_wallets.h rename to src/include/cpp-client/api/two/wallets/two_wallets.h index 17bd1e16..c58d66d1 100644 --- a/src/api/two/wallets/two_wallets.h +++ b/src/include/cpp-client/api/two/wallets/two_wallets.h @@ -12,7 +12,6 @@ #include "api/api_base.h" #include "api/two/two_paths.h" -#include "helpers/helpers.h" #include namespace Ark { diff --git a/src/arkClient.h b/src/include/cpp-client/arkClient.h similarity index 100% rename from src/arkClient.h rename to src/include/cpp-client/arkClient.h diff --git a/src/connection/connection.h b/src/include/cpp-client/connection/connection.h similarity index 100% rename from src/connection/connection.h rename to src/include/cpp-client/connection/connection.h diff --git a/src/http/http.h b/src/include/cpp-client/http/http.h similarity index 100% rename from src/http/http.h rename to src/include/cpp-client/http/http.h diff --git a/include/stl/array b/src/stl/array similarity index 100% rename from include/stl/array rename to src/stl/array diff --git a/include/stl/cassert b/src/stl/cassert similarity index 100% rename from include/stl/cassert rename to src/stl/cassert diff --git a/include/stl/cctype b/src/stl/cctype similarity index 100% rename from include/stl/cctype rename to src/stl/cctype diff --git a/include/stl/cstddef b/src/stl/cstddef similarity index 100% rename from include/stl/cstddef rename to src/stl/cstddef diff --git a/include/stl/cstdint b/src/stl/cstdint similarity index 100% rename from include/stl/cstdint rename to src/stl/cstdint diff --git a/include/stl/cstdio b/src/stl/cstdio similarity index 100% rename from include/stl/cstdio rename to src/stl/cstdio diff --git a/include/stl/cstring b/src/stl/cstring similarity index 100% rename from include/stl/cstring rename to src/stl/cstring diff --git a/include/stl/details/to_string.h b/src/stl/details/to_string.h similarity index 100% rename from include/stl/details/to_string.h rename to src/stl/details/to_string.h diff --git a/include/stl/memory b/src/stl/memory similarity index 100% rename from include/stl/memory rename to src/stl/memory diff --git a/test/.travis.yml b/test/.travis.yml deleted file mode 100644 index 9443843a..00000000 --- a/test/.travis.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Continuous Integration (CI) is the practice, in software -# engineering, of merging all developer working copies with a shared mainline -# several times a day < http://docs.platformio.org/page/ci/index.html > -# -# Documentation: -# -# * Travis CI Embedded Builds with PlatformIO -# < https://docs.travis-ci.com/user/integration/platformio/ > -# -# * PlatformIO integration with Travis CI -# < http://docs.platformio.org/page/ci/travis.html > -# -# * User Guide for `platformio ci` command -# < http://docs.platformio.org/page/userguide/cmd_ci.html > -# -# -# Please choice one of the following templates (proposed below) and uncomment -# it (remove "# " before each line) or use own configuration according to the -# Travis CI documentation (see above). -# - - -# -# Template #1: General project. Test it using existing `platformio.ini`. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio run - - -# -# Template #2: The project is intended to by used as a library with examples -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# env: -# - PLATFORMIO_CI_SRC=path/to/test/file.c -# - PLATFORMIO_CI_SRC=examples/file.ino -# - PLATFORMIO_CI_SRC=path/to/test/directory -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0a4cd36..7d7270fd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,7 +14,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../lib") include_directories(${PROJECT_SOURCE_DIR}/../src) include_directories(${PROJECT_SOURCE_DIR}/../test) -include_directories(${PROJECT_SOURCE_DIR}/include/ArduinoJson) +include_directories(${PROJECT_SOURCE_DIR}/lib/ArduinoJson) include_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(TEST_API_SRC @@ -41,10 +41,7 @@ set(TEST_TWO_SRC ${PROJECT_SOURCE_DIR}/api/two/two_wallets.cpp ) -find_library(Ark-Cpp-Client-tests - NAMES Ark-Cpp-Client-lib - PATHS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -) +find_library(Ark-Cpp-Client-tests PUBLIC) add_executable(Ark-Cpp-Client-tests ${TEST_API_SRC} @@ -52,19 +49,16 @@ add_executable(Ark-Cpp-Client-tests ${TEST_TWO_SRC} ) -target_link_libraries(Ark-Cpp-Client-tests Ark-Cpp-Client-lib) - -target_link_libraries(Ark-Cpp-Client-tests GTest::main) # GTest::gtest will be linked automatically -target_link_libraries(Ark-Cpp-Client-tests GTest::gtest) +target_link_libraries(Ark-Cpp-Client-tests Ark-Cpp-Client-lib GTest::gtest GTest::main) add_test(NAME test COMMAND Ark-Cpp-Client-tests) if (CMAKE_BUILD_TYPE STREQUAL "Coverage") - include("${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake") + include("${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake") - setup_target_for_coverage(${PROJECT_NAME}_coverage Ark-Cpp-Client-tests coverage) + setup_target_for_coverage(${PROJECT_NAME}_coverage Ark-Cpp-Client-tests coverage) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage" + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage" diff --git a/test/api/one/one_loader.cpp b/test/api/one/one_loader.cpp index f3b5c638..6a5f3dc5 100644 --- a/test/api/one/one_loader.cpp +++ b/test/api/one/one_loader.cpp @@ -72,7 +72,7 @@ TEST(api, test_one_loader_sync) ASSERT_FALSE(syncing); int blocks = root["blocks"]; - ASSERT_STRNE("", std::to_string(blocks).c_str()); + ASSERT_GE(0, blocks); int height = root["height"]; ASSERT_NE(0, height); diff --git a/test/api/one/one_transactions.cpp b/test/api/one/one_transactions.cpp index 1704085d..7ae53ed0 100644 --- a/test/api/one/one_transactions.cpp +++ b/test/api/one/one_transactions.cpp @@ -30,7 +30,7 @@ TEST(api, test_one_transactions_transaction) ASSERT_STREQ("4115750139916005265", blockid); int height = transaction["height"]; - ASSERT_STREQ("2695914", std::to_string(height).c_str()); + ASSERT_EQ(2695914, height); int type = transaction["type"]; ASSERT_EQ(0, type); diff --git a/test/api/two/two_blocks.cpp b/test/api/two/two_blocks.cpp index 17fd6310..5465f0dc 100644 --- a/test/api/two/two_blocks.cpp +++ b/test/api/two/two_blocks.cpp @@ -54,7 +54,7 @@ TEST(api, test_two_block) ASSERT_STREQ("13114381566690093367", id); int version = data["version"]; - ASSERT_STREQ("0", std::to_string(version).c_str()); + ASSERT_EQ(0, version); int height = data["height"]; ASSERT_EQ(1, height); @@ -170,13 +170,13 @@ TEST(api, test_two_block_transactions) JsonObject& dataZero = root["data"][0]; int id = dataZero["id"]; - ASSERT_STRNE("", std::to_string(id).c_str()); + ASSERT_EQ(0, id); const char* blockId = dataZero["blockId"]; ASSERT_STRNE("", blockId); int type = dataZero["type"]; - ASSERT_STRNE("", std::to_string(type).c_str()); + ASSERT_EQ(0, type); uint64_t amount = dataZero["amount"]; ASSERT_TRUE(amount >= 0); @@ -191,16 +191,16 @@ TEST(api, test_two_block_transactions) ASSERT_STRNE("", signature); int confirmations = dataZero["confirmations"]; - ASSERT_STRNE("", std::to_string(confirmations).c_str()); + ASSERT_EQ(0, confirmations); JsonObject& timestamp = dataZero["timestamp"]; int epoch = timestamp["epoch"]; - ASSERT_STRNE("", std::to_string(epoch).c_str()); + ASSERT_EQ(0, epoch); int timestampUnix = timestamp["unix"]; - ASSERT_STRNE("", std::to_string(timestampUnix).c_str()); + ASSERT_EQ(0, timestampUnix); const char* human = timestamp["human"]; ASSERT_STRNE("", human); @@ -278,7 +278,7 @@ TEST(api, test_two_blocks) JsonObject& dataZero = root["data"][0]; int version = dataZero["version"]; - ASSERT_STRNE("", std::to_string(version).c_str()); + ASSERT_EQ(0, version); } /* test_two_blocks_blocks_limit_page @@ -354,7 +354,7 @@ TEST(api, test_two_blocks_limit_page) JsonObject& dataZero = root["data"][0]; int version = dataZero["version"]; - ASSERT_STRNE("", std::to_string(version).c_str()); + ASSERT_EQ(0, version); } /* test_two_blocks_search diff --git a/test/api/two/two_delegates.cpp b/test/api/two/two_delegates.cpp index 8d5efa21..c50e700f 100644 --- a/test/api/two/two_delegates.cpp +++ b/test/api/two/two_delegates.cpp @@ -159,7 +159,7 @@ TEST(api, test_two_delegate_blocks) ASSERT_STRNE("", id); int version = root["data"][0]["version"]; - ASSERT_STRNE("", std::to_string(version).c_str()); + ASSERT_EQ(0, version); uint64_t height = root["data"][0]["height"]; ASSERT_TRUE(height >= 0); diff --git a/test/api/two/two_peers.cpp b/test/api/two/two_peers.cpp index 7b643e9f..436eb78a 100644 --- a/test/api/two/two_peers.cpp +++ b/test/api/two/two_peers.cpp @@ -47,7 +47,7 @@ TEST(api, test_two_peer) ASSERT_STREQ("linux", os); int latency = data["latency"]; - ASSERT_STRNE("", std::to_string(latency).c_str()); + ASSERT_NE(0, latency); } /* test_two_peers_peers @@ -115,5 +115,5 @@ TEST(api, test_two_peers) ASSERT_STRNE("", os); int latency = dataZero["latency"]; - ASSERT_STRNE("", std::to_string(latency).c_str()); + ASSERT_NE(0, latency); } diff --git a/test/api/two/two_wallets.cpp b/test/api/two/two_wallets.cpp index 4fdcde06..1e56d87e 100644 --- a/test/api/two/two_wallets.cpp +++ b/test/api/two/two_wallets.cpp @@ -223,7 +223,8 @@ TEST(api, test_two_wallets_top) ASSERT_TRUE(balance >= 0); bool isDelegate = dataZero["isDelegate"]; - ASSERT_STRNE("", std::to_string(isDelegate).c_str()); + // as long as data was read, we don't really care (or know) what the expected value is + ASSERT_TRUE(isDelegate || !isDelegate); } /* test_two_wallets_transactions diff --git a/test/iot/gtest/gtest.h b/test/iot/gtest/gtest.h index 55752bcc..5a4c6499 100644 --- a/test/iot/gtest/gtest.h +++ b/test/iot/gtest/gtest.h @@ -6,4 +6,6 @@ #include #include +#define ASSERT_GE(e, a) assertMoreOrEqual(static_cast(e), a) + #endif diff --git a/test/include/ArduinoJson b/test/lib/ArduinoJson similarity index 100% rename from test/include/ArduinoJson rename to test/lib/ArduinoJson diff --git a/test/lib/googletest b/test/lib/googletest new file mode 160000 index 00000000..3cf8f514 --- /dev/null +++ b/test/lib/googletest @@ -0,0 +1 @@ +Subproject commit 3cf8f514d859d65b7202e51c662a03a92887b8e2 diff --git a/test/platformio.ini b/test/platformio.ini index 7d54170d..d7868c73 100644 --- a/test/platformio.ini +++ b/test/platformio.ini @@ -12,23 +12,20 @@ src_dir = .. lib_dir = .. -[common] -lib_deps = ArduinoJson@5.13.2, AUnit - [env:esp8266] +lib_deps = ArduinoJson, AUnit platform = espressif8266 board = huzzah framework = arduino -build_flags = -I../test/iot/ -DUNIT_TEST -src_filter = +<*> -<.git/> - - - - -<../src/http/os/> -<_3rdParty> - -extra_scripts = pre:rm_submodules.py +build_flags = -I../test/iot/ -I../test -I../src -I../src/include/cpp-client -DUNIT_TEST +src_filter = +<*> -<.git/> - - - - -<../src/http/os/> -<_3rdParty> - - - upload_speed = 921600 [env:esp32] +lib_deps = ArduinoJson, AUnit platform = espressif32 board = esp32dev framework = arduino -build_flags = -I../test/iot/ -DUNIT_TEST -src_filter = +<*> -<.git/> - - - - -<../src/http/os/> -<_3rdParty> - -extra_scripts = pre:rm_submodules.py +build_flags = -I../test/iot/ -I../test -I../src -I../src/include/cpp-client -DUNIT_TEST +src_filter = +<*> -<.git/> - - - - -<../src/http/os/> -<_3rdParty> - - - upload_speed = 921600 diff --git a/test/rm_submodules.py b/test/rm_submodules.py deleted file mode 100644 index 6dff22f4..00000000 --- a/test/rm_submodules.py +++ /dev/null @@ -1,9 +0,0 @@ -Import("env") -import os -import shutil - -for root, dirs, files in os.walk('../test/include/ArduinoJson'): - for f in files: - os.unlink(os.path.join(root, f)) - for d in dirs: - shutil.rmtree(os.path.join(root, d))