diff --git a/lua/neotest-golang/cmd.lua b/lua/neotest-golang/cmd.lua index 219a63a5..5b3c6f0d 100644 --- a/lua/neotest-golang/cmd.lua +++ b/lua/neotest-golang/cmd.lua @@ -80,45 +80,25 @@ function M.test_command_for_dir(module_name) end function M.gotest_with_args_for_dir(module_name) - local gotest = { + local cmd = { "go", "test", "-json", } - - local required_go_test_args = { - module_name, - } - - local combined_args = vim.list_extend( - vim.deepcopy(options.get().go_test_args), - required_go_test_args - ) - local cmd = vim.list_extend(vim.deepcopy(gotest), combined_args) - + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().go_test_args) + cmd = vim.list_extend(vim.deepcopy(cmd), { module_name }) return cmd end function M.gotestsum_with_args_cmd_for_dir(module_name, json_filepath) - local gotest = { "gotestsum" } - local gotestsum_json = { + local cmd = { + "gotestsum", "--jsonfile=" .. json_filepath, - "--", - } - - local required_go_test_args = { - module_name, } - - local gotest_args = vim.list_extend( - vim.deepcopy(options.get().go_test_args), - required_go_test_args - ) - - local cmd = - vim.list_extend(vim.deepcopy(gotest), options.get().gotestsum_args) - cmd = vim.list_extend(vim.deepcopy(cmd), gotestsum_json) - cmd = vim.list_extend(vim.deepcopy(cmd), gotest_args) + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().gotestsum_args) + cmd = vim.list_extend(vim.deepcopy(cmd), { "--" }) + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().go_test_args) + cmd = vim.list_extend(vim.deepcopy(cmd), { module_name }) return cmd end @@ -127,20 +107,16 @@ function M.gotest_with_args_for_individual_test( test_folder_absolute_path, test_name ) - --- @type table - local required_go_test_args = { test_folder_absolute_path, "-run", test_name } - - local gotest = { + local cmd = { "go", "test", "-json", } - - local combined_args = vim.list_extend( - vim.deepcopy(options.get().go_test_args), - required_go_test_args + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().go_test_args) + cmd = vim.list_extend( + vim.deepcopy(cmd), + { test_folder_absolute_path, "-run", test_name } ) - local cmd = vim.list_extend(vim.deepcopy(gotest), combined_args) return cmd end @@ -149,25 +125,17 @@ function M.gotestsum_with_args_for_individual_test( test_name, json_filepath ) - --- @type table - local required_go_test_args = { test_folder_absolute_path, "-run", test_name } - - local gotest = { "gotestsum" } - local gotestsum_json = { + local cmd = { + "gotestsum", "--jsonfile=" .. json_filepath, - "--", } - - local gotest_args = vim.list_extend( - vim.deepcopy(options.get().go_test_args), - required_go_test_args + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().gotestsum_args) + cmd = vim.list_extend(vim.deepcopy(cmd), { "--" }) + cmd = vim.list_extend(vim.deepcopy(cmd), options.get().go_test_args) + cmd = vim.list_extend( + vim.deepcopy(cmd), + { test_folder_absolute_path, "-run", test_name } ) - - local cmd = - vim.list_extend(vim.deepcopy(gotest), options.get().gotestsum_args) - cmd = vim.list_extend(vim.deepcopy(cmd), gotestsum_json) - cmd = vim.list_extend(vim.deepcopy(cmd), gotest_args) - return cmd end