Module luatest.treegen
Working tree generator.
Generates a tree of Lua files using provided templates and filenames.
local t = require('luatest')
local treegen = require('luatest.treegen')
local g = t.group()
g.test_foo = function(g)
treegen.add_template('^.*$', 'test_script')
local dir = treegen.prepare_directory({'foo/bar.lua', 'main.lua'})
...
end
Save the template with the given pattern.
Parameters:
Create a temporary directory with given contents.
The contents are generated using templates added by treegen.add_template().
Parameters:
- contents: (tab) List of bodies of the content to write.
- replacements: (tab) List of replacement templates. (optional)
Returns:
string
Example for {'foo/bar.lua', 'baz.lua'}:
/
+ tmp/
+ rfbWOJ/
+ foo/
| + bar.lua
+ baz.lua
The return value is '/tmp/rfbWOJ' for this example.