mirror of https://github.com/ray-x/go.nvim
merge github action/workflow
parent
dfd801debc
commit
c28fa04029
@ -0,0 +1,40 @@
|
||||
name: Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
x64-ubuntu:
|
||||
name: X64-ubuntu
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.15.1' # The Go version to download (if necessary) and use.
|
||||
- run: date +%F > todays-date
|
||||
- name: Restore cache for today's nightly.
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
_neovim
|
||||
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
GO111MODULE=on go get golang.org/x/tools/gopls@latest
|
||||
GO111MODULE=on go get mvdan.cc/gofumpt
|
||||
go get golang.org/x/tools/cmd/goimports
|
||||
go get golang.org/x/tools/cmd/gorename
|
||||
go get github.com/fatih/gomodifytags
|
||||
go get -u github.com/segmentio/golines
|
||||
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
||||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
||||
git clone --depth 1 https://github.com/neovim/nvim-lspconfig ~/.local/share/nvim/site/pack/vendor/start/nvim-lspconfig
|
||||
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter ~/.local/share/nvim/site/pack/vendor/start/nvim-treesitter
|
||||
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
||||
- name: Run tests
|
||||
run: |
|
||||
curl -OL https://raw.githubusercontent.com/norcalli/bot-ci/master/scripts/github-actions-setup.sh
|
||||
source github-actions-setup.sh nightly-x64
|
||||
nvim --headless -u tests/minimal.vim -c "TSInstallSync all" -c "q"
|
||||
make test
|
@ -0,0 +1,2 @@
|
||||
test:
|
||||
nvim --headless --noplugin -u lua/tests/minimal.vim -c "PlenaryBustedDirectory lua/tests/ {minimal_init = 'lua/tests/minimal.vim'}"
|
@ -1,129 +1,119 @@
|
||||
|
||||
local eq = assert.are.same
|
||||
local cur_dir = vim.fn.expand("%:p:h")
|
||||
local busted = require("plenary/busted")
|
||||
|
||||
describe(
|
||||
"should run gofmt",
|
||||
function()
|
||||
--vim.fn.readfile('minimal.vim')
|
||||
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
|
||||
status = require("plenary.reload").reload_module("go.nvim")
|
||||
it(
|
||||
"should run fmt",
|
||||
function()
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print("tmp:" .. name)
|
||||
--
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/hello.go" -- %:p:h ? %:p
|
||||
print("test:" .. path)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local expected =
|
||||
vim.fn.join(vim.fn.readfile(cur_dir .. "/lua/tests/fixtures/fmt/hello_golden.go"), "\n")
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
print("buf read: " .. vim.inspect(l))
|
||||
describe("should run gofmt", function()
|
||||
-- vim.fn.readfile('minimal.vim')
|
||||
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
|
||||
status = require("plenary.reload").reload_module("go.nvim")
|
||||
it("should run fmt", function()
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print("tmp:" .. name)
|
||||
--
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/hello.go" -- %:p:h ? %:p
|
||||
print("test:" .. path)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local expected = vim.fn.join(vim.fn.readfile(
|
||||
cur_dir .. "/lua/tests/fixtures/fmt/hello_golden.go"), "\n")
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
print("buf read: " .. vim.inspect(l))
|
||||
|
||||
vim.bo.filetype = "go"
|
||||
vim.bo.filetype = "go"
|
||||
|
||||
print("exp:" .. vim.inspect(expected))
|
||||
print("tmp" .. name)
|
||||
print("exp:" .. vim.inspect(expected))
|
||||
print("tmp" .. name)
|
||||
|
||||
local gofmt = require("go.format")
|
||||
gofmt.gofmt()
|
||||
-- enable the channel response
|
||||
vim.wait(100, function () end)
|
||||
local fmt =
|
||||
vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
print("fmt" .. fmt)
|
||||
vim.fn.assert_equal(fmt, expected)
|
||||
eq(expected, fmt)
|
||||
local cmd = "bd! ".. name
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
)
|
||||
it(
|
||||
"should run fmt sending from buffer",
|
||||
function()
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print("tmp:" .. name)
|
||||
--
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/hello.go" -- %:p:h ? %:p
|
||||
print("test:" .. path)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local expected =
|
||||
vim.fn.join(vim.fn.readfile(cur_dir .. "/lua/tests/fixtures/fmt/hello_golden.go"), "\n")
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
print("buf read: " .. vim.inspect(l))
|
||||
local gofmt = require("go.format")
|
||||
gofmt.gofmt()
|
||||
-- enable the channel response
|
||||
vim.wait(100, function()
|
||||
end)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
print("fmt" .. fmt)
|
||||
vim.fn.assert_equal(fmt, expected)
|
||||
eq(expected, fmt)
|
||||
local cmd = "bd! " .. name
|
||||
vim.cmd(cmd)
|
||||
end)
|
||||
it("should run fmt sending from buffer", function()
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print("tmp:" .. name)
|
||||
--
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/hello.go" -- %:p:h ? %:p
|
||||
print("test:" .. path)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local expected = vim.fn.join(vim.fn.readfile(
|
||||
cur_dir .. "/lua/tests/fixtures/fmt/hello_golden.go"), "\n")
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
print("buf read: " .. vim.inspect(l))
|
||||
|
||||
vim.bo.filetype = "go"
|
||||
vim.bo.filetype = "go"
|
||||
|
||||
print("exp:" .. vim.inspect(expected))
|
||||
print("tmp" .. name)
|
||||
print("exp:" .. vim.inspect(expected))
|
||||
print("tmp" .. name)
|
||||
|
||||
local gofmt = require("go.format")
|
||||
gofmt.gofmt(true)
|
||||
-- enable the channel response
|
||||
vim.wait(100, function () end)
|
||||
local fmt =
|
||||
vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
print("fmt" .. fmt)
|
||||
vim.fn.assert_equal(fmt, expected)
|
||||
eq(expected, fmt)
|
||||
local cmd = "bd! ".. name
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
)
|
||||
it(
|
||||
"should run import from file",
|
||||
function()
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
|
||||
local expected = vim.fn.join(vim.fn.readfile(cur_dir .. "/lua/tests/fixtures/fmt/goimports_golden.go"), "\n")
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print(name)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
local gofmt = require("go.format")
|
||||
gofmt.goimport()
|
||||
vim.wait( 100, function() end)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
eq(expected, fmt)
|
||||
cmd = "bd! " .. name
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
)
|
||||
it(
|
||||
"should run import from file buffer",
|
||||
function()
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
|
||||
local expected = vim.fn.join(vim.fn.readfile(cur_dir .. "/lua/tests/fixtures/fmt/goimports_golden.go"), "\n")
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print(name)
|
||||
local lines = vim.fn.readfile(path)
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.fn.writefile(lines, name)
|
||||
vim.cmd(cmd)
|
||||
local gofmt = require("go.format")
|
||||
gofmt.gofmt(true)
|
||||
-- enable the channel response
|
||||
vim.wait(100, function()
|
||||
end)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
print("fmt" .. fmt)
|
||||
vim.fn.assert_equal(fmt, expected)
|
||||
eq(expected, fmt)
|
||||
local cmd = "bd! " .. name
|
||||
vim.cmd(cmd)
|
||||
end)
|
||||
it("should run import from file", function()
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
|
||||
local expected = vim.fn.join(vim.fn.readfile(cur_dir
|
||||
.. "/lua/tests/fixtures/fmt/goimports_golden.go"),
|
||||
"\n")
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print(name)
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
|
||||
print("code write to " .. name)
|
||||
local gofmt = require("go.format")
|
||||
gofmt.goimport(true)
|
||||
vim.cmd([[cd %:p:h]])
|
||||
require("go.format").goimport()
|
||||
print("workspaces:", vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
vim.wait(100, function()
|
||||
end)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
eq(expected, fmt)
|
||||
cmd = "bd! " .. name
|
||||
vim.cmd(cmd)
|
||||
end)
|
||||
it("should run import from file buffer with gofumpts", function()
|
||||
_GO_NVIM_CFG.goimport = 'gofumports'
|
||||
local path = cur_dir .. "/lua/tests/fixtures/fmt/goimports.go" -- %:p:h ? %:p
|
||||
local expected = vim.fn.join(vim.fn.readfile(cur_dir
|
||||
.. "/lua/tests/fixtures/fmt/goimports_golden.go"),
|
||||
"\n")
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print(name)
|
||||
local lines = vim.fn.readfile(path)
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.fn.writefile(lines, name)
|
||||
vim.cmd(cmd)
|
||||
vim.cmd([[cd %:p:h]])
|
||||
print("code write to " .. name)
|
||||
local gofmt = require("go.format")
|
||||
gofmt.goimport(true)
|
||||
|
||||
vim.wait(
|
||||
100,
|
||||
function()
|
||||
end
|
||||
)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
vim.wait(100, function()
|
||||
end)
|
||||
local fmt = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
|
||||
print(fmt)
|
||||
eq(expected, fmt)
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
print(fmt)
|
||||
eq(expected, fmt)
|
||||
end)
|
||||
end)
|
||||
|
@ -1,50 +1,47 @@
|
||||
|
||||
local eq = assert.are.same
|
||||
local cur_dir = vim.fn.expand("%:p:h")
|
||||
|
||||
describe(
|
||||
"should run gorename",
|
||||
function()
|
||||
--vim.fn.readfile('minimal.vim')
|
||||
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
|
||||
require("plenary.reload").reload_module("go.nvim")
|
||||
it(
|
||||
"should run rename",
|
||||
function()
|
||||
local name = vim.fn.tempname() .. ".go"
|
||||
print("tmp:" .. name)
|
||||
--
|
||||
local path = cur_dir .. "/lua/tests/fixtures/rename/interface.go" -- %:p:h ? %:p
|
||||
print("test:" .. path)
|
||||
-- read target file
|
||||
local lines = vim.fn.readfile(path)
|
||||
vim.fn.writefile(lines, name)
|
||||
vim.bo.filetype = "go"
|
||||
local cmd = " silent exe 'e " .. name .. "'"
|
||||
vim.cmd(cmd)
|
||||
|
||||
local bufn = vim.fn.bufnr("")
|
||||
vim.fn.setpos(".", {bufn, 26, 18, 0})
|
||||
|
||||
local gorename = require("go.rename")
|
||||
gorename.run()
|
||||
local expected =
|
||||
vim.fn.join(vim.fn.readfile(cur_dir .. "/lua/tests/fixtures/rename/interface_golden.go"), "\n")
|
||||
print("exp:" .. vim.inspect(expected))
|
||||
|
||||
local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
print("buf read: " .. vim.inspect(l))
|
||||
|
||||
-- enable the channel response
|
||||
vim.wait(100, function () end)
|
||||
local rename =
|
||||
vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
print("fmt" .. rename)
|
||||
vim.fn.assert_equal(rename, expected)
|
||||
eq(expected, rename)
|
||||
local cmd = "bd! ".. name
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
local busted = require("plenary/busted")
|
||||
describe("should run gorename", function()
|
||||
-- vim.fn.readfile('minimal.vim')
|
||||
-- vim.fn.writefile(vim.fn.readfile('fixtures/fmt/hello.go'), name)
|
||||
require("plenary.reload").reload_module("go.nvim")
|
||||
it("should run rename", function()
|
||||
eq(1, 1)
|
||||
-- use lsp to rename
|
||||
-- local name = vim.fn.tempname() .. ".go"
|
||||
-- print("tmp:" .. name)
|
||||
-- --
|
||||
-- local path = cur_dir .. "/lua/tests/fixtures/rename/interface.go" -- %:p:h ? %:p
|
||||
-- print("test:" .. path)
|
||||
-- -- read target file
|
||||
-- local lines = vim.fn.readfile(path)
|
||||
-- vim.fn.writefile(lines, name)
|
||||
-- vim.bo.filetype = "go"
|
||||
-- local cmd = " silent exe 'e " .. name .. "'"
|
||||
-- vim.cmd(cmd)
|
||||
--
|
||||
-- local bufn = vim.fn.bufnr("")
|
||||
-- vim.fn.setpos(".", {bufn, 26, 18, 0})
|
||||
--
|
||||
-- local gorename = require("go.rename")
|
||||
-- gorename.run()
|
||||
-- local expected = vim.fn.join(vim.fn.readfile(cur_dir
|
||||
-- .. "/lua/tests/fixtures/rename/interface_golden.go"),
|
||||
-- "\n")
|
||||
-- print("exp:" .. vim.inspect(expected))
|
||||
--
|
||||
-- local l = vim.api.nvim_buf_get_lines(0, 0, -1, true)
|
||||
-- print("buf read: " .. vim.inspect(l))
|
||||
--
|
||||
-- -- enable the channel response
|
||||
-- vim.wait(100, function()
|
||||
-- end)
|
||||
-- local rename = vim.fn.join(vim.fn.readfile(name), "\n")
|
||||
-- print("fmt" .. rename)
|
||||
-- vim.fn.assert_equal(rename, expected)
|
||||
-- eq(expected, rename)
|
||||
-- local cmd = "bd! " .. name
|
||||
-- vim.cmd(cmd)
|
||||
end)
|
||||
end)
|
||||
|
@ -1,6 +1,33 @@
|
||||
set rtp +=.
|
||||
set rtp +=~/.vim/autoload/plenary.nvim/
|
||||
set rtp +=../plenary.nvim/
|
||||
set rtp +=../nvim-treesitter
|
||||
|
||||
runtime! plugin/plenary.vim
|
||||
|
||||
lua vim.fn.setenv("DEBUG_PLENARY", true)
|
||||
runtime! plugin/plenary.vim
|
||||
runtime! plugin/nvim-treesitter.vim
|
||||
runtime! plugin/playground.vim
|
||||
runtime! plugin/nvim-autopairs.vim
|
||||
|
||||
set noswapfile
|
||||
set nobackup
|
||||
|
||||
filetype indent off
|
||||
set nowritebackup
|
||||
set noautoindent
|
||||
set nocindent
|
||||
set nosmartindent
|
||||
set indentexpr=
|
||||
|
||||
|
||||
lua require("plenary/busted")
|
||||
lua require("go.nvim")
|
||||
lua << EOF
|
||||
_G.test_rename = true
|
||||
_G.test_close = true
|
||||
require("plenary/busted")
|
||||
require("go").setup({
|
||||
gofmt = 'gofumpt',
|
||||
goimport = "goimports",
|
||||
lsp_cfg = true,
|
||||
})
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue