Skip to content

Commit

Permalink
[azure-pipeline] test integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Raffaello committed May 12, 2020
1 parent bc01dfa commit 3e2f271
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 40 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ include(CPack)
option(BUILD_SHARED_LIBS "build shared libs with C inteface" ON)
option(BUILD_EXAMPLES "build examples" ON)
include(CTest)
option(ENABLE_CODECOVERAGE "compile Debug with code coverage" OFF)
option(BUILD_SNAPSHOT "build snapshot test" OFF)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(TEST_DUMP_SNAPSHOT "build test to dump the expected output instead of verifing it" OFF
Expand Down
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ branches:
skip_branch_with_pr: false

image:
- Visual Studio 2019
- Ubuntu
#- Visual Studio 2019
#- Ubuntu
- macOS

platform:
Expand Down Expand Up @@ -54,6 +54,9 @@ for:
- sh: brew install p7zip
- sh: cd $WS && git clone https://github.com/Microsoft/vcpkg.git
- sh: cd $APPVEYOR_BUILD_FOLDER
# /Library/Developer/CommandLineTools/usr/bin/llvm-cov
#- sh: sudo find / -name llvm-cov 2> /dev/null
- sh: llvm-cov --help
test_script:
- sh: ctest -V

Expand Down
13 changes: 12 additions & 1 deletion azure-pipelines/templates/ci-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,20 @@ steps:
arch: ${{ parameters.arch }}
#build_wrapper:
- ${{ if eq(parameters.test, true) }}:
- script: ctest -C ${{ parameters.build_type }} -V
- script: ctest -C ${{ parameters.build_type }} -v -V -T Test
displayName: cmake test (ctest)
workingDirectory: build
- task: PublishTestResults@2
inputs:
testResultsFormat: 'cTest' # Options: JUnit, NUnit, VSTest, xUnit, cTest
testResultsFiles: '**/Test.xml'
searchFolder: build # Optional
#mergeTestResults: false # Optional
#failTaskOnFailedTests: false # Optional
#testRunTitle: # Optional
#buildPlatform: # Optional
#buildConfiguration: # Optional
#publishRunAttachments: true # Optional

- ${{ if eq(parameters.install, true) }}:
- script: cmake --build . --target install
Expand Down
25 changes: 22 additions & 3 deletions azure-pipelines/templates/sonarcloud-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,31 @@ jobs:
build_wrapper: "${{ parameters.build_wrapper }} --out-dir bw-output"

- ${{ if eq(parameters.test, true) }}:
- script: ctest -C ${{ parameters.build_type }} -V
displayName: cmake test (ctest)
- script: ctest -C ${{ parameters.build_type }}
displayName: ctest
workingDirectory: build
- bash: llvm-cov gcov -f -b -u $(find . -name *.gcda)
# /usr/local/Cellar/llvm/10.0.0_3/bin/llvm-cov
- bash: |
echo '#!/bin/bash' > g.sh
echo 'exec /usr/local/Cellar/llvm/10.0.0_3/bin/llvm-cov gcov "$@"' >> g.sh
chmod +x g.sh
displayName: llvm-cov gcov wrapper
workingDirectory: build
condition: ne(variables['Agent.OS'], 'Windows_NT')
#- bash: sudo find / -name llvm-cov 2> /dev/null
# displayName: llvm-cov DEBUG
# condition: ne(variables['Agent.OS'], 'Windows_NT')
- bash: |
test $OSTYPE = "Darwin" && brew install lcov || echo "not implemented"
./g.sh -f -b -u $(find . -name *.gcda)
lcov --directory . --base-directory . --gcov-tool ./g.sh --capture -o cov.info
lcov --remove cov.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
bash <(curl -s https://codecov.io/bash) -t b8f07100-6985-49f7-aa4c-14e36f29ac80
displayName: collect coverage data
workingDirectory: build
condition: ne(variables['Agent.OS'], 'Windows_NT')
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
inputs:
Expand Down
1 change: 1 addition & 0 deletions azure-pipelines/variables/build_switches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ variables:
BUILD_SHARED_LIBS: ON
BUILD_EXAMPLES: ON
BUILD_SNAPSHOT: OFF
ENABLE_CODE_COVERAGE: OFF
1 change: 1 addition & 0 deletions azure-pipelines/win-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ stages:
variables:
BUILD_EXAMPLES: OFF
BUILD_SHARED_LIBS: OFF
ENABLE_CODE_COVERAGE: ON
jobs:
# - template: 'templates/sonarcloud-job.yml'
# parameters:
Expand Down
65 changes: 31 additions & 34 deletions sdl2-vga-terminal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,35 @@ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "^MSVC")
# @see https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category?view=vs-2019

target_compile_options(vga-terminal-static PUBLIC /W4 /WX
target_compile_options(vga-terminal-static PRIVATE /W4 #/WX
$<$<CONFIG:DEBUG>:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL>
$<$<CONFIG:RELEASE>:/O2 /Ot /GA /GL /Gw>
)
#if (BUILD_SHARED_LIBS)
# target_compile_options(vga-terminal PRIVATE /W4 /WX
# $<$<CONFIG:DEBUG>:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL>
# $<$<CONFIG:RELEASE>:/O2 /Ot /GA /GL /Gw>
# )
#endif()
if (BUILD_SHARED_LIBS)
target_compile_options(vga-terminal PRIVATE /W4 #/WX
$<$<CONFIG:DEBUG>:/Od /GR /GS /Gs /guard:cf /RTC1c /D_ALLOW_RTCc_IN_STL>
$<$<CONFIG:RELEASE>:/O2 /Ot /GA /GL /Gw>
)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU")
target_compile_options(vga-terminal-static PUBLIC -Wall -Wextra -pedantic -fPIC
target_compile_options(vga-terminal-static PRIVATE -Wall -Wextra -pedantic -fPIC
$<$<CONFIG:DEBUG>:
-O0;-D_GLIBCXX_DEBUG;-D_GLIBCXX_ASSERTIONS;-fexceptions;
-W; -Wshadow; -Wunused-variable;
-Wunused-parameter; -Wunused-function; -Wunused; -Wno-system-headers;
-Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings; -fprofile-arcs; -ftest-coverage;
-Wno-deprecated; -Woverloaded-virtual; -Wwrite-strings;
>
#$<$<CONFIG:RELEASE>:-O2;-fexceptions;-fstack-clash-protection;-D_FORTIFY_SOURCE=2>
$<$<CONFIG:RELEASE>:-O2;-fexceptions;-D_FORTIFY_SOURCE=2>
) #-Werror)
target_link_options(vga-terminal-static INTERFACE $<$<CONFIG:DEBUG>:-fprofile-arcs; -ftest-coverage; --coverage;>)

if (ENABLE_CODE_COVERAGE)
target_compile_options(vga-terminal-static PRIVATE
$<$<CONFIG:DEBUG>: -fprofile-arcs; -ftest-coverage;>
)
target_link_options(vga-terminal-static PRIVATE $<$<CONFIG:DEBUG>:-fprofile-arcs; -ftest-coverage; --coverage;>)
endif()

#if (BUILD_SHARED_LIBS)
# target_compile_options(vga-terminal INTERAFCE
# $<$<CONFIG:DEBUG>:
Expand All @@ -190,36 +197,26 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "^GNU")

elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang")
target_compile_options(vga-terminal-static PRIVATE -WCL4 -Wabstract-vbase-init -Wassign-enum
-Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal
-fPIC
$<$<CONFIG:DEBUG>:
-g;
>
$<$<CONFIG:RELEASE>:
-O2;
>
) #-Weverything #-Werror


### This if Clang is shipped with VS2019 CE
-Watomic-implicit-seq-cst -Watomic-properties -Wbad-function-cast -Wbinary-literal
)

if (WIN32)
set(LINK_SUBSYS_WIN /subsystem:windows)
message(STATUS ${LINK_SUBSYS_WIN})
target_link_options(vga-terminal-static INTERFACE ${LINK_SUBSYS_WIN})
target_link_options(vga-terminal-static PUBLIC ${LINK_SUBSYS_WIN})
elseif(UNIX)
#target_compile_options(vga-terminal-static PUBLIC -fprofile-instr-generate -fcoverage-mapping)
target_compile_options(vga-terminal-static INTERFACE
$<$<CONFIG:DEBUG>:
#-flto; -fsanitize=address; -fsanitize=thread; -fsanitize=memory; -fsanitize=undefined; -fsanitize=dataflow;
#-fsanitize=cfi; -fsanitize=safe-stack;
#-fprofile-instr-generate; -fcoverage-mapping;
-c -ftest-coverage;
>
$<$<CONFIG:RELEASE>:
>
target_compile_options(vga-terminal-static PRIVATE -fPIC
$<$<CONFIG:DEBUG>: -g;>
$<$<CONFIG:RELEASE>:-O2;>
)

if(ENABLE_CODE_COVERAGE)
target_compile_options(vga-terminal-static PRIVATE
$<$<CONFIG:DEBUG>:-c -ftest-coverage;>
)
target_link_options(vga-terminal-static PUBLIC $<$<CONFIG:DEBUG>: -ftest-coverage; --coverage;>)
#target_link_options(vga-terminal-static PUBLIC $<$<CONFIG:DEBUG>: -fprofile-instr-generate; -fcoverage-mapping;>)
target_link_options(vga-terminal-static INTERFACE $<$<CONFIG:DEBUG>: -ftest-coverage; --coverage;>)
endif()
else()
message(ERROR "Unknown OS")
endif()
Expand Down

0 comments on commit 3e2f271

Please sign in to comment.