mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 04:03:52 +00:00
Build testing (#277)
* build-testing better supported * Add formatting to Azure * Adding more jobs to Azure * Control * Allow libc++ to be used on linux * Fix modernize message * Fix variable * fixup! Fix modernize message * Drop auto exp. optional * Update readme, better user id in docker * Fix BUILD_TESTING * Drop format from travis, leave tidy for now * Check tidy and format * Tidy fully on Azure now
This commit is contained in:
parent
0be526e247
commit
433fd91212
11
.ci/azure-build.yml
Normal file
11
.ci/azure-build.yml
Normal file
@ -0,0 +1,11 @@
|
||||
steps:
|
||||
|
||||
- task: CMake@1
|
||||
inputs:
|
||||
cmakeArgs: .. -DCLI11_SINGLE_FILE=$(cli11.single) -DCLI11_CXX_STD=$(cli11.std) -DCLI11_SINGLE_FILE_TESTS=$(cli11.single) -DCMAKE_BUILD_TYPE=$(cli11.build_type) $(cli11.options)
|
||||
displayName: 'Configure'
|
||||
|
||||
- script: cmake --build . $(cli11.threadopt)
|
||||
displayName: 'Build'
|
||||
workingDirectory: build
|
||||
|
16
.ci/azure-cmake.yml
Normal file
16
.ci/azure-cmake.yml
Normal file
@ -0,0 +1,16 @@
|
||||
steps:
|
||||
|
||||
# Note that silkeh/clang does not include ca-certificates, so check the shasum for verification
|
||||
- bash: |
|
||||
wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz"
|
||||
echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256
|
||||
displayName: Download CMake
|
||||
|
||||
- task: ExtractFiles@1
|
||||
inputs:
|
||||
archiveFilePatterns: 'cmake*.tar.gz'
|
||||
destinationFolder: 'cmake_program'
|
||||
displayName: Extract CMake
|
||||
|
||||
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin"
|
||||
displayName: Add CMake to PATH
|
@ -1,18 +0,0 @@
|
||||
steps:
|
||||
|
||||
- checkout: self
|
||||
fetchDepth: 50
|
||||
submodules: true
|
||||
|
||||
- task: CMake@1
|
||||
inputs:
|
||||
cmakeArgs: .. -DCLI12_SINGLE_FILE=ON -DCLI11_CXX_STD=14 -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
|
||||
displayName: 'Configure'
|
||||
|
||||
- script: cmake --build . -j
|
||||
displayName: 'Build'
|
||||
workingDirectory: build
|
||||
|
||||
- script: ctest --output-on-failure -C Debug
|
||||
displayName: 'Test'
|
||||
workingDirectory: build
|
5
.ci/azure-test.yml
Normal file
5
.ci/azure-test.yml
Normal file
@ -0,0 +1,5 @@
|
||||
steps:
|
||||
|
||||
- script: ctest --output-on-failure -C $(cli11.build_type)
|
||||
displayName: 'Test'
|
||||
workingDirectory: build
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo -en "travis_fold:start:script.build\\r"
|
||||
echo "Building with tidy on..."
|
||||
set -evx
|
||||
|
||||
mkdir -p build-tidy
|
||||
cd build-tidy
|
||||
CXX_FLAGS="-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON
|
||||
cmake --build .
|
||||
|
||||
set -evx
|
||||
echo -en "travis_fold:end:script.build\\r"
|
||||
echo -en "travis_fold:start:script.compare\\r"
|
||||
echo "Checking git diff..."
|
||||
set -evx
|
||||
|
||||
git diff --exit-code --color
|
||||
|
||||
set +evx
|
||||
echo -en "travis_fold:end:script.compare\\r"
|
@ -7,3 +7,5 @@ insert_final_newline = true
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
@ -23,15 +23,6 @@ matrix:
|
||||
- .ci/make_and_test.sh 14
|
||||
- .ci/make_and_test.sh 17
|
||||
|
||||
# Check style/tidy
|
||||
- compiler: clang
|
||||
env:
|
||||
- CHECK_STYLE=yes
|
||||
script:
|
||||
- cd "${TRAVIS_BUILD_DIR}"
|
||||
- scripts/check_style.sh
|
||||
- .ci/check_tidy.sh
|
||||
|
||||
# Docs and clang 3.5
|
||||
- compiler: clang
|
||||
env:
|
||||
|
@ -21,6 +21,8 @@ Set handling has been completely replaced by a new backend that works as a Valid
|
||||
* Cleanup for shadow warnings [#232]
|
||||
* Better alignment on multiline descriptions [#269]
|
||||
* Better support for aarch64 [#266]
|
||||
* Respect `BUILD_TESTING` only if CLI11 is the main project; otherwise, `CLI11_TESTING` must be used [#277]
|
||||
* Drop auto-detection of experimental optional; must be enabled explicitly (too fragile) [#277]
|
||||
|
||||
> ### Converting from CLI11 1.7:
|
||||
>
|
||||
@ -54,6 +56,7 @@ Set handling has been completely replaced by a new backend that works as a Valid
|
||||
[#265]: https://github.com/CLIUtils/CLI11/pull/265
|
||||
[#266]: https://github.com/CLIUtils/CLI11/pull/266
|
||||
[#269]: https://github.com/CLIUtils/CLI11/pull/269
|
||||
[#277]: https://github.com/CLIUtils/CLI11/pull/277
|
||||
|
||||
|
||||
## Version 1.7.1: Quick patch
|
||||
@ -85,7 +88,7 @@ Passing the same subcommand multiple times is better supported. Several new feat
|
||||
* Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#179]
|
||||
* Calling parse multiple times is now officially supported without `clear` (automatic). [#179]
|
||||
* Dropped the mostly undocumented `short_circuit` property, as help flag parsing is a bit more complex, and the default callback behavior of options now works properly. [#179]
|
||||
* Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined (`CLI11_TESTING` may eventually be removed) [#183]
|
||||
* Use the standard `BUILD_TESTING` over `CLI11_TESTING` if defined [#183]
|
||||
* Cleanup warnings [#191]
|
||||
* Remove deprecated names: `set_footer`, `set_name`, `set_callback`, and `set_type_name`. Use without the `set_` instead. [#192]
|
||||
|
||||
|
@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.4)
|
||||
# Note: this is a header only library. If you have an older CMake than 3.4,
|
||||
# just add the CLI11/include directory and that's all you need to do.
|
||||
|
||||
# Make sure users don't get warnings on a tested (3.4 to 3.13) version
|
||||
# Make sure users don't get warnings on a tested (3.4 to 3.14) version
|
||||
# of CMake. For most of the policies, the new version is better (hence the change).
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.13)
|
||||
# We don't use the 3.4...3.14 syntax because of a bug in a version of MSVC
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.14)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
else()
|
||||
cmake_policy(VERSION 3.13)
|
||||
cmake_policy(VERSION 3.14)
|
||||
endif()
|
||||
|
||||
set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
|
||||
@ -27,6 +28,15 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
# User settable
|
||||
set(CLI11_CXX_STD "11" CACHE STRING "The CMake standard to require")
|
||||
|
||||
# Special override for Clang on Linux (useful with an old stdlibc++ and a newer clang)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
option(CLI11_FORCE_LIBCXX "Force Clang to use libc++ instead of libstdc++ (Linux only)" OFF)
|
||||
if(CLI11_FORCE_LIBCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CUR_PROJ ON)
|
||||
set(CMAKE_CXX_STANDARD ${CLI11_CXX_STD})
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
@ -149,14 +159,23 @@ if(CLI11_SINGLE_FILE)
|
||||
target_include_directories(CLI11_SINGLE INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/")
|
||||
endif()
|
||||
|
||||
cmake_dependent_option(CLI11_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF "CLI11_SINGLE_FILE" OFF)
|
||||
cmake_dependent_option(CLI11_SINGLE_FILE_TESTS
|
||||
"Duplicate all the tests for a single file build"
|
||||
OFF
|
||||
"CLI11_SINGLE_FILE"
|
||||
OFF)
|
||||
|
||||
cmake_dependent_option(CLI11_TESTING "Build the tests and add them" ON "CUR_PROJ" OFF)
|
||||
if(DEFINED BUILD_TESTING)
|
||||
cmake_dependent_option(CLI11_TESTING "" ON "BUILD_TESTING" OFF)
|
||||
message(STATUS "BUILD_TESTING is defined and it supersedes CLI11_TESTING. Has forced to ${CLI11_TESTING}")
|
||||
|
||||
if(DEFINED CLI11_TESTING)
|
||||
set(CLI11_TESTING_INTERNAL "${CLI11_TESTING}")
|
||||
elseif(CUR_PROJ)
|
||||
option(BUILD_TESTING "Build the tests" ON)
|
||||
set(CLI11_TESTING_INTERNAL "${BUILD_TESTING}")
|
||||
else()
|
||||
set(CLI11_TESTING_INTERNAL OFF)
|
||||
endif()
|
||||
if(CLI11_TESTING)
|
||||
|
||||
if(CLI11_TESTING_INTERNAL)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
@ -73,7 +73,7 @@ An acceptable CLI parser library should be all of the following:
|
||||
|
||||
- Easy to include (i.e., header only, one file if possible, **no external requirements**).
|
||||
- Short, simple syntax: This is one of the main reasons to use a CLI parser, it should make variables from the command line nearly as easy to define as any other variables. If most of your program is hidden in CLI parsing, this is a problem for readability.
|
||||
- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang 3.5+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+.
|
||||
- C++11 or better: Should work with GCC 4.8+ (default on CentOS/RHEL 7), Clang 3.4+, AppleClang 7+, NVCC 7.0+, or MSVC 2015+.
|
||||
- Work on Linux, macOS, and Windows.
|
||||
- Well tested using [Travis][] (Linux) and [AppVeyor][] (Windows) or [Azure][] (all three). "Well" is defined as having good coverage measured by [CodeCov][].
|
||||
- Clear help printing.
|
||||
|
@ -6,21 +6,71 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
variables:
|
||||
cli11.single: ON
|
||||
cli11.std: 14
|
||||
cli11.build_type: Debug
|
||||
cli11.options:
|
||||
cli11.threadopt: -j
|
||||
|
||||
jobs:
|
||||
- job: Linux
|
||||
|
||||
- job: ClangFormatTidy
|
||||
variables:
|
||||
CXX_FLAGS: "-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11"
|
||||
cli11.options: -DCLANG_TIDY_FIX=ON
|
||||
cli11.std: 11
|
||||
cli11.single: OFF
|
||||
cli11.threadopt:
|
||||
pool:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
container: silkeh/clang:5
|
||||
steps:
|
||||
- template: .ci/azure-steps.yml
|
||||
- script: scripts/check_style.sh
|
||||
displayName: Check format
|
||||
- template: .ci/azure-cmake.yml
|
||||
- template: .ci/azure-build.yml
|
||||
- script: git diff --exit-code --color
|
||||
displayName: Check tidy
|
||||
|
||||
- job: macOS
|
||||
- job: Native
|
||||
strategy:
|
||||
matrix:
|
||||
Linux:
|
||||
vmImage: 'ubuntu-16.04'
|
||||
macOS:
|
||||
vmImage: 'macOS-10.14'
|
||||
Windows:
|
||||
vmImage: 'vs2017-win2016'
|
||||
pool:
|
||||
vmImage: 'macOS-10.13'
|
||||
vmImage: $(vmImage)
|
||||
steps:
|
||||
- template: .ci/azure-steps.yml
|
||||
- template: .ci/azure-build.yml
|
||||
- template: .ci/azure-test.yml
|
||||
|
||||
- job: Windows
|
||||
- job: Docker
|
||||
variables:
|
||||
cli11.single: OFF
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
vmImage: 'ubuntu-16.04'
|
||||
strategy:
|
||||
matrix:
|
||||
gcc9:
|
||||
containerImage: gcc:9
|
||||
cli11.std: 17
|
||||
gcc4.7:
|
||||
containerImage: gcc:4.7
|
||||
cli11.std: 11
|
||||
clang3.4:
|
||||
containerImage: silkeh/clang:3.4
|
||||
cli11.std: 11
|
||||
clang8:
|
||||
containerImage: silkeh/clang:8
|
||||
cli11.std: 14
|
||||
cli11.options: -DCLI11_FORCE_LIBCXX=ON
|
||||
container: $[ variables['containerImage'] ]
|
||||
steps:
|
||||
- template: .ci/azure-steps.yml
|
||||
- template: .ci/azure-cmake.yml
|
||||
- template: .ci/azure-build.yml
|
||||
- template: .ci/azure-test.yml
|
||||
|
||||
|
@ -19,11 +19,7 @@
|
||||
#define CLI11_STD_OPTIONAL 0
|
||||
#endif
|
||||
|
||||
#if defined(CLI11_CPP14) && __has_include(<experimental/optional>) && \
|
||||
!defined(CLI11_EXPERIMENTAL_OPTIONAL) \
|
||||
&& (!defined(CLI11_STD_OPTIONAL) || CLI11_STD_OPTIONAL == 0)
|
||||
#define CLI11_EXPERIMENTAL_OPTIONAL 1
|
||||
#elif !defined(CLI11_EXPERIMENTAL_OPTIONAL)
|
||||
#if !defined(CLI11_EXPERIMENTAL_OPTIONAL)
|
||||
#define CLI11_EXPERIMENTAL_OPTIONAL 0
|
||||
#endif
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define _GLIBCXX_USE_NANOSLEEP
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@ -86,9 +87,9 @@ class Timer {
|
||||
/// This prints out a time string from a time
|
||||
std::string make_time_str(double time) const {
|
||||
auto print_it = [](double x, std::string unit) {
|
||||
char buffer[50];
|
||||
std::snprintf(buffer, 50, "%.5g", x);
|
||||
return buffer + std::string(" ") + unit;
|
||||
std::array<char, 50> buffer;
|
||||
std::snprintf(buffer.data(), 50, "%.5g", x);
|
||||
return buffer.data() + std::string(" ") + unit;
|
||||
};
|
||||
|
||||
if(time < .000001)
|
||||
|
@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Also good but untagged: CLANG_FORMAT=unibeautify/clang-format
|
||||
# This might provide more control in the future: silkeh/clang:8 (etc)
|
||||
CLANG_FORMAT=saschpe/clang-format:5.0.1
|
||||
|
||||
set -evx
|
||||
|
||||
docker run --rm -it ${CLANG_FORMAT} --version
|
||||
docker run --rm -it -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp')
|
||||
docker run --rm ${CLANG_FORMAT} --version
|
||||
docker run --rm --user $(id -u):$(id -g) -v "$(pwd)":/workdir -w /workdir ${CLANG_FORMAT} -style=file -sort-includes -i $(git ls-files -- '*.cpp' '*.hpp')
|
||||
|
||||
git diff --exit-code --color
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user