mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 11:14:58 +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,12 +5,12 @@
|
|||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCpp/Parser.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/preprocessor";
|
||||
constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/preprocessor"sv;
|
||||
|
||||
static DeprecatedString read_all(DeprecatedString const& path)
|
||||
{
|
||||
|
@ -23,16 +23,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("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1));
|
||||
|
||||
|
@ -49,5 +46,6 @@ TEST_CASE(test_regression)
|
|||
for (size_t i = 0; i < tokens.size(); ++i) {
|
||||
EXPECT_EQ(tokens[i].to_deprecated_string(), target_lines[i]);
|
||||
}
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue