mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
presets: Diagnose non-string workflow step types
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
#include "cmCMakePresetsErrors.h"
|
||||
#include "cmCMakePresetsGraph.h"
|
||||
#include "cmCMakePresetsGraphInternal.h"
|
||||
@@ -16,6 +14,10 @@
|
||||
|
||||
class cmJSONState;
|
||||
|
||||
namespace Json {
|
||||
class Value;
|
||||
}
|
||||
|
||||
namespace {
|
||||
using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset;
|
||||
|
||||
@@ -27,26 +29,28 @@ bool WorkflowStepTypeHelper(WorkflowPreset::WorkflowStep::Type& out,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value->isString()) {
|
||||
std::string workflowType;
|
||||
if (!cmCMakePresetsGraphInternal::PresetStringHelper(workflowType, value,
|
||||
state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value->asString() == "configure") {
|
||||
if (workflowType == "configure") {
|
||||
out = WorkflowPreset::WorkflowStep::Type::Configure;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value->asString() == "build") {
|
||||
if (workflowType == "build") {
|
||||
out = WorkflowPreset::WorkflowStep::Type::Build;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value->asString() == "test") {
|
||||
if (workflowType == "test") {
|
||||
out = WorkflowPreset::WorkflowStep::Type::Test;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value->asString() == "package") {
|
||||
if (workflowType == "package") {
|
||||
out = WorkflowPreset::WorkflowStep::Type::Package;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ endfunction()
|
||||
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
|
||||
run_cmake_workflow_presets(UnsupportedVersion)
|
||||
run_cmake_workflow_presets(WorkflowStepInvalidType)
|
||||
set(CMakePresets_SCHEMA_EXPECTED_RESULT 0)
|
||||
run_cmake_workflow_presets(NoWorkflowSteps)
|
||||
run_cmake_workflow_presets(FirstStepNotConfigure)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
^CMake Error: Could not read presets from [^
|
||||
]*/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidType:
|
||||
CMakePresets\.json:8: "type" expected a string, got: 42
|
||||
"type": 42,
|
||||
\^$
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 6,
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "WorkflowStepInvalidType",
|
||||
"steps": [
|
||||
{
|
||||
"type": 42,
|
||||
"name": "configure"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user