diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-05-02 00:21:32 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-05-02 16:23:05 +0530 |
| commit | 00efc9757475b3b347fee0ce2aaccfbf4b1c33b5 (patch) | |
| tree | da75cc067b26afc4dc3b444ffafd68d17fcd947f /spec/main.cpp | |
| parent | 0da44615dcf97ad34b4576da8ef0b77f6c9fc01f (diff) | |
| download | null-browser-00efc9757475b3b347fee0ce2aaccfbf4b1c33b5.tar.gz null-browser-00efc9757475b3b347fee0ce2aaccfbf4b1c33b5.zip | |
Add a simple lua test suite + add utils spec + fix keymap spec
Diffstat (limited to 'spec/main.cpp')
| -rw-r--r-- | spec/main.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/spec/main.cpp b/spec/main.cpp index 15d0b60..1f60aea 100644 --- a/spec/main.cpp +++ b/spec/main.cpp @@ -1,8 +1,44 @@ +#include <QtCore> + +#include "LuaRuntime.hpp" #include "testUtils.h" -#include <QtWidgets/qapplication.h> + +int run_lua_tests() { + QString test_name = getenv("TEST_NAME"); + if (test_name.startsWith("lua ")) { + test_name = test_name.remove(0, 4); + } else if (!test_name.isEmpty()) + return 0; + + QDir dir("../spec/lua"); // TODO: relative to root instead of build/? + QStringList spec_files = dir.entryList(QDir::Files); + auto &lua = LuaRuntime::instance(); + + lua.start_event_loop(); + lua.require_module("null-browser.test-utils"); + + for (auto &file : spec_files) { + auto is_spec = file.endsWith("_spec.lua"); + auto should_run_spec = test_name.isEmpty() || file.contains(test_name); + if (is_spec && should_run_spec) { + qDebug() << "Running suite: " << file; + lua.load_file_sync(dir.filePath(file)); + } + } + + lua.stop_event_loop(); + + qDebug() << "Tests ran successfully"; + return 0; +} int main(int argc, char **argv) { QApplication app(argc, argv); - return run_all_tests(); + int exit_code_app = run_app_tests(); + int exit_code_lua = run_lua_tests(); + + if (exit_code_app != 0) + return exit_code_app; + return exit_code_lua; } |
