Commit 43ec307781a979e991b5138744d214394df6c175

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent 48cb5008

Better message about optional test, warning suppression

.appveyor.yml
@@ -18,7 +18,9 @@ build_script: @@ -18,7 +18,9 @@ build_script:
18 - conan create . CLIUtils/CLI11 18 - conan create . CLIUtils/CLI11
19 19
20 test_script: 20 test_script:
  21 + - cd build
21 - ctest --output-on-failure -C Debug 22 - ctest --output-on-failure -C Debug
  23 + - tests\OptionalTest
22 24
23 notifications: 25 notifications:
24 - provider: Webhook 26 - provider: Webhook
.ci/make_and_test.sh
@@ -15,6 +15,7 @@ echo "Testing..." @@ -15,6 +15,7 @@ echo "Testing..."
15 set -evx 15 set -evx
16 16
17 ctest --output-on-failure 17 ctest --output-on-failure
  18 +./tests/OptionalTest
18 19
19 set +evx 20 set +evx
20 echo -en "travis_fold:end:script.test\\r" 21 echo -en "travis_fold:end:script.test\\r"
CMakeLists.txt
@@ -27,7 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) @@ -27,7 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
27 if(MSVC) 27 if(MSVC)
28 add_definitions("/W4") 28 add_definitions("/W4")
29 else() 29 else()
30 - add_definitions(-Wall -Wextra -pedantic) 30 + add_definitions(-Wall -Wextra -pedantic -Wno-deprecated-declarations)
31 endif() 31 endif()
32 32
33 if(CMAKE_VERSION VERSION_GREATER 3.6) 33 if(CMAKE_VERSION VERSION_GREATER 3.6)
include/CLI/Option.hpp
@@ -309,7 +309,7 @@ class Option : public OptionBase<Option> { @@ -309,7 +309,7 @@ class Option : public OptionBase<Option> {
309 template <typename T = App> Option *requires(std::string opt_name) { 309 template <typename T = App> Option *requires(std::string opt_name) {
310 for(const Option_p &opt : dynamic_cast<T *>(parent_)->options_) 310 for(const Option_p &opt : dynamic_cast<T *>(parent_)->options_)
311 if(opt.get() != this && opt->check_name(opt_name)) 311 if(opt.get() != this && opt->check_name(opt_name))
312 - return requires(opt.get()); 312 + return needs(opt.get());
313 throw IncorrectConstruction::MissingOption(opt_name); 313 throw IncorrectConstruction::MissingOption(opt_name);
314 } 314 }
315 315
tests/OptionalTest.cpp
1 #include <cstdlib> 1 #include <cstdlib>
2 #include <iostream> 2 #include <iostream>
3 3
4 -#if CLI11_OPTIONAL  
5 -  
6 #include "app_helper.hpp" 4 #include "app_helper.hpp"
7 5
  6 +#if CLI11_OPTIONAL
  7 +
8 TEST_F(TApp, OptionalTest) { 8 TEST_F(TApp, OptionalTest) {
9 optional<int> opt; 9 optional<int> opt;
10 app.add_option("-c,--count", opt); 10 app.add_option("-c,--count", opt);
@@ -24,4 +24,8 @@ TEST_F(TApp, OptionalTest) { @@ -24,4 +24,8 @@ TEST_F(TApp, OptionalTest) {
24 EXPECT_EQ(*opt, 3); 24 EXPECT_EQ(*opt, 3);
25 } 25 }
26 26
  27 +#else
  28 +
  29 +TEST_F(TApp, DISABLED_OptionalTest) {}
  30 +
27 #endif 31 #endif