From 7958e82a25a853caab17757c844f8acd05b045e8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 14 Sep 2026 22:16:18 +0300 Subject: [PATCH] add '--debugger' argument to vctest --- .github/workflows/appimage.yml | 2 +- .github/workflows/macos.yml | 2 +- vctest/main.cpp | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 8d05f59b3..0d7670934 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -52,7 +52,7 @@ jobs: run: | chmod +x build/VoxelEngine chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build + AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --memchecker valgrind - name: Build AppImage uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910 env: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2bcb56dda..b4d9f6328 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -49,7 +49,7 @@ jobs: run: | chmod +x build/VoxelEngine chmod +x AppDir/usr/bin/vctest - AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --memchecker "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " + AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- " - name: Create DMG run: | mkdir VoxelEngineDmgContent diff --git a/vctest/main.cpp b/vctest/main.cpp index 953d59aa9..99eebaacd 100644 --- a/vctest/main.cpp +++ b/vctest/main.cpp @@ -16,7 +16,8 @@ struct Config { fs::path directory; fs::path resDir {"res"}; fs::path workingDir {"."}; - std::string memchecker = "valgrind"; + std::string memchecker = ""; + std::string debugger = ""; bool outputAlways = false; }; @@ -30,6 +31,7 @@ static bool perform_keyword( std::cout << " --tests , -d = tests directory path\n"; std::cout << " --res , -r = 'res' directory path\n"; std::cout << " --user , -u = user directory path\n"; + std::cout << " --debugger = debugger with run command\n"; std::cout << " --memchecker = path to valgrind\n"; std::cout << " --output-always = always show tests output\n"; std::cout << std::endl; @@ -44,6 +46,8 @@ static bool perform_keyword( config.workingDir = fs::path(reader.next()); } else if (keyword == "--output-always") { config.outputAlways = true; + } else if (keyword == "--debugger") { + config.debugger = reader.next(); } else if (keyword == "--memchecker") { config.memchecker = reader.next(); } else { @@ -172,7 +176,7 @@ static std::string fix_path(std::string s) { return s; } -static bool run_test(const Config& config, const fs::path& path, bool memcheck = false) { +static bool run_test(const Config& config, const fs::path& path, bool debugRun = false) { using std::chrono::duration_cast; using std::chrono::high_resolution_clock; using std::chrono::milliseconds; @@ -182,9 +186,16 @@ static bool run_test(const Config& config, const fs::path& path, bool memcheck = auto name = path.stem(); std::stringstream ss; - if (memcheck) { - ss << config.memchecker << /*" --log-file=" - << fix_path(memcheckLogFile.string()) <<*/ " "; + if (debugRun) { + if (!config.memchecker.empty()) { + ss << config.memchecker; + ss << " --log-file=" << fix_path(memcheckLogFile.string()); + ss << " "; + } + if (!config.debugger.empty()) { + ss << config.debugger; + ss << " "; + } } ss << fs::canonical(config.executable) << " --headless"; ss << " --test " << fix_path(path.string()); @@ -203,7 +214,7 @@ static bool run_test(const Config& config, const fs::path& path, bool memcheck = .count(); if (code) { - if (memcheck) { + if (debugRun) { // valgrind-specific output display_segfault_valgrind(memcheckLogFile, name, std::cerr); fs::remove(memcheckLogFile);