diff --git a/Libraries/LibCore/File.cpp b/Libraries/LibCore/File.cpp index 27f36fdd4018..a2f26cf7eb05 100644 --- a/Libraries/LibCore/File.cpp +++ b/Libraries/LibCore/File.cpp @@ -7,15 +7,11 @@ #include #include -#include #if !defined(AK_OS_WINDOWS) # include #else -# include -# define STDIN_FILENO _fileno(stdin) -# define STDOUT_FILENO _fileno(stdout) -# define STDERR_FILENO _fileno(stderr) +# include #endif namespace Core { diff --git a/Libraries/LibCore/System.h b/Libraries/LibCore/System.h index 323982dd880a..c68f21b95c10 100644 --- a/Libraries/LibCore/System.h +++ b/Libraries/LibCore/System.h @@ -33,7 +33,11 @@ # include #else # include "SocketAddressWindows.h" +# include # define O_CLOEXEC O_NOINHERIT +# define STDIN_FILENO _get_osfhandle(_fileno(stdin)) +# define STDOUT_FILENO _get_osfhandle(_fileno(stdout)) +# define STDERR_FILENO _get_osfhandle(_fileno(stderr)) # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) using sighandler_t = void (*)(int); diff --git a/Libraries/LibCore/SystemWindows.cpp b/Libraries/LibCore/SystemWindows.cpp index fec598601ef4..9194af4a8d7a 100644 --- a/Libraries/LibCore/SystemWindows.cpp +++ b/Libraries/LibCore/SystemWindows.cpp @@ -263,4 +263,9 @@ u64 physical_memory_bytes() return ms.ullTotalPhys; } +ErrorOr isatty(int handle) +{ + return GetFileType(to_handle(handle)) == FILE_TYPE_CHAR; +} + } diff --git a/UI/Headless/Fixture.cpp b/UI/Headless/Fixture.cpp index d17281e599b1..9254e6c80109 100644 --- a/UI/Headless/Fixture.cpp +++ b/UI/Headless/Fixture.cpp @@ -47,6 +47,9 @@ class HttpEchoServerFixture final : public Fixture { ErrorOr HttpEchoServerFixture::setup(WebView::WebContentOptions& web_content_options) { +#ifdef AK_OS_WINDOWS + VERIFY(0 && "Ladybird::HttpEchoServerFixture::setup is not implemented"); +#else auto const script_path = LexicalPath::join(s_fixtures_path, m_script_path); auto const arguments = Vector { script_path.string(), "--directory", Ladybird::Application::the().test_root_path }; @@ -81,10 +84,14 @@ ErrorOr HttpEchoServerFixture::setup(WebView::WebContentOptions& web_conte warnln("Failed to read echo server port from buffer: '{}'", raw_output); return {}; +#endif } void HttpEchoServerFixture::teardown_impl() { +#ifdef AK_OS_WINDOWS + VERIFY(0 && "Ladybird::HttpEchoServerFixture::teardown_impl is not implemented"); +#else VERIFY(m_process.has_value()); auto script_path = LexicalPath::join(s_fixtures_path, m_script_path); @@ -98,6 +105,7 @@ void HttpEchoServerFixture::teardown_impl() } m_process = {}; +#endif } void Fixture::initialize_fixtures() diff --git a/UI/Headless/Test.cpp b/UI/Headless/Test.cpp index 50ce346d5d0d..e82381696362 100644 --- a/UI/Headless/Test.cpp +++ b/UI/Headless/Test.cpp @@ -182,7 +182,7 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t return TestResult::Pass; } - auto const color_output = isatty(STDOUT_FILENO) ? Diff::ColorOutput::Yes : Diff::ColorOutput::No; + auto const color_output = TRY(Core::System::isatty(STDOUT_FILENO)) ? Diff::ColorOutput::Yes : Diff::ColorOutput::No; if (color_output == Diff::ColorOutput::Yes) outln("\n\033[33;1mTest failed\033[0m: {}", url); @@ -531,7 +531,7 @@ ErrorOr run_tests(Core::AnonymousBuffer const& theme, Web::DevicePixelSize bool all_tests_ok = true; // Keep clearing and reusing the same line if stdout is a TTY. - bool log_on_one_line = app.verbosity < Application::VERBOSITY_LEVEL_LOG_TEST_DURATION && isatty(STDOUT_FILENO) == 1; + bool log_on_one_line = app.verbosity < Application::VERBOSITY_LEVEL_LOG_TEST_DURATION && TRY(Core::System::isatty(STDOUT_FILENO)); outln("Running {} tests...", tests.size()); auto all_tests_complete = Core::Promise::construct(); diff --git a/UI/Headless/main.cpp b/UI/Headless/main.cpp index 158d659e8af2..0057787f0a12 100644 --- a/UI/Headless/main.cpp +++ b/UI/Headless/main.cpp @@ -61,6 +61,8 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor ErrorOr serenity_main(Main::Arguments arguments) { + AK::set_rich_debug_enabled(true); + WebView::platform_init(); auto app = Ladybird::Application::create(arguments, "about:newtab"sv);