|
@@ -10,6 +10,7 @@
|
|
#include <AK/URLParser.h>
|
|
#include <AK/URLParser.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/ArgsParser.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibCore/File.h>
|
|
|
|
+#include <LibCore/Stream.h>
|
|
#include <LibMain/Main.h>
|
|
#include <LibMain/Main.h>
|
|
#include <LibXML/DOM/Document.h>
|
|
#include <LibXML/DOM/Document.h>
|
|
#include <LibXML/DOM/Node.h>
|
|
#include <LibXML/DOM/Node.h>
|
|
@@ -370,8 +371,8 @@ static auto parse(StringView contents)
|
|
if (url.scheme() != "file")
|
|
if (url.scheme() != "file")
|
|
return Error::from_string_literal("NYI: Nonlocal entity");
|
|
return Error::from_string_literal("NYI: Nonlocal entity");
|
|
|
|
|
|
- auto file = TRY(Core::File::open(url.path(), Core::OpenMode::ReadOnly));
|
|
|
|
- return String::copy(file->read_all());
|
|
|
|
|
|
+ auto file = TRY(Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read));
|
|
|
|
+ return String::copy(TRY(file->read_all()));
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
@@ -439,7 +440,7 @@ static void do_run_tests(XML::Document& document)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- auto file_result = Core::File::open(url.path(), Core::OpenMode::ReadOnly);
|
|
|
|
|
|
+ auto file_result = Core::Stream::File::open(url.path(), Core::Stream::OpenMode::Read);
|
|
if (file_result.is_error()) {
|
|
if (file_result.is_error()) {
|
|
warnln("Read error for {}: {}", url.path(), file_result.error());
|
|
warnln("Read error for {}: {}", url.path(), file_result.error());
|
|
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
@@ -449,7 +450,12 @@ static void do_run_tests(XML::Document& document)
|
|
warnln("Running test {}", url.path());
|
|
warnln("Running test {}", url.path());
|
|
|
|
|
|
auto contents = file_result.value()->read_all();
|
|
auto contents = file_result.value()->read_all();
|
|
- auto parser = parse(contents);
|
|
|
|
|
|
+ if (contents.is_error()) {
|
|
|
|
+ warnln("Read error for {}: {}", url.path(), contents.error());
|
|
|
|
+ s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ auto parser = parse(contents.value());
|
|
auto doc_or_error = parser.parse();
|
|
auto doc_or_error = parser.parse();
|
|
if (doc_or_error.is_error()) {
|
|
if (doc_or_error.is_error()) {
|
|
if (type == "invalid" || type == "error" || type == "not-wf")
|
|
if (type == "invalid" || type == "error" || type == "not-wf")
|
|
@@ -462,14 +468,19 @@ static void do_run_tests(XML::Document& document)
|
|
auto out = suite.attributes.find("OUTPUT");
|
|
auto out = suite.attributes.find("OUTPUT");
|
|
if (out != suite.attributes.end()) {
|
|
if (out != suite.attributes.end()) {
|
|
auto out_path = LexicalPath::join(test_base_path, out->value).string();
|
|
auto out_path = LexicalPath::join(test_base_path, out->value).string();
|
|
- auto file_result = Core::File::open(out_path, Core::OpenMode::ReadOnly);
|
|
|
|
|
|
+ auto file_result = Core::Stream::File::open(out_path, Core::Stream::OpenMode::Read);
|
|
if (file_result.is_error()) {
|
|
if (file_result.is_error()) {
|
|
warnln("Read error for {}: {}", out_path, file_result.error());
|
|
warnln("Read error for {}: {}", out_path, file_result.error());
|
|
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
auto contents = file_result.value()->read_all();
|
|
auto contents = file_result.value()->read_all();
|
|
- auto parser = parse(contents);
|
|
|
|
|
|
+ if (contents.is_error()) {
|
|
|
|
+ warnln("Read error for {}: {}", out_path, contents.error());
|
|
|
|
+ s_test_results.set(url.path(), TestResult::RunnerFailed);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ auto parser = parse(contents.value());
|
|
auto out_doc_or_error = parser.parse();
|
|
auto out_doc_or_error = parser.parse();
|
|
if (out_doc_or_error.is_error()) {
|
|
if (out_doc_or_error.is_error()) {
|
|
warnln("Parse error for {}: {}", out_path, out_doc_or_error.error());
|
|
warnln("Parse error for {}: {}", out_path, out_doc_or_error.error());
|
|
@@ -505,8 +516,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
parser.parse(arguments);
|
|
parser.parse(arguments);
|
|
|
|
|
|
s_path = Core::File::real_path_for(filename);
|
|
s_path = Core::File::real_path_for(filename);
|
|
- auto file = TRY(Core::File::open(s_path, Core::OpenMode::ReadOnly));
|
|
|
|
- auto contents = file->read_all();
|
|
|
|
|
|
+ auto file = TRY(Core::Stream::File::open(s_path, Core::Stream::OpenMode::Read));
|
|
|
|
+ auto contents = TRY(file->read_all());
|
|
|
|
|
|
auto xml_parser = parse(contents);
|
|
auto xml_parser = parse(contents);
|
|
auto result = xml_parser.parse();
|
|
auto result = xml_parser.parse();
|