MCPcopy Create free account
hub / github.com/Snapchat/Valdi / serializeTestCases

Function serializeTestCases

tsn/src/test262/shared/Test262Serialization.cpp:24–56  ·  view source on GitHub ↗

MUST(rjaber): Add recursive iteration, and relative path into DiskUtils/Path and move this function over

Source from the content-addressed store, hash-verified

22
23// MUST(rjaber): Add recursive iteration, and relative path into DiskUtils/Path and move this function over
24bool 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
58Result<map<string, TestCaseData>> deserializeTestCases(const fs::path& inputFile) {
59 auto testCasesResult = DiskUtils::load(Path(inputFile.string()));

Callers 1

processTestDirectoryFunction · 0.85

Calls 10

valueToJsonFunction · 0.85
storeFunction · 0.85
getMessageMethod · 0.65
errorMethod · 0.65
ValueClass · 0.50
PathClass · 0.50
sizeMethod · 0.45
emplaceMethod · 0.45
toBytesViewMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected