[INIT]
This commit is contained in:
35
tests/_headless_single.lua
Normal file
35
tests/_headless_single.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local M = require('merged-repl-plugin')
|
||||
local main = [[/home/dai/projects/reperl.nvim/test_main_repo]]
|
||||
local repl = [[/home/dai/projects/reperl.nvim/test_repl_repo]]
|
||||
local rf = repl .. '/repl.pl'
|
||||
M.setup{ main_repo_path = main, repl_repo_path = repl, repl_file = rf, auto_start = false, output_target = 'file' }
|
||||
-- run one sync and capture result
|
||||
M.sync_once(function(err, res)
|
||||
local f = io.open([[/home/dai/projects/reperl.nvim/tests/sync_result.txt]], 'w')
|
||||
f:write(tostring(err) .. "\n")
|
||||
if res then f:write(vim.inspect(res) .. "\n") end
|
||||
f:close()
|
||||
end)
|
||||
-- ensure repl file exists (writing fresh, since sync may change working tree)
|
||||
local fh = io.open(rf, 'w')
|
||||
if fh then fh:write('print "Hello from REPL\n";') fh:close() end
|
||||
|
||||
-- run the repl; runner will write repl_output.log in the repl repo
|
||||
M.run_repl()
|
||||
-- wait up to 2s for the output file to appear
|
||||
local out_path = repl .. '/repl_output.log'
|
||||
local ok = vim.wait(2000, function()
|
||||
return vim.loop.fs_stat(out_path) ~= nil
|
||||
end, 50)
|
||||
if ok then
|
||||
-- copy to tests location for inspection
|
||||
local in_f = io.open(out_path, 'r')
|
||||
if in_f then
|
||||
local content = in_f:read('*a')
|
||||
in_f:close()
|
||||
local out_f = io.open([[/home/dai/projects/reperl.nvim/tests/repl_output_captured.log]], 'w')
|
||||
if out_f then out_f:write(content); out_f:close() end
|
||||
end
|
||||
end
|
||||
|
||||
vim.cmd('qa!')
|
||||
Reference in New Issue
Block a user