From 0e33cea65d6a4e44d560d595bb89f532feddf58e Mon Sep 17 00:00:00 2001 From: V13Axel Date: Wed, 7 Feb 2024 11:03:16 -0500 Subject: [PATCH] Automatically detect and use sail if it exists --- lua/neotest-pest/init.lua | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lua/neotest-pest/init.lua b/lua/neotest-pest/init.lua index afde6e6..48651c7 100644 --- a/lua/neotest-pest/init.lua +++ b/lua/neotest-pest/init.lua @@ -70,15 +70,26 @@ end ---@return neotest.RunSpec | nil function NeotestAdapter.build_spec(args) local position = args.tree:data() - local results_path = async.fn.tempname() + local results_path = "storage/app/" .. os.date("junit-%Y%m%d-%H%M%S") local binary = get_pest_cmd() - local command = vim.tbl_flatten({ - binary, - position.name ~= "tests" and position.path, - "--log-junit=" .. results_path, - }) + local command = {} + + if vim.fn.filereadable("vendor/bin/sail") then + command = vim.tbl_flatten({ + "vendor/bin/sail", "bin", "pest", + position.name ~= "tests" and ("/var/www/html" .. string.sub(position.path, string.len(vim.loop.cwd()) + 1)), + "--log-junit=" .. results_path, + }) + else + command = vim.tbl_flatten({ + binary, + position.name ~= "tests" and position.path, + "--log-junit=" .. results_path, + }) + end + if position.type == "test" then local script_args = vim.tbl_flatten({