fix: search runtime for python script
See https://github.com/nvim-neotest/neotest/issues/118
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
local async = require("neotest.async")
|
local async = require("neotest.async")
|
||||||
local Path = require("plenary.path")
|
|
||||||
local lib = require("neotest.lib")
|
local lib = require("neotest.lib")
|
||||||
local base = require("neotest-python.base")
|
local base = require("neotest-python.base")
|
||||||
|
|
||||||
local function script_path()
|
local function get_script()
|
||||||
local str = debug.getinfo(2, "S").source:sub(2)
|
local paths = vim.api.nvim_get_runtime_file("neotest.py", true)
|
||||||
return str:match(("(.*%s)"):format(lib.files.sep))
|
for _, path in ipairs(paths) do
|
||||||
end
|
if vim.endswith(path, ("neotest-python%sneotest.py"):format(lib.files.sep)) then
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local python_script = (Path.new(script_path()):parent():parent() / "neotest.py").filename
|
error("neotest.py not found")
|
||||||
|
end
|
||||||
|
|
||||||
local dap_args
|
local dap_args
|
||||||
local is_test_file = base.is_test_file
|
local is_test_file = base.is_test_file
|
||||||
@@ -104,9 +107,7 @@ function PythonNeotestAdapter.build_spec(args)
|
|||||||
local position = args.tree:data()
|
local position = args.tree:data()
|
||||||
local results_path = async.fn.tempname()
|
local results_path = async.fn.tempname()
|
||||||
local stream_path = async.fn.tempname()
|
local stream_path = async.fn.tempname()
|
||||||
local x = io.open(stream_path, "w")
|
lib.files.write(stream_path, "")
|
||||||
x:write("")
|
|
||||||
x:close()
|
|
||||||
|
|
||||||
local root = PythonNeotestAdapter.root(position.path)
|
local root = PythonNeotestAdapter.root(position.path)
|
||||||
local python = get_python(root)
|
local python = get_python(root)
|
||||||
@@ -127,7 +128,7 @@ function PythonNeotestAdapter.build_spec(args)
|
|||||||
end
|
end
|
||||||
local command = vim.tbl_flatten({
|
local command = vim.tbl_flatten({
|
||||||
python,
|
python,
|
||||||
python_script,
|
get_script(),
|
||||||
script_args,
|
script_args,
|
||||||
})
|
})
|
||||||
local strategy_config = get_strategy_config(args.strategy, python, python_script, script_args)
|
local strategy_config = get_strategy_config(args.strategy, python, python_script, script_args)
|
||||||
|
Reference in New Issue
Block a user