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

Function processTestDirectory

tsn/src/test262/preprocessor/main.cpp:289–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289bool processTestDirectory(const fs::path& test262Directory, const fs::path& outputFile) {
290 auto testDirectory = test262Directory / "test";
291 auto tmp = string(testDirectory.c_str());
292
293 unordered_map<std::string, TestCaseData> testCases;
294 // TODO(rjaber): Add support for skipping folders, for example we don't expect Intl tests to ever pass
295 // TODO(rjaber): Add directory_entry into DiskUtils, and move away from using C++ filesystem module
296 for (const fs::directory_entry& dir_entry : fs::recursive_directory_iterator(testDirectory)) {
297 if (dir_entry.is_directory()) {
298 continue;
299 }
300
301 auto path = dir_entry.path();
302 if (path.extension() != ".js" || path.filename().string().ends_with("_FIXTURE.js")) {
303 continue;
304 }
305
306 auto contentResult = Valdi::DiskUtils::load(Valdi::Path(path.string()));
307 if (!contentResult) {
308 TEST262_LOG(cerr, "Failed to load file {} with error {}", path, contentResult.error().getMessage());
309 return false;
310 }
311 auto content = contentResult.moveValue();
312 auto metadataResult = parseMetaData(string(content.asStringView()));
313 if (!metadataResult) {
314 TEST262_LOG(cerr, "Could not process metadata for file {}", path);
315 return false;
316 }
317 auto metadata = metadataResult.moveValue();
318
319 // NOTE(rjaber): For the tests cases these checks are not important since the typescript VM should be taking
320 // care of it.
321 if (metadata.isNegative && metadata.negativeType == "SyntaxError") {
322 continue;
323 }
324
325 // TODO(rjaber): Add relative into Valdi::Path, and move away from using c++ filesystem module
326 const auto directory = fs::path(test262Directory).parent_path();
327 const auto testFileRelative = fs::relative(path, directory).replace_extension("");
328 testCases[testFileRelative.string()] = metadata;
329 }
330
331 serializeTestCases(outputFile, testCases);
332 return true;
333}
334
335int main(int argc, const char* argv[]) {
336 fs::path testDirectory;

Callers 1

mainFunction · 0.85

Calls 9

loadFunction · 0.85
parseMetaDataFunction · 0.85
serializeTestCasesFunction · 0.85
pathMethod · 0.80
asStringViewMethod · 0.80
getMessageMethod · 0.65
errorMethod · 0.65
PathClass · 0.50
stringMethod · 0.45

Tested by

no test coverage detected