2
0
mirror of https://github.com/boostorg/nowide.git synced 2026-02-15 01:02:17 +00:00

Add CI for CMake project + consumer test

This commit is contained in:
Flamefire
2019-12-14 19:05:37 +01:00
parent 3d6c001fc4
commit d357f7108f
4 changed files with 130 additions and 0 deletions

60
.github/workflows/ci_tests.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: CI Tests
on:
push:
pull_request:
jobs:
UnitTests:
strategy:
matrix:
os: [ubuntu-16.04, windows-latest]
buildType: [Debug, Release]
shared_lib: [ON, OFF]
generator: ['Visual Studio 16 2019', 'MinGW Makefiles', 'Unix Makefiles']
exclude:
- os: ubuntu-16.04
generator: MinGW Makefiles
- os: ubuntu-16.04
generator: Visual Studio 16 2019
- os: ubuntu-16.04
buildType: Debug
- os: windows-latest
generator: Unix Makefiles
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v1
# Install newer CMake to be able to find Boost
- name: Install CMake
if: runner.os == 'Linux' && ! matrix.standalone
run: wget -O- https://cmake.org/files/v3.14/cmake-3.14.0-Linux-x86_64.tar.gz | sudo tar --strip-components=1 -xzC /usr/local
- name: Build Boost
if: matrix.generator == 'MinGW Makefiles'
shell: bash
run: |
cd "${BOOST_ROOT}"
./bootstrap.sh --with-libraries=system,filesystem threading=multi
./b2 link=static variant=release -j$(nproc)
- name: Configure
working-directory: build
run: cmake .. -DBoost_ARCHITECTURE=-x64 -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DBUILD_SHARED_LIBS=${{matrix.shared_lib}} -DCMAKE_INSTALL_PREFIX=${{runner.workspace}}/../install -G "${{matrix.generator}}" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
- name: Build & Install
run: cmake --build build --config ${{matrix.buildType}} --target install
# Run test with both bash and powershell and watch for "Using std::cin" on bash but not on powershell
- name: Test
working-directory: build
shell: bash
run: ctest --output-on-failure -C ${{matrix.buildType}} --verbose
- name: Test on PowerShell
working-directory: build
shell: powershell
if: runner.os == 'Windows'
run: ctest --output-on-failure -C ${{matrix.buildType}} --verbose
- name: Test consumption
working-directory: build
shell: bash
run: |
rm -r *
cmake ../test/exampleProject -DBoost_ARCHITECTURE=-x64 -DCMAKE_PREFIX_PATH="${{runner.workspace}}/../install" -G "${{matrix.generator}}" -DCMAKE_SH="CMAKE_SH-NOTFOUND"
cmake --build . --config ${{matrix.buildType}}
ctest --output-on-failure -C ${{matrix.buildType}}

View File

@@ -12,6 +12,9 @@ branches:
- develop
- /feature\/.*/
matrix:
fast_finish: true
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
@@ -47,6 +50,17 @@ environment:
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03-gnu,11-gnu,14-gnu,1z-gnu
# CMake builds
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATOR: Visual Studio 14 2015 Win64
configuration: Debug
BOOST_ROOT: C:\Libraries\boost_1_60_0
CMAKE: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GENERATOR: Visual Studio 16 2019
configuration: Debug
BOOST_ROOT: C:\Libraries\boost_1_71_0
CMAKE: true
install:
- set BOOST_BRANCH=develop
@@ -67,3 +81,29 @@ test_script:
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/nowide/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
for:
- matrix:
only:
- CMAKE: true
install: true
before_build:
- if exist build\ (rmdir /S /Q build)
- set "INSTALL_DIR=%APPVEYOR_BUILD_FOLDER%\installed"
- if exist %INSTALL_DIR%\ (rmdir /S /Q %INSTALL_DIR%)
- mkdir build
- cd build
- cmake -G "%GENERATOR%" -DBOOST_NOWIDE_LAYOUT=versioned -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..
build:
project: build/boost_nowide.sln
parallel: true
test_script:
- ctest --output-on-failure -C %configuration% --parallel 4
# Build consumer example test
- cmake --build . --config %configuration% --target install
- del /F /S /Q *
- cmake ../test/exampleProject -G "%GENERATOR%" -DCMAKE_PREFIX_PATH=%APPVEYOR_BUILD_FOLDER%\installed
- cmake --build . --config %configuration%
- ctest --output-on-failure -C %configuration% --parallel 4

View File

@@ -0,0 +1,10 @@
# Project testing to consume Boost.Nowide
cmake_minimum_required(VERSION 3.8.0)
project(nowide_example_project)
find_package(boost_nowide 10.0 REQUIRED)
add_executable(example example_main.cpp)
target_link_libraries(example PRIVATE Boost::nowide)
enable_testing()
add_test(NAME example COMMAND example)

View File

@@ -0,0 +1,20 @@
//
// Copyright (c) 2019 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/nowide/args.hpp>
#include <boost/nowide/convert.hpp>
int main(int argc, char **argv, char **env)
{
boost::nowide::args _(argc, argv, env);
if(argc < 1)
return 1;
if(boost::nowide::narrow(boost::nowide::widen(argv[0])) != argv[0])
return 1;
return 0;
}