Copy the snippets referred to by an index file to a separate * directory where they will be parsed for submission to CDash. **/
| 947 | * directory where they will be parsed for submission to CDash. |
| 948 | **/ |
| 949 | void cmInstrumentation::PrepareDataForCDash(std::string const& data_dir, |
| 950 | std::string const& index_path) |
| 951 | { |
| 952 | cmSystemTools::MakeDirectory(this->cdashDir); |
| 953 | cmSystemTools::MakeDirectory(cmStrCat(this->cdashDir, "/configure")); |
| 954 | cmSystemTools::MakeDirectory(cmStrCat(this->cdashDir, "/build")); |
| 955 | cmSystemTools::MakeDirectory(cmStrCat(this->cdashDir, "/build/commands")); |
| 956 | cmSystemTools::MakeDirectory(cmStrCat(this->cdashDir, "/build/targets")); |
| 957 | cmSystemTools::MakeDirectory(cmStrCat(this->cdashDir, "/test")); |
| 958 | |
| 959 | Json::Value root; |
| 960 | std::string error_msg; |
| 961 | cmJSONState parseState = cmJSONState(index_path, &root); |
| 962 | if (!parseState.errors.empty()) { |
| 963 | cmSystemTools::Error(parseState.GetErrorMessage(true)); |
| 964 | return; |
| 965 | } |
| 966 | |
| 967 | if (!root.isObject()) { |
| 968 | error_msg = |
| 969 | cmStrCat("Expected index file ", index_path, " to contain an object"); |
| 970 | cmSystemTools::Error(error_msg); |
| 971 | return; |
| 972 | } |
| 973 | |
| 974 | if (!root.isMember("snippets")) { |
| 975 | error_msg = cmStrCat("Expected index file ", index_path, |
| 976 | " to have a key 'snippets'"); |
| 977 | cmSystemTools::Error(error_msg); |
| 978 | return; |
| 979 | } |
| 980 | |
| 981 | std::string dst_dir; |
| 982 | Json::Value snippets = root["snippets"]; |
| 983 | for (auto const& snippet : snippets) { |
| 984 | // Parse the role of this snippet. |
| 985 | std::string snippet_str = snippet.asString(); |
| 986 | std::string snippet_path = cmStrCat(data_dir, '/', snippet_str); |
| 987 | Json::Value snippet_root; |
| 988 | parseState = cmJSONState(snippet_path, &snippet_root); |
| 989 | if (!parseState.errors.empty()) { |
| 990 | cmSystemTools::Error(parseState.GetErrorMessage(true)); |
| 991 | continue; |
| 992 | } |
| 993 | if (!snippet_root.isObject()) { |
| 994 | error_msg = cmStrCat("Expected snippet file ", snippet_path, |
| 995 | " to contain an object"); |
| 996 | cmSystemTools::Error(error_msg); |
| 997 | continue; |
| 998 | } |
| 999 | if (!snippet_root.isMember("role")) { |
| 1000 | error_msg = cmStrCat("Expected snippet file ", snippet_path, |
| 1001 | " to have a key 'role'"); |
| 1002 | cmSystemTools::Error(error_msg); |
| 1003 | continue; |
| 1004 | } |
| 1005 | |
| 1006 | std::string snippet_role = snippet_root["role"].asString(); |
no test coverage detected