From cb1644b16ce6ff1d32554b43a78f6234734fe343 Mon Sep 17 00:00:00 2001 From: Terik23 Date: Tue, 27 Mar 2018 14:03:12 +0500 Subject: [PATCH] add ci --- .travis.yml | 22 ++++++++++++++++++++++ CMakeLists.txt | 2 ++ README.md | 4 ++++ appveyor.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ example/example.cpp | 3 ++- test/CMakeLists.txt | 4 +++- 6 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1709853 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,22 @@ +dist: trusty +sudo: required + +language: cpp + +os: + - linux + - osx + +compiler: + - g++ + - clang++ + +env: + - TARGET_CPU=amd64 BUILD_CONFIGURATION=Release + +script: + - mkdir build + - cd build + - cmake .. -DCMAKE_BUILD_TYPE=$BUILD_CONFIGURATION -DTARGET_CPU=$TARGET_CPU + - cmake --build . + - ctest -V --output-on-failure -ะก $BUILD_CONFIGURATION \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3302421..60846da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,5 +4,7 @@ project(nameof) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +enable_testing() + add_subdirectory(example) add_subdirectory(test) \ No newline at end of file diff --git a/README.md b/README.md index c1c2254..67fc36d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ C++ alternative to [nameof](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/nameof) operator. + Linux/OSX | Windows +-----------|--------- +[![Build Status](https://travis-ci.org/Terik23/nameof.svg?branch=master)](https://travis-ci.org/Terik23/nameof)|[![Build status](https://ci.appveyor.com/api/projects/status/4tyl8lee10ckw10k/branch/master?svg=true)](https://ci.appveyor.com/project/Terik23/nameof/branch/master) + Used to obtain the simple name of a variable, type, function. Before, you had to use string literals to refer to definitions, which is brittle when renaming code elements because tools do not know to check these string literals. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..e98158d --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,42 @@ +version: "{branch}#{build}" + +branches: + only: + - master + +image: Visual Studio 2017 + +platform: x64 + +configuration: Release + +shallow_clone: true + +matrix: + fast_finish: false + +environment: + matrix: + - PLATFORM: x64 + BUILDER: CMake + GENERATOR: "Visual Studio 15 2017 Win64" + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + - PLATFORM: x64 + BUILDER: CMake + GENERATOR: "Visual Studio 14 2015 Win64" + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + +init: + - ps: 'Write-Host "Building GEOS branch: $env:APPVEYOR_REPO_BRANCH" -ForegroundColor Magenta' + +before_build: + - ps: 'Write-Host "Running $env:BUILDER with $env:GENERATOR" -ForegroundColor Magenta' + - if "%BUILDER%"=="CMake" cmake.exe -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%CONFIGURATION% %APPVEYOR_BUILD_FOLDER% + +build_script: + - ps: 'Write-Host "Running $env:BUILDER:" -ForegroundColor Magenta' + - if "%BUILDER%"=="CMake" cmake --build . --config %CONFIGURATION% + +test_script: + - ps: 'Write-Host "Running tests:" -ForegroundColor Magenta' + - if "%BUILDER%"=="CMake" ctest -V --output-on-failure -C %CONFIGURATION% \ No newline at end of file diff --git a/example/example.cpp b/example/example.cpp index 77c2106..a38e314 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -21,8 +21,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include +#include +#include struct SomeStruct { int SomeField; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d672af5..c02faf5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,4 +6,6 @@ set(SRC 3rdparty/Catch2/catch.hpp ${CMAKE_SOURCE_DIR}/src/nameof.hpp) -add_executable(${PROJECT_NAME}_test ${SRC}) \ No newline at end of file +add_executable(${PROJECT_NAME}_test ${SRC}) + +add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test) \ No newline at end of file