update-cpp-test-results.cpp 1.5 KB

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