18 Commits

Author SHA1 Message Date
Yves-Marie Haussonne
d97e252372 chore(base): refactor variable names for clarity
Refactored loops to correctly count the number of mods in `tests_mod_list`.
2024-10-06 10:31:07 +02:00
Yves-Marie Haussonne
f8dbd2360a debug 2024-10-06 10:13:27 +02:00
Yves-Marie Haussonne
861f71da9d refactor(base): rename register_test to register_test_template
Renamed `register_test` to `register_test_template` for clarity and consistency with its purpose of defining a test template in the base.lua file.
2024-10-06 09:35:03 +02:00
Yves-Marie Haussonne
8de4cc3964 feat(tests): enhance test framework for minetest mods
- Enhance instructions in the README for setting up and running tests with the test framework.
- Develop modules for registering and running tests within mods.
- Provide a mechanism to control which mods are tested through `test_harness_mods` setting.
- Improve summary display logic for test results and categorize them (passed, failed, skipped, dnr).
- Refactor scripts for better management of test execution and handling various cases.
2024-10-06 09:19:43 +02:00
Yves-Marie Haussonne
b322a1b6b1 fix(base.lua): fix 'skip' status in test result output
Corrected the displayed status of skipped tests from 'skip' to 'dnr' (short for 'did not run'). This change ensures better clarity in the test summary by accurately reflecting the status of each test. The modification impacts the visual representation of skipped tests, enhancing the overall readability of the test results.
2024-10-04 15:45:46 +02:00
Yves-Marie Haussonne
ad261f3e41 chore(base.lua): refactor test result printing and cleanup
Refactor the code to extract the test result printing logic into a separate function, `print_result_line`, to improve readability and reduce code duplication. This change aims to enhance maintainability by consolidating similar print statements and ensuring consistent display of test results across the script.
2024-10-04 14:21:06 +02:00
Yves-Marie Haussonne
0fafeb9f52 refactor(test_harness): improve test handling and display
Refactored the `run_player_tests` function in `base.lua` to improve error handling and the way test results are displayed. Tests now run asynchronously and reschedule remaining tests if necessary. Added clearer output for skipped tests and improved failure reporting.
2024-10-04 12:13:59 +02:00
Yves-Marie Haussonne
e8235378d9 style(base.lua): enhance test summary display
Enhanced the display of test summaries in `base.lua` for better readability and alignment. Increased the width of formatted strings from 60 to 80 characters, providing a more spacious layout for test outputs
2024-10-04 01:36:49 +02:00
Yves-Marie Haussonne
8f77cd456c feat(colors): add color management for console output
Add color management functionality sourced from 'lua-chroma' library, introducing various color escape sequences for enhanced console output formatting. Implemented a `pprint` function for formatted printing with color support, enabling structured and visually enhanced display in the console for tests and results.

This commit enhances readability and visual differentiation in test summary displays through color-coded outputs, highlighting test status and errors effectively.
2024-10-04 01:29:54 +02:00
Yves-Marie Haussonne
3bc13b5c9f feat[player]: Save and restore player inventories during test
Save complete players inventories, and added unit tests on players
2024-10-02 19:59:39 +02:00
Yves-Marie Haussonne
cb66508e19 refactor(base.lua): improve test completion logic
Refactored the test completion logic in the `run_tests` function for better readability and maintainability. Removed redundant check for `minetest.settings:get_bool("test_harness_stop_server", true)` and streamlined the conditional flow based on `tests_state`. This change enhances code clarity without altering functionality significantly.
2024-10-02 12:36:45 +02:00
Yves-Marie Haussonne
02f78d379b chore(ci): update packaging script output directory
Adjusted the packaging script in `.gitlab-ci.yml` to save artifacts in `/tmp/` for improved storage management and accessibility. Additionally, fixed a conditional statement in `base.lua` to properly handle the failfast option during testing.
2024-10-02 12:15:03 +02:00
Yves-Marie Haussonne
4475ebb556 debug 2024-10-02 11:31:19 +02:00
Yves-Marie Haussonne
514e089214 fix(tests): change 'break' to 'return' in run_tests
Changing 'break' to 'return' in the run_tests function to stop the test loop when a failure occurs, improving test harness behavior by returning from the function instead of breaking out of the loop.
2024-10-02 11:24:24 +02:00
Yves-Marie Haussonne
199abfba88 refactor(base.lua): improve run_tests function logic
Refactor the run_tests function in base.lua to enhance its logic and readability. The changes ensure proper handling of the tests_state enumeration.
2024-10-02 11:12:18 +02:00
Yves-Marie Haussonne
14860ab625 fix(testing): ensure mod validity in get_test_registrator
Check if the provided mod name is valid by iterating through the registered mod names before allowing test registration.
2024-10-02 08:07:56 +02:00
Yves-Marie Haussonne
b40bbafd4c feat(tests): introduce modular test registration
- Adds support for registering tests under specific modules to enhance organization and categorization.
- Introduces `register_test` function scoped within a module using `get_test_registrator`.
- Track tests by module for improved visibility and management.
- Enhances test output formatting to include module information alongside test names.
2024-10-02 01:42:45 +02:00
Yves-Marie Haussonne
6514938564 Add generic test harness lib. test itself 2024-10-01 19:00:24 +02:00