Quellcode durchsuchen

LibCodeComprehension: Prefer File::read_until_eof over DeprecatedFile

Note that LibTest/Macros.h and therefore the macro TRY_OR_FAIL are not
available, so using these would require some in-depth rework.

release_value_but_fixme_should_propagate_errors should generate a
reasonably obvious hint that the test didn't find some expected file.
Note that I intentionally did not choose MUST(), since it should be a
TRY_OR_FAIL() in some form.
Ben Wiederhake vor 2 Jahren
Ursprung
Commit
07dd719e3e
1 geänderte Dateien mit 2 neuen und 3 gelöschten Zeilen
  1. 2 3
      Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp

+ 2 - 3
Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp

@@ -89,9 +89,8 @@ int run_tests()
 
 static void add_file(FileDB& filedb, DeprecatedString const& name)
 {
-    auto file = Core::DeprecatedFile::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly);
-    VERIFY(!file.is_error());
-    filedb.add(name, DeprecatedString::copy(file.value()->read_all()));
+    auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
+    filedb.add(name, DeprecatedString::copy(MUST(file->read_until_eof())));
 }
 
 void test_complete_local_args()