diff options
Diffstat (limited to 'test/lua/visrc.lua')
| -rw-r--r-- | test/lua/visrc.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lua/visrc.lua b/test/lua/visrc.lua new file mode 100644 index 0000000..16aa8b9 --- /dev/null +++ b/test/lua/visrc.lua @@ -0,0 +1,28 @@ +package.path = '../../lua/?.lua;'..package.path +dofile("../../lua/vis.lua") + +-- redirect output to stdout, stderr is used by the vis UI +io.stderr = io.stdout + +-- make sure we gracefully terminate, cleanup terminal state etc. +os.exit = function(status) + vis:exit(status) +end + +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + -- test.in file passed to vis + local in_file = win.file.name + if in_file then + -- use the corresponding test.lua file + lua_file = string.gsub(in_file, '%.in$', '.lua') + local ok, msg = pcall(dofile, lua_file) + if not ok then + if type(msg) == 'string' then + print(msg) + end + vis:exit(1) + return + end + end + vis:exit(0) +end) |
