summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-11-22 18:43:32 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2019-11-25 16:08:27 (GMT)
commitf9f294f5faf980aa39721e4deb465b2e9dbbbd9a (patch)
tree3f9210c5f80ab9f1199daaaa44ebeb84930f7335
parent99f0881d8c6d0c435e595c5f9510da776827ee3e (diff)
downloadCMake-f9f294f5faf980aa39721e4deb465b2e9dbbbd9a.zip
CMake-f9f294f5faf980aa39721e4deb465b2e9dbbbd9a.tar.gz
CMake-f9f294f5faf980aa39721e4deb465b2e9dbbbd9a.tar.bz2
CTest: Add version field to resource spec file
Fixes: #20007
-rw-r--r--Help/manual/ctest.1.rst9
-rw-r--r--Source/CTest/cmCTestResourceSpec.cxx26
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec.cxx17
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec1.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec10.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec11.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec14.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec15.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec16.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec17.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec18.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec19.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec2.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec20.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec21.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec22.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec23.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec24.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec25.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec26.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec27.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec28.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec29.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec3.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec30.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec31.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec32.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec33.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec34.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec35.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec4.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec5.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec6.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec7.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec8.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec9.json4
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/resspec.json4
37 files changed, 224 insertions, 0 deletions
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index dbefb91..6af795e 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -1345,6 +1345,10 @@ the following resource specification file:
.. code-block:: json
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
@@ -1376,6 +1380,11 @@ the following resource specification file:
The members are:
+``version``
+ An object containing a ``major`` integer field and a ``minor`` integer field.
+ Currently, the only supported version is major ``1``, minor ``0``. Any other
+ value is an error.
+
``local``
A JSON array of resource sets present on the system. Currently, this array
is restricted to being of size 1.
diff --git a/Source/CTest/cmCTestResourceSpec.cxx b/Source/CTest/cmCTestResourceSpec.cxx
index b4a2b30..237a745 100644
--- a/Source/CTest/cmCTestResourceSpec.cxx
+++ b/Source/CTest/cmCTestResourceSpec.cxx
@@ -33,6 +33,32 @@ bool cmCTestResourceSpec::ReadFromJSONFile(const std::string& filename)
return false;
}
+ int majorVersion = 1;
+ int minorVersion = 0;
+ if (root.isMember("version")) {
+ auto const& version = root["version"];
+ if (version.isObject()) {
+ if (!version.isMember("major") || !version.isMember("minor")) {
+ return false;
+ }
+ auto const& major = version["major"];
+ auto const& minor = version["minor"];
+ if (!major.isInt() || !minor.isInt()) {
+ return false;
+ }
+ majorVersion = major.asInt();
+ minorVersion = minor.asInt();
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ if (majorVersion != 1 || minorVersion != 0) {
+ return false;
+ }
+
auto const& local = root["local"];
if (!local.isArray()) {
return false;
diff --git a/Tests/CMakeLib/testCTestResourceSpec.cxx b/Tests/CMakeLib/testCTestResourceSpec.cxx
index e4bc770..b981387 100644
--- a/Tests/CMakeLib/testCTestResourceSpec.cxx
+++ b/Tests/CMakeLib/testCTestResourceSpec.cxx
@@ -39,6 +39,23 @@ static const std::vector<ExpectedSpec> expectedResourceSpecs = {
{"spec16.json", true, {{{}}}},
{"spec17.json", false, {{{}}}},
{"spec18.json", false, {{{}}}},
+ {"spec19.json", false, {{{}}}},
+ {"spec20.json", true, {{{}}}},
+ {"spec21.json", false, {{{}}}},
+ {"spec22.json", false, {{{}}}},
+ {"spec23.json", false, {{{}}}},
+ {"spec24.json", false, {{{}}}},
+ {"spec25.json", false, {{{}}}},
+ {"spec26.json", false, {{{}}}},
+ {"spec27.json", false, {{{}}}},
+ {"spec28.json", false, {{{}}}},
+ {"spec29.json", false, {{{}}}},
+ {"spec30.json", false, {{{}}}},
+ {"spec31.json", false, {{{}}}},
+ {"spec32.json", false, {{{}}}},
+ {"spec33.json", false, {{{}}}},
+ {"spec34.json", false, {{{}}}},
+ {"spec35.json", false, {{{}}}},
{"noexist.json", false, {{{}}}},
/* clang-format on */
};
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
index ee3d0ce..b01aa6b 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
index 22105d7..8764907 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
index 1e37ef5..7551ea2 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
index ce708c7..83f480c 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"0": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
index 78b6990..10fe2e3 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"-": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
index 95c7d26..8546759 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"A": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
index 1b6ab4b..e4cdfc9 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
index 1a17df7..26a7c70 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
new file mode 100644
index 0000000..3067f0c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
index 6175b1a..df49390 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
]
}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
new file mode 100644
index 0000000..df49390
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
new file mode 100644
index 0000000..7459ff2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
new file mode 100644
index 0000000..23c57d8
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
@@ -0,0 +1,5 @@
+{
+ "version": 2,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
new file mode 100644
index 0000000..a3d0a27
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "major": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
new file mode 100644
index 0000000..d5f6b08
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
new file mode 100644
index 0000000..914da4b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
new file mode 100644
index 0000000..c06de22
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 2,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
new file mode 100644
index 0000000..9e2b6c3
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": "1",
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
new file mode 100644
index 0000000..ce3b76a
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": "0"
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
new file mode 100644
index 0000000..58afd2b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
index 82453ec..2f1045f 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
},
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
new file mode 100644
index 0000000..9e13ff0
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
@@ -0,0 +1,5 @@
+{
+ "version": [1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
new file mode 100644
index 0000000..c0ef7f4
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
new file mode 100644
index 0000000..abe977e
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
@@ -0,0 +1,5 @@
+{
+ "version": [2, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
new file mode 100644
index 0000000..c6ca749
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
@@ -0,0 +1,5 @@
+{
+ "version": ["1", 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
new file mode 100644
index 0000000..be258f1
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, "0"],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
new file mode 100644
index 0000000..137648c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
@@ -0,0 +1,5 @@
+{
+ "version": "1",
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
index 05e73d7..17349bd 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": {
}
}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
index 2c63c08..f6e6cb4 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
@@ -1,2 +1,6 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ }
}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
index 93c790d..eb8b14c 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
[]
]
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
index 28b6a4f..0447981 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": {
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
index 79bd224..ee7a9c2 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
index 6bb1def..ae1117b 100644
--- a/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"gpus": [
diff --git a/Tests/RunCMake/CTestResourceAllocation/resspec.json b/Tests/RunCMake/CTestResourceAllocation/resspec.json
index c67fcca..48321ec 100644
--- a/Tests/RunCMake/CTestResourceAllocation/resspec.json
+++ b/Tests/RunCMake/CTestResourceAllocation/resspec.json
@@ -1,4 +1,8 @@
{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
"local": [
{
"widgets": [