Commit 39e777392d9cb13b5c32345ecb4658811c42a703
Committed by
Henry Schreiner
1 parent
43ec3077
Adding informational printout to ctest
Showing
6 changed files
with
57 additions
and
6 deletions
.appveyor.yml
| @@ -20,7 +20,6 @@ build_script: | @@ -20,7 +20,6 @@ build_script: | ||
| 20 | test_script: | 20 | test_script: |
| 21 | - cd build | 21 | - cd build |
| 22 | - ctest --output-on-failure -C Debug | 22 | - ctest --output-on-failure -C Debug |
| 23 | - - tests\OptionalTest | ||
| 24 | 23 | ||
| 25 | notifications: | 24 | notifications: |
| 26 | - provider: Webhook | 25 | - provider: Webhook |
.ci/make_and_test.sh
| @@ -15,7 +15,6 @@ echo "Testing..." | @@ -15,7 +15,6 @@ echo "Testing..." | ||
| 15 | set -evx | 15 | set -evx |
| 16 | 16 | ||
| 17 | ctest --output-on-failure | 17 | ctest --output-on-failure |
| 18 | -./tests/OptionalTest | ||
| 19 | 18 | ||
| 20 | set +evx | 19 | set +evx |
| 21 | echo -en "travis_fold:end:script.test\\r" | 20 | echo -en "travis_fold:end:script.test\\r" |
include/CLI/Optional.hpp
| @@ -60,10 +60,10 @@ template <typename T> std::istream &operator>>(std::istream &in, boost::optional | @@ -60,10 +60,10 @@ template <typename T> std::istream &operator>>(std::istream &in, boost::optional | ||
| 60 | // Export the best optional to the CLI namespace | 60 | // Export the best optional to the CLI namespace |
| 61 | #if defined(CLI11_STD_OPTIONAL) | 61 | #if defined(CLI11_STD_OPTIONAL) |
| 62 | using std::optional; | 62 | using std::optional; |
| 63 | -#elif CLI11_EXPERIMENTAL_OPTIONAL | 63 | +#elif defined(CLI11_EXPERIMENTAL_OPTIONAL) |
| 64 | using std::experimental::optional; | 64 | using std::experimental::optional; |
| 65 | -#elif CLI11_BOOST_OPTIONAL | ||
| 66 | -using boost::optionall | 65 | +#elif defined(CLI11_BOOST_OPTIONAL) |
| 66 | +using boost::optional; | ||
| 67 | #endif | 67 | #endif |
| 68 | 68 | ||
| 69 | // This is true if any optional is found | 69 | // This is true if any optional is found |
tests/CMakeLists.txt
| @@ -53,3 +53,13 @@ set_target_properties(link_test_1 PROPERTIES FOLDER "Tests") | @@ -53,3 +53,13 @@ set_target_properties(link_test_1 PROPERTIES FOLDER "Tests") | ||
| 53 | add_executable(link_test_2 link_test_2.cpp) | 53 | add_executable(link_test_2 link_test_2.cpp) |
| 54 | target_link_libraries(link_test_2 PUBLIC CLI11 link_test_1) | 54 | target_link_libraries(link_test_2 PUBLIC CLI11 link_test_1) |
| 55 | add_gtest(link_test_2) | 55 | add_gtest(link_test_2) |
| 56 | + | ||
| 57 | +# Add informational printout | ||
| 58 | +add_executable(informational informational.cpp) | ||
| 59 | +target_link_libraries(informational PUBLIC CLI11) | ||
| 60 | +set_property(TARGET informational PROPERTY | ||
| 61 | + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
| 62 | + | ||
| 63 | +file(WRITE "${PROJECT_BINARY_DIR}/CTestCustom.cmake" | ||
| 64 | + "set(CTEST_CUSTOM_PRE_TEST \"${CMAKE_BINARY_DIR}/informational\")" | ||
| 65 | + ) |
tests/OptionalTest.cpp
tests/informational.cpp
0 → 100644
| 1 | +#ifdef CLI11_SINGLE_FILE | ||
| 2 | +#include "CLI11.hpp" | ||
| 3 | +#else | ||
| 4 | +#include "CLI/CLI.hpp" | ||
| 5 | +#endif | ||
| 6 | + | ||
| 7 | +#include <iostream> | ||
| 8 | + | ||
| 9 | +int main() { | ||
| 10 | + std::cout << "\nCLI11 information:\n"; | ||
| 11 | + | ||
| 12 | + std::cout << " C++ standard: "; | ||
| 13 | +#if defined(CLI11_CPP20) | ||
| 14 | + std::cout << 20; | ||
| 15 | +#elif defined(CLI11_CPP17) | ||
| 16 | + std::cout << 17; | ||
| 17 | +#elif defined(CLI11_CPP14) | ||
| 18 | + std::cout << 14; | ||
| 19 | +#else | ||
| 20 | + std::cout << 11; | ||
| 21 | +#endif | ||
| 22 | + std::cout << "\n"; | ||
| 23 | + | ||
| 24 | +#ifdef CLI11_OPTIONAL | ||
| 25 | + std::cout << " [Available as CLI::optional]"; | ||
| 26 | +#else | ||
| 27 | + std::cout << " No optional library found\n"; | ||
| 28 | +#endif | ||
| 29 | + | ||
| 30 | +#ifdef CLI11_STD_OPTIONAL | ||
| 31 | + std::cout << " std::optional support active\n"; | ||
| 32 | +#endif | ||
| 33 | + | ||
| 34 | +#ifdef CLI11_EXPERIMENTAL_OPTIONAL | ||
| 35 | + std::cout << " std::experimental::optional support active\n"; | ||
| 36 | +#endif | ||
| 37 | + | ||
| 38 | +#ifdef CLI11_BOOST_OPTIONAL | ||
| 39 | + std::cout << " boost::optional support active\n"; | ||
| 40 | +#endif | ||
| 41 | + | ||
| 42 | + std::cout << std::endl; | ||
| 43 | +} |