mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 00:15:08 +00:00
Tests: Migrate to Directory::for_each_entry()
This commit is contained in:
parent
23aec16e8b
commit
728b07fbf6
3 changed files with 23 additions and 30 deletions
|
@ -5,13 +5,13 @@
|
|||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCpp/Parser.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <unistd.h>
|
||||
|
||||
constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/parser";
|
||||
constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/parser"sv;
|
||||
|
||||
static DeprecatedString read_all(DeprecatedString const& path)
|
||||
{
|
||||
|
@ -24,16 +24,13 @@ static DeprecatedString read_all(DeprecatedString const& path)
|
|||
|
||||
TEST_CASE(test_regression)
|
||||
{
|
||||
Core::DirIterator directory_iterator(TESTS_ROOT_DIR, Core::DirIterator::Flags::SkipDots);
|
||||
|
||||
while (directory_iterator.has_next()) {
|
||||
auto file_path = directory_iterator.next_full_path();
|
||||
|
||||
auto path = LexicalPath { file_path };
|
||||
MUST(Core::Directory::for_each_entry(TESTS_ROOT_DIR, Core::DirIterator::Flags::SkipDots, [](auto const& entry, auto const& directory) -> ErrorOr<IterationDecision> {
|
||||
auto path = LexicalPath::join(directory.path().string(), entry.name);
|
||||
if (!path.has_extension(".cpp"sv))
|
||||
continue;
|
||||
return IterationDecision::Continue;
|
||||
|
||||
outln("Checking {}...", path.basename());
|
||||
auto file_path = path.string();
|
||||
|
||||
auto ast_file_path = DeprecatedString::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
|
||||
|
||||
|
@ -75,5 +72,6 @@ TEST_CASE(test_regression)
|
|||
|
||||
auto equal = content == target_ast;
|
||||
EXPECT(equal);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue