diff options
author | Brad King <brad.king@kitware.com> | 2023-07-13 12:36:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-07-13 12:36:24 (GMT) |
commit | d769c59d783f0ffc46d61bb4715b5fb3a68181a8 (patch) | |
tree | b85b3771afef9de12d05b7083256d4d27714cb4d /Tests | |
parent | c6ce7572984726ac714ae78d31b047683f076e83 (diff) | |
parent | e02cf3f1906dda51e5cdf8ae38b3eb46176a90f1 (diff) | |
download | CMake-d769c59d783f0ffc46d61bb4715b5fb3a68181a8.zip CMake-d769c59d783f0ffc46d61bb4715b5fb3a68181a8.tar.gz CMake-d769c59d783f0ffc46d61bb4715b5fb3a68181a8.tar.bz2 |
Merge topic 'debugger-no-supportsVariableType' into release-3.27
e02cf3f190 Debugger: Correctly handle clients without supportsVariableType
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Garrett Campbell <gcampbell@microsoft.com>
Merge-request: !8620
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/testDebugger.h | 12 | ||||
-rw-r--r-- | Tests/CMakeLib/testDebuggerVariables.cxx | 29 | ||||
-rw-r--r-- | Tests/CMakeLib/testDebuggerVariablesHelper.cxx | 1 |
3 files changed, 38 insertions, 4 deletions
diff --git a/Tests/CMakeLib/testDebugger.h b/Tests/CMakeLib/testDebugger.h index 8ba21f6..d8d2caa 100644 --- a/Tests/CMakeLib/testDebugger.h +++ b/Tests/CMakeLib/testDebugger.h @@ -19,11 +19,15 @@ do { \ ASSERT_TRUE(x.name == expectedName); \ ASSERT_TRUE(x.value == expectedValue); \ - ASSERT_TRUE(x.type.value() == expectedType); \ - ASSERT_TRUE(x.evaluateName.has_value() == false); \ - if (std::string(expectedType) == "collection") { \ - ASSERT_TRUE(x.variablesReference != 0); \ + if (expectedType == nullptr) { \ + ASSERT_TRUE(x.type == dap::optional<dap::string>()); \ + } else { \ + ASSERT_TRUE(x.type == dap::optional<dap::string>(expectedType)); \ + if (std::string(expectedType) == "collection") { \ + ASSERT_TRUE(x.variablesReference != 0); \ + } \ } \ + ASSERT_TRUE(x.evaluateName.has_value() == false); \ } while (false) #define ASSERT_VARIABLE_REFERENCE(x, expectedName, expectedValue, \ diff --git a/Tests/CMakeLib/testDebuggerVariables.cxx b/Tests/CMakeLib/testDebuggerVariables.cxx index 6c19baa..0d8d18d 100644 --- a/Tests/CMakeLib/testDebuggerVariables.cxx +++ b/Tests/CMakeLib/testDebuggerVariables.cxx @@ -8,6 +8,7 @@ #include <unordered_set> #include <vector> +#include <cm3p/cppdap/optional.h> #include <cm3p/cppdap/protocol.h> #include <cm3p/cppdap/types.h> @@ -174,6 +175,33 @@ static bool testSortTheResult() return true; } +static bool testNoSupportsVariableType() +{ + auto variablesManager = + std::make_shared<cmDebugger::cmDebuggerVariablesManager>(); + + auto vars = std::make_shared<cmDebugger::cmDebuggerVariables>( + variablesManager, "Variables", false, []() { + return std::vector<cmDebugger::cmDebuggerVariableEntry>{ { "test", + "value" } }; + }); + + auto subvars = std::make_shared<cmDebugger::cmDebuggerVariables>( + variablesManager, "Children", false); + + vars->AddSubVariables(subvars); + + dap::array<dap::Variable> variables = + variablesManager->HandleVariablesRequest( + CreateVariablesRequest(vars->GetId())); + + ASSERT_TRUE(variables.size() == 2); + ASSERT_VARIABLE(variables[0], "Children", "", nullptr); + ASSERT_VARIABLE(variables[1], "test", "value", nullptr); + + return true; +} + int testDebuggerVariables(int, char*[]) { return runTests(std::vector<std::function<bool()>>{ @@ -181,5 +209,6 @@ int testDebuggerVariables(int, char*[]) testConstructors, testIgnoreEmptyStringEntries, testSortTheResult, + testNoSupportsVariableType, }); } diff --git a/Tests/CMakeLib/testDebuggerVariablesHelper.cxx b/Tests/CMakeLib/testDebuggerVariablesHelper.cxx index e0bbdf0..d61b73b 100644 --- a/Tests/CMakeLib/testDebuggerVariablesHelper.cxx +++ b/Tests/CMakeLib/testDebuggerVariablesHelper.cxx @@ -8,6 +8,7 @@ #include <utility> #include <vector> +#include <cm3p/cppdap/optional.h> #include <cm3p/cppdap/protocol.h> #include <cm3p/cppdap/types.h> #include <stddef.h> |