Support verbose logging during tests

This commit is contained in:
momo5502
2025-01-25 13:05:25 +01:00
parent d2b735c26e
commit d387477883
5 changed files with 28 additions and 2 deletions

View File

@@ -9,6 +9,15 @@ on:
- "**"
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
verbose:
description: "Enable verbose logging during tests"
type: choice
required: false
default: "false"
options:
- "true"
- "false"
#concurrency:
# group: ${{ github.ref }}
@@ -246,6 +255,7 @@ jobs:
run: cd build/${{matrix.preset}} && ctest --verbose
env:
EMULATOR_ROOT: ${{github.workspace}}/build/${{matrix.preset}}/artifacts/root
EMULATOR_VERBOSE: ${{ github.event.inputs.verbose }}
smoke-test-android:
name: Smoke Test Android

View File

@@ -111,6 +111,7 @@ namespace
.registry_directory = options.registry_path,
.emulation_root = options.emulation_root,
.arguments = parse_arguments(args),
.verbose_calls = options.verbose_logging,
.silent_until_main = options.concise_logging,
};
@@ -119,7 +120,6 @@ namespace
(void)&watch_system_objects;
watch_system_objects(win_emu, options.concise_logging);
win_emu.buffer_stdout = true;
win_emu.verbose_calls = options.verbose_logging;
const auto& exe = *win_emu.process().executable;

View File

@@ -21,9 +21,15 @@
namespace test
{
inline bool enable_verbose_logging()
{
const auto* env = getenv("EMULATOR_VERBOSE");
return env && (env == "1"sv || env == "true"sv);
}
inline std::filesystem::path get_emulator_root()
{
auto* env = getenv("EMULATOR_ROOT");
const auto* env = getenv("EMULATOR_ROOT");
if (!env)
{
throw std::runtime_error("No EMULATOR_ROOT set!");
@@ -34,6 +40,14 @@ namespace test
inline windows_emulator create_sample_emulator(emulator_settings settings, emulator_callbacks callbacks = {})
{
const auto is_verbose = enable_verbose_logging();
if (is_verbose)
{
settings.disable_logging = false;
settings.verbose_calls = true;
}
settings.application = "c:/test-sample.exe";
settings.emulation_root = get_emulator_root();
return windows_emulator{std::move(settings), std::move(callbacks)};

View File

@@ -838,6 +838,7 @@ windows_emulator::windows_emulator(const emulator_settings& settings, emulator_c
this->file_sys().set_working_directory(settings.application.parent());
}
this->verbose_calls = settings.verbose_calls;
this->silent_until_main_ = settings.silent_until_main && !settings.disable_logging;
this->use_relative_time_ = settings.use_relative_time;
this->log.disable_output(settings.disable_logging || this->silent_until_main_);

View File

@@ -32,6 +32,7 @@ struct emulator_settings
std::filesystem::path registry_directory{"./registry"};
std::filesystem::path emulation_root{};
std::vector<std::u16string> arguments{};
bool verbose_calls{false};
bool disable_logging{false};
bool silent_until_main{false};
bool use_relative_time{false};