Yves-Marie Haussonne 0a2e282dae chore(util): Refactor Docker-related scripts for better modularity
Refactored Docker-related scripts to improve modularity and readability. Introduced support for loading configuration from `.mod_env.json` files, enhancing script flexibility. Added debug flag to enable detailed logging during script execution for better troubleshooting. Fixed file path issues related to script operations.
2024-10-10 14:41:48 +02:00

Docker Test Harness for Minetest Mods

Overview

This mod provides an automated testing framework for Minetest mods by simulating player behavior on a Minetest server. It allows developers to create, register, and run tests to ensure the correct behavior of their mods in various scenarios.

Features

  • Test Registration: Easily register custom tests for your mod.
  • Player Behavior Simulation: Simulate player actions for automatic testing.
  • Modular Structure: Each test is associated with a specific mod and can be customized.
  • Area and Node Manipulation: Test areas can be defined, and node checks can be performed.
  • Test Context and State Management: Manage and track the progress of tests across multiple mods.

Prerequisite

The tests are run using Docker or Podman. Therefor you'll need to have either one of them installed.

Usage

This mod's goal is to provide a test framework for implementing tests for minetest mods.

  1. Declare test_harness as an optional dependencies for your mod
  2. copy the .util folder in your project
  3. copy the .util/.mod_env.tmpl to .mod_env at the root of your folder.
  4. adapt its content. Do not remove the test_harness dependency definition.
  5. if necessary, customize the .util/Dockerfile to adapt the /etc/minetest/minetest.conf.base file to list the mods you want to test (test_harness_mods), and to adjust the server configuration to your project test settings.
  6. In your source files (in the init.lua for example) add the following lines (or equivalent)
    if minetest.settings:get_bool("test_harness_run_tests", false) then
        dofile(minetest.get_modpath("my_mod").. "/test/init.lua")
    end
    
  7. In your test file(s), get an instance of the method allowing the registration of your tests:
    local register_test = test_harness.get_test_registrator("my_mod", my_mod.version_string)
    
  8. Register the test by calling register_test
  9. Run the test by lauching the run_tests.sh script. For example with Podman
    $ .util/run_tests.sh --podman -c 1
    
    See the available options with .util/run_tests.sh --help

Sources

License

Licensed under the AGPL (Affero General Public License).

Funding

This mod is published with funding from the NLNet Foundation.

Description
No description provided
Readme 97 KiB
Languages
Lua 61.1%
Dockerfile 20.1%
Shell 18.8%