MUST(rjaber): Add recursive iteration, and relative path into DiskUtils/Path and move this function over
| 22 | |
| 23 | // MUST(rjaber): Add recursive iteration, and relative path into DiskUtils/Path and move this function over |
| 24 | bool serializeTestCases(const fs::path& outputFile, const unordered_map<string, TestCaseData>& testCases) { |
| 25 | Value result; |
| 26 | for (const auto& testCase : testCases) { |
| 27 | auto data = testCase.second; |
| 28 | |
| 29 | Value map; |
| 30 | map.setMapValue(kIsNegative, Value(data.isNegative)); |
| 31 | map.setMapValue(kNegativePhase, Value(data.negativePhase)); |
| 32 | map.setMapValue(kNegativeType, Value(data.negativeType)); |
| 33 | map.setMapValue(kOnlyStrict, Value(data.onlyStrict)); |
| 34 | map.setMapValue(kNoStrict, Value(data.noStrict)); |
| 35 | map.setMapValue(kModule, Value(data.module)); |
| 36 | map.setMapValue(kRaw, Value(data.raw)); |
| 37 | map.setMapValue(kAsync, Value(data.async)); |
| 38 | |
| 39 | const auto includesSize = data.includes.size(); |
| 40 | auto includesValueArray = ValueArray::make(includesSize); |
| 41 | for (size_t i = 0; i < includesSize; i++) { |
| 42 | includesValueArray->emplace(i, Value(data.includes[i])); |
| 43 | } |
| 44 | map.setMapValue(kIncludes, Value(includesValueArray)); |
| 45 | result.setMapValue(testCase.first, map); |
| 46 | } |
| 47 | |
| 48 | const auto data = valueToJson(result)->toBytesView(); |
| 49 | |
| 50 | auto storeResult = DiskUtils::store(Path(outputFile.string()), data); |
| 51 | if (!storeResult) { |
| 52 | TEST262_LOG(cerr, "Failed to save file {} with error {}", outputFile, storeResult.error().getMessage()); |
| 53 | return false; |
| 54 | } |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | Result<map<string, TestCaseData>> deserializeTestCases(const fs::path& inputFile) { |
| 59 | auto testCasesResult = DiskUtils::load(Path(inputFile.string())); |
no test coverage detected