Skip to main content

Module harness

Module harness 

Source
Expand description

Test harness running Lua scripts outside of the game.

Scripts run in Lua 5.1, the version the games use, together with the real script libraries of the game (script/_lib) and, optionally, the vanilla scripts of a campaign. What the game’s C++ side provides is emulated by engine.lua: objects typed after the scripting docs that record every call made on them.

A test file registers tests with rpfm.test(name, function). Its top-level code runs before the game boots, so the world it sets up (rpfm.faction { key = "...", is_human = true }) exists when the scripts start. Each test then runs in its own Lua state, after the libraries, the mods of the tested packs and the first tick have run, so tests can’t affect each other.

Scripts are sandboxed: they can’t run programs, load native code or touch files outside of memory.

Structs§

LuaScripts
Scripts the harness can load, by path.
LuaTestOptions
Options of a test run.
LuaTestReport
Results of running a test file.
LuaTestResult
Result of a test.

Functions§

run_tests
This function runs the tests of a test file.