You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RegTest: can you include another file from a test file? #25
I would like to create a shared macros file for all my tests to include. Mostly macros that bring the game to the wanted state before the actual test starts.
For example, I want to add a test which specifically performs various checks on a given object. The object is in a room that you only reach after a few tens of commands, that I want to avoid repeating, for maintainability's sake. I could just include the macro from another file where it's defined once and for all, this would be very convenient.
I haven't found such a feature in the documentation, but maybe there's already a way? If not, please consider this a feature suggestion 🙏 .
I've worked on an implementation and am currently testing it. Here's what the addition to the doc would say:
A line beginning with "** include:" specifies a file to include at that point in the test file. The included file is parsed recursively; its tests, directives, and nested includes take effect as if the content were pasted inline. File paths are resolved relative to the directory of the file containing the ** include: directive. You can use multiple ** include: lines to include several files.
Because included content is parsed inline, directives in included files follow the same rules as in the main file: ** game: overrides any prior value, ** precommand: appends to the precommand list, and so on. Test names must be unique across all files. A duplicate test name will cause an error. Circular includes (A includes B which includes A) are also an error.
An included file can contain anything the main file can: top-level directives, test definitions, comments, and even more ** include: lines.
Activity
erkyrath commentedon Sep 7, 2025
Nope, there is no such feature at present. It's a reasonable suggestion. Possibly as
However, it's not entirely trivial to implement, so I can't promise I'll pick it up soon.
Thanks for the idea, though.
stormi commentedon Sep 8, 2025
Just a way to include another file on top would already be very useful, and possibly easier to implement.
I would just include "lib" files that define reusable "macros" (tests that start with
_) on top of my test files.erkyrath commentedon Sep 9, 2025
Good point, thanks.
stormi commentedon Jul 26, 2026
I've worked on an implementation and am currently testing it. Here's what the addition to the doc would say:
A line beginning with
"** include:"specifies a file to include at that point in the test file. The included file is parsed recursively; its tests, directives, and nested includes take effect as if the content were pasted inline. File paths are resolved relative to the directory of the file containing the** include:directive. You can use multiple** include:lines to include several files.Because included content is parsed inline, directives in included files follow the same rules as in the main file:
** game:overrides any prior value,** precommand:appends to the precommand list, and so on. Test names must be unique across all files. A duplicate test name will cause an error. Circular includes (A includes B which includes A) are also an error.An included file can contain anything the main file can: top-level directives, test definitions, comments, and even more
** include:lines.