@ -8,39 +8,39 @@ local utils = require("go.utils")
local empty = utils.empty
local run = function ( setup )
print ( vim.inspect ( setup ) )
local j = vim.fn . jobstart ( setup , {
on_stdout = function ( jobid , data , event )
vim.fn . jobstart ( setup , {
stdout_buffered = true ,
on_stdout = function ( _ , data , _ )
print ( " unit tests generate " .. vim.inspect ( data ) )
end ,
on_stderr = function ( _ , data , _ )
print ( " generate tests finished with message: " .. vim.inspect ( setup ) .. " error: " .. vim.inspect ( data ) )
end ,
} )
end
local add_test = function ( args )
require ( " go.install " ) . install ( gotests )
if string.len ( test_template ) > 1 then
local gofile = vim.fn . expand ( " % " )
table.insert ( args , " -w " )
table.insert ( args , gofile )
run ( args )
end
local new_gotests_args = function ( parallel )
local args = { gotests }
if parallel then
table.insert ( args , " -parallel " )
end
if string.len ( test_template ) > 0 then
table.insert ( args , " -template " )
table.insert ( args , test_template )
if string.len ( test_dir ) > 1 then
if string.len ( test_dir ) > 0 then
table.insert ( args , " -template_dir " )
table.insert ( args , test_dir )
end
end
local row , col = unpack ( vim.api . nvim_win_get_cursor ( 0 ) )
row , col = row + 1 , col + 1
local ns = require ( " go.ts.go " ) . get_func_method_node_at_pos ( row , col )
if empty ( ns ) then
return
end
utils.log ( " parnode " .. vim.inspect ( ns ) )
run ( args )
return args
end
ut.fun_test = function ( parallel )
parallel = parallel or false
local row , col = unpack ( vim.api . nvim_win_get_cursor ( 0 ) )
row , col = row + 1 , col + 1
local ns = require ( " go.ts.go " ) . get_func_method_node_at_pos ( row , col )
@ -51,31 +51,21 @@ ut.fun_test = function(parallel)
-- utils.log("parnode" .. vim.inspect(ns))
local funame = ns.name
-- local rs, re = ns.dim.s.r, ns.dim.e.r
local gofile = vim.fn . expand ( " % " )
local args = { gotests , " -w " , " -only " , funame , gofile }
if parallel then
table.insert ( args , " -parallel " )
end
local args = new_gotests_args ( parallel )
table.insert ( args , " -only " )
table.insert ( args , funame )
add_test ( args )
end
ut.all_test = function ( parallel )
parallel = parallel or false
local gofile = vim.fn . expand ( " % " )
local args = { gotests , " -all " , " -w " , gofile }
if parallel then
table.insert ( args , " -parallel " )
end
local args = new_gotests_args ( parallel )
table.insert ( args , " -all " )
add_test ( args )
end
ut.exported_test = function ( parallel )
parallel = parallel or false
local gofile = vim.fn . expand ( " % " )
local args = { gotests , " -exported " , " -w " , gofile }
if parallel then
table.insert ( args , " -parallel " )
end
local args = new_gotests_args ( parallel )
table.insert ( args , " -exported " )
add_test ( args )
end