Serenity Operating System
at master 39 lines 1.6 kB view raw
1/* 2 * Copyright (c) 2022, Itamar S. <itamar8910@gmail.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <AK/Format.h> 8#include <AK/LexicalPath.h> 9#include <LibCore/Command.h> 10#include <LibCore/DirIterator.h> 11#include <LibCore/StandardPaths.h> 12#include <LibMain/Main.h> 13 14ErrorOr<int> serenity_main(Main::Arguments) 15{ 16 Core::DirIterator parser_tests(LexicalPath::join(Core::StandardPaths::home_directory(), "Tests/cpp-tests/parser"sv).string()); 17 while (parser_tests.has_next()) { 18 auto cpp_full_path = parser_tests.next_full_path(); 19 if (!cpp_full_path.ends_with(".cpp"sv)) 20 continue; 21 auto ast_full_path = cpp_full_path.replace(".cpp"sv, ".ast"sv, ReplaceMode::FirstOnly); 22 outln("{}", cpp_full_path); 23 auto res = Core::command("/bin/sh", { "-c", DeprecatedString::formatted("cpp-parser {} > {}", cpp_full_path, ast_full_path) }, {}); 24 VERIFY(!res.is_error()); 25 } 26 27 Core::DirIterator preprocessor_tests(LexicalPath::join(Core::StandardPaths::home_directory(), "Tests/cpp-tests/preprocessor"sv).string()); 28 while (preprocessor_tests.has_next()) { 29 auto cpp_full_path = preprocessor_tests.next_full_path(); 30 if (!cpp_full_path.ends_with(".cpp"sv)) 31 continue; 32 auto ast_full_path = cpp_full_path.replace(".cpp"sv, ".txt"sv, ReplaceMode::FirstOnly); 33 outln("{}", cpp_full_path); 34 auto res = Core::command("/bin/sh", { "-c", DeprecatedString::formatted("cpp-preprocessor {} > {}", cpp_full_path, ast_full_path) }, {}); 35 VERIFY(!res.is_error()); 36 } 37 38 return 0; 39}