Compare commits
6 Commits
master
...
chore-poc-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91e6b978e0 | ||
|
|
006b27dc0a | ||
|
|
63cd226c3e | ||
|
|
f9dc294829 | ||
|
|
2dcf249d49 | ||
|
|
9ac1e05fc8 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
/luals-out/
|
||||
/luals/
|
||||
/plenary.nvim/
|
||||
# backup vim files
|
||||
*~
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
"workspace": {
|
||||
"library": [
|
||||
"$VIMRUNTIME/lua/vim",
|
||||
"${3rd}/luv/library"
|
||||
"${3rd}/luv/library",
|
||||
"plenary.nvim"
|
||||
]
|
||||
},
|
||||
"diagnostics": {
|
||||
|
||||
13
Makefile
13
Makefile
@ -43,6 +43,19 @@ help-update:
|
||||
help-check: help-update
|
||||
git diff --exit-code doc/nvim-tree-lua.txt
|
||||
|
||||
#
|
||||
# test
|
||||
#
|
||||
test: plenary.nvim
|
||||
scripts/test.sh
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
# no plenary tags or releases available
|
||||
plenary.nvim:
|
||||
git clone git@github.com:nvim-lua/plenary.nvim.git
|
||||
|
||||
|
||||
.PHONY: all lint style check luacheck style-check style-doc luals style-fix help-update help-check
|
||||
|
||||
|
||||
@ -11,6 +11,10 @@ M.is_wsl = vim.fn.has("wsl") == 1
|
||||
-- false for WSL
|
||||
M.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
|
||||
|
||||
function M._is_windows()
|
||||
return vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1
|
||||
end
|
||||
|
||||
---@param haystack string
|
||||
---@param needle string
|
||||
---@return boolean
|
||||
@ -299,7 +303,7 @@ end
|
||||
---@param path string
|
||||
---@return string
|
||||
function M.canonical_path(path)
|
||||
if M.is_windows and path:match("^%a:") then
|
||||
if M._is_windows() and path:match("^%a:") then
|
||||
return path:sub(1, 1):upper() .. path:sub(2)
|
||||
end
|
||||
return path
|
||||
|
||||
25
scripts/test.sh
Executable file
25
scripts/test.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
DIR_REPO="$(git rev-parse --show-toplevel)"
|
||||
export DIR_REPO
|
||||
|
||||
DIR_PLENARY="${DIR_REPO}/plenary.nvim"
|
||||
export DIR_PLENARY
|
||||
|
||||
if [ "${#}" -eq 1 ]; then
|
||||
TEST_NAME="${1}"
|
||||
elif [ -z "${TEST_NAME}" ]; then
|
||||
TEST_NAME="tests"
|
||||
fi
|
||||
export TEST_NAME
|
||||
|
||||
echo "testing: ${TEST_NAME}"
|
||||
|
||||
nvim --headless \
|
||||
--clean \
|
||||
-u "${DIR_REPO}/tests/minimal_init.lua" \
|
||||
-l "${DIR_REPO}/tests/test_init.lua" \
|
||||
-c "qa!"
|
||||
|
||||
8
tests/minimal_init.lua
Normal file
8
tests/minimal_init.lua
Normal file
@ -0,0 +1,8 @@
|
||||
-- Prepend these as plenary appends a "." and plenary directory
|
||||
-- The spawned processes don't specify --clean so contain the full ~/.local runtime path
|
||||
vim.o.runtimepath = string.format(
|
||||
"%s,%s,%s",
|
||||
vim.env.DIR_REPO,
|
||||
vim.env.DIR_PLENARY,
|
||||
vim.o.runtimepath
|
||||
)
|
||||
9
tests/test_init.lua
Normal file
9
tests/test_init.lua
Normal file
@ -0,0 +1,9 @@
|
||||
local test_harness = require("plenary.test_harness")
|
||||
|
||||
test_harness.test_directory(
|
||||
vim.env.TEST_NAME,
|
||||
{
|
||||
minimal_init = vim.env.DIR_REPO .. "/tests/minimal_init.lua",
|
||||
sequential = true,
|
||||
}
|
||||
)
|
||||
30
tests/unit/utils_spec.lua
Normal file
30
tests/unit/utils_spec.lua
Normal file
@ -0,0 +1,30 @@
|
||||
---@type Luassert
|
||||
local assert = require("luassert")
|
||||
local stub = require("luassert.stub")
|
||||
|
||||
local utils = require("nvim-tree.utils")
|
||||
|
||||
describe("utils.path_add_trailing", function()
|
||||
it("trailing added", function()
|
||||
assert.equals("foo/", utils.path_add_trailing("foo"))
|
||||
end)
|
||||
|
||||
it("trailing already present", function()
|
||||
assert.equals("foo/", utils.path_add_trailing("foo/"))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("utils.canonical_path", function()
|
||||
before_each(function()
|
||||
stub(vim.fn, "has")
|
||||
end)
|
||||
|
||||
it("is windows", function()
|
||||
vim.fn.has.on_call_with("win32unix").returns(1)
|
||||
assert.equals("C:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"), "should be uppercase drive")
|
||||
end)
|
||||
|
||||
it("not windows", function()
|
||||
assert.equals("c:\\foo\\bar", utils.canonical_path("c:\\foo\\bar"))
|
||||
end)
|
||||
end)
|
||||
Loading…
Reference in New Issue
Block a user