diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89f96ca..4c2d1f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,19 @@ jobs: - name: install plenary.nvim run: | - 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/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary + # git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim - - name: run test + - name: setup tools shell: bash run: | luarocks install luacheck luarocks install vusted - vusted + + - name: Run tests + shell: bash + env: + VUSTED_NVIM: ${{ steps.vim.outputs.executable }} + VUSTED_ARGS: "--headless" + run: | + make test diff --git a/.luacheckrc b/.luacheckrc index fc60a60..fe54381 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,10 +1,9 @@ -self = false - -ignore = { -} -read_globals = { - "vim", - "describe", - "it", - "assert" +globals = { + 'vim', + 'describe', + 'it', + 'before_each', + 'after_each', + 'assert', + 'async', } diff --git a/Makefile b/Makefile index e5f2bc2..553ca06 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,4 @@ +# GIT_WORKTREE_NVIM_LOG=fatal +.PHONY: test test: - GIT_WORKTREE_NVIM_LOG=fatal nvim --headless --noplugin -u tests/minimal_init.vim -c "PlenaryBustedDirectory tests/ { minimal_init = './tests/minimal_init.vim' }" + vusted --output=gtest ./lua diff --git a/spec/config_spec.lua b/lua/git-worktree/config_spec.lua similarity index 100% rename from spec/config_spec.lua rename to lua/git-worktree/config_spec.lua diff --git a/spec/git_spec.lua b/lua/git-worktree/git_spec.lua similarity index 96% rename from spec/git_spec.lua rename to lua/git-worktree/git_spec.lua index f3ae6b9..0730c87 100644 --- a/spec/git_spec.lua +++ b/lua/git-worktree/git_spec.lua @@ -1,4 +1,4 @@ -local git_harness = require('util.git_harness') +local git_harness = require('git-worktree.test.git_util') local gwt_git = require('git-worktree.git') local Status = require('git-worktree.status') diff --git a/spec/setup_spec.lua b/lua/git-worktree/setup_spec.lua similarity index 100% rename from spec/setup_spec.lua rename to lua/git-worktree/setup_spec.lua diff --git a/spec/util/git_harness.lua b/lua/git-worktree/test/git_util.lua similarity index 93% rename from spec/util/git_harness.lua rename to lua/git-worktree/test/git_util.lua index d797214..3ba318d 100644 --- a/spec/util/git_harness.lua +++ b/lua/git-worktree/test/git_util.lua @@ -1,4 +1,4 @@ -local system = require('util.system') +local system = require('git-worktree.test.system_util') local M = {} @@ -11,7 +11,7 @@ function M.setup_origin_repo() local workspace_dir = system.create_temp_dir('workspace-dir') vim.api.nvim_set_current_dir(vim.fn.getcwd()) - system.run('cp -r spec/.repo ' .. workspace_dir) + system.run('cp -r test/fixtures/.repo ' .. workspace_dir) vim.api.nvim_set_current_dir(workspace_dir) system.run([[ mv .repo/.git-orig ./.git diff --git a/spec/util/system.lua b/lua/git-worktree/test/system_util.lua similarity index 100% rename from spec/util/system.lua rename to lua/git-worktree/test/system_util.lua diff --git a/spec/.repo/.git-orig/COMMIT_EDITMSG b/test/fixtures/.repo/.git-orig/COMMIT_EDITMSG similarity index 100% rename from spec/.repo/.git-orig/COMMIT_EDITMSG rename to test/fixtures/.repo/.git-orig/COMMIT_EDITMSG diff --git a/spec/.repo/.git-orig/FETCH_HEAD b/test/fixtures/.repo/.git-orig/FETCH_HEAD similarity index 100% rename from spec/.repo/.git-orig/FETCH_HEAD rename to test/fixtures/.repo/.git-orig/FETCH_HEAD diff --git a/spec/.repo/.git-orig/HEAD b/test/fixtures/.repo/.git-orig/HEAD similarity index 100% rename from spec/.repo/.git-orig/HEAD rename to test/fixtures/.repo/.git-orig/HEAD diff --git a/spec/.repo/.git-orig/config b/test/fixtures/.repo/.git-orig/config similarity index 100% rename from spec/.repo/.git-orig/config rename to test/fixtures/.repo/.git-orig/config diff --git a/spec/.repo/.git-orig/description b/test/fixtures/.repo/.git-orig/description similarity index 100% rename from spec/.repo/.git-orig/description rename to test/fixtures/.repo/.git-orig/description diff --git a/spec/.repo/.git-orig/hooks/applypatch-msg.sample b/test/fixtures/.repo/.git-orig/hooks/applypatch-msg.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/applypatch-msg.sample rename to test/fixtures/.repo/.git-orig/hooks/applypatch-msg.sample diff --git a/spec/.repo/.git-orig/hooks/commit-msg.sample b/test/fixtures/.repo/.git-orig/hooks/commit-msg.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/commit-msg.sample rename to test/fixtures/.repo/.git-orig/hooks/commit-msg.sample diff --git a/spec/.repo/.git-orig/hooks/fsmonitor-watchman.sample b/test/fixtures/.repo/.git-orig/hooks/fsmonitor-watchman.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/fsmonitor-watchman.sample rename to test/fixtures/.repo/.git-orig/hooks/fsmonitor-watchman.sample diff --git a/spec/.repo/.git-orig/hooks/post-update.sample b/test/fixtures/.repo/.git-orig/hooks/post-update.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/post-update.sample rename to test/fixtures/.repo/.git-orig/hooks/post-update.sample diff --git a/spec/.repo/.git-orig/hooks/pre-applypatch.sample b/test/fixtures/.repo/.git-orig/hooks/pre-applypatch.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-applypatch.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-applypatch.sample diff --git a/spec/.repo/.git-orig/hooks/pre-commit.sample b/test/fixtures/.repo/.git-orig/hooks/pre-commit.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-commit.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-commit.sample diff --git a/spec/.repo/.git-orig/hooks/pre-merge-commit.sample b/test/fixtures/.repo/.git-orig/hooks/pre-merge-commit.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-merge-commit.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-merge-commit.sample diff --git a/spec/.repo/.git-orig/hooks/pre-push.sample b/test/fixtures/.repo/.git-orig/hooks/pre-push.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-push.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-push.sample diff --git a/spec/.repo/.git-orig/hooks/pre-rebase.sample b/test/fixtures/.repo/.git-orig/hooks/pre-rebase.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-rebase.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-rebase.sample diff --git a/spec/.repo/.git-orig/hooks/pre-receive.sample b/test/fixtures/.repo/.git-orig/hooks/pre-receive.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/pre-receive.sample rename to test/fixtures/.repo/.git-orig/hooks/pre-receive.sample diff --git a/spec/.repo/.git-orig/hooks/prepare-commit-msg.sample b/test/fixtures/.repo/.git-orig/hooks/prepare-commit-msg.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/prepare-commit-msg.sample rename to test/fixtures/.repo/.git-orig/hooks/prepare-commit-msg.sample diff --git a/spec/.repo/.git-orig/hooks/update.sample b/test/fixtures/.repo/.git-orig/hooks/update.sample similarity index 100% rename from spec/.repo/.git-orig/hooks/update.sample rename to test/fixtures/.repo/.git-orig/hooks/update.sample diff --git a/spec/.repo/.git-orig/index b/test/fixtures/.repo/.git-orig/index similarity index 100% rename from spec/.repo/.git-orig/index rename to test/fixtures/.repo/.git-orig/index diff --git a/spec/.repo/.git-orig/info/exclude b/test/fixtures/.repo/.git-orig/info/exclude similarity index 100% rename from spec/.repo/.git-orig/info/exclude rename to test/fixtures/.repo/.git-orig/info/exclude diff --git a/spec/.repo/.git-orig/logs/HEAD b/test/fixtures/.repo/.git-orig/logs/HEAD similarity index 100% rename from spec/.repo/.git-orig/logs/HEAD rename to test/fixtures/.repo/.git-orig/logs/HEAD diff --git a/spec/.repo/.git-orig/logs/refs/heads/featB b/test/fixtures/.repo/.git-orig/logs/refs/heads/featB similarity index 100% rename from spec/.repo/.git-orig/logs/refs/heads/featB rename to test/fixtures/.repo/.git-orig/logs/refs/heads/featB diff --git a/spec/.repo/.git-orig/logs/refs/heads/featC b/test/fixtures/.repo/.git-orig/logs/refs/heads/featC similarity index 100% rename from spec/.repo/.git-orig/logs/refs/heads/featC rename to test/fixtures/.repo/.git-orig/logs/refs/heads/featC diff --git a/spec/.repo/.git-orig/logs/refs/heads/master b/test/fixtures/.repo/.git-orig/logs/refs/heads/master similarity index 100% rename from spec/.repo/.git-orig/logs/refs/heads/master rename to test/fixtures/.repo/.git-orig/logs/refs/heads/master diff --git a/spec/.repo/.git-orig/objects/0b/4012bdb8b7f16ec2c7490276b071a85dbf86e9 b/test/fixtures/.repo/.git-orig/objects/0b/4012bdb8b7f16ec2c7490276b071a85dbf86e9 similarity index 100% rename from spec/.repo/.git-orig/objects/0b/4012bdb8b7f16ec2c7490276b071a85dbf86e9 rename to test/fixtures/.repo/.git-orig/objects/0b/4012bdb8b7f16ec2c7490276b071a85dbf86e9 diff --git a/spec/.repo/.git-orig/objects/1a/d41d73bf6e2f4d929f0ab5e3098e5e5b31f8e2 b/test/fixtures/.repo/.git-orig/objects/1a/d41d73bf6e2f4d929f0ab5e3098e5e5b31f8e2 similarity index 100% rename from spec/.repo/.git-orig/objects/1a/d41d73bf6e2f4d929f0ab5e3098e5e5b31f8e2 rename to test/fixtures/.repo/.git-orig/objects/1a/d41d73bf6e2f4d929f0ab5e3098e5e5b31f8e2 diff --git a/spec/.repo/.git-orig/objects/2a/fa41f6d9a4e4dc25e9088e402fe7ba35b95a10 b/test/fixtures/.repo/.git-orig/objects/2a/fa41f6d9a4e4dc25e9088e402fe7ba35b95a10 similarity index 100% rename from spec/.repo/.git-orig/objects/2a/fa41f6d9a4e4dc25e9088e402fe7ba35b95a10 rename to test/fixtures/.repo/.git-orig/objects/2a/fa41f6d9a4e4dc25e9088e402fe7ba35b95a10 diff --git a/spec/.repo/.git-orig/objects/30/a0f033a755629a8ef1561e7b7ece3750ce8a13 b/test/fixtures/.repo/.git-orig/objects/30/a0f033a755629a8ef1561e7b7ece3750ce8a13 similarity index 100% rename from spec/.repo/.git-orig/objects/30/a0f033a755629a8ef1561e7b7ece3750ce8a13 rename to test/fixtures/.repo/.git-orig/objects/30/a0f033a755629a8ef1561e7b7ece3750ce8a13 diff --git a/spec/.repo/.git-orig/objects/39/ba5d897e269fb97a17058423947603f010e702 b/test/fixtures/.repo/.git-orig/objects/39/ba5d897e269fb97a17058423947603f010e702 similarity index 100% rename from spec/.repo/.git-orig/objects/39/ba5d897e269fb97a17058423947603f010e702 rename to test/fixtures/.repo/.git-orig/objects/39/ba5d897e269fb97a17058423947603f010e702 diff --git a/spec/.repo/.git-orig/objects/3b/73d17c51c9b22ff9d4552e5bb56927776173b3 b/test/fixtures/.repo/.git-orig/objects/3b/73d17c51c9b22ff9d4552e5bb56927776173b3 similarity index 100% rename from spec/.repo/.git-orig/objects/3b/73d17c51c9b22ff9d4552e5bb56927776173b3 rename to test/fixtures/.repo/.git-orig/objects/3b/73d17c51c9b22ff9d4552e5bb56927776173b3 diff --git a/spec/.repo/.git-orig/objects/40/c09bafbe2555af7017dd08f027e4ae45db2879 b/test/fixtures/.repo/.git-orig/objects/40/c09bafbe2555af7017dd08f027e4ae45db2879 similarity index 100% rename from spec/.repo/.git-orig/objects/40/c09bafbe2555af7017dd08f027e4ae45db2879 rename to test/fixtures/.repo/.git-orig/objects/40/c09bafbe2555af7017dd08f027e4ae45db2879 diff --git a/spec/.repo/.git-orig/objects/61/fcdbfa0b2af3418651b55d003c05c8e128d22e b/test/fixtures/.repo/.git-orig/objects/61/fcdbfa0b2af3418651b55d003c05c8e128d22e similarity index 100% rename from spec/.repo/.git-orig/objects/61/fcdbfa0b2af3418651b55d003c05c8e128d22e rename to test/fixtures/.repo/.git-orig/objects/61/fcdbfa0b2af3418651b55d003c05c8e128d22e diff --git a/spec/.repo/.git-orig/objects/91/b5884361b690f3bf1ba2edc9145a01d651a920 b/test/fixtures/.repo/.git-orig/objects/91/b5884361b690f3bf1ba2edc9145a01d651a920 similarity index 100% rename from spec/.repo/.git-orig/objects/91/b5884361b690f3bf1ba2edc9145a01d651a920 rename to test/fixtures/.repo/.git-orig/objects/91/b5884361b690f3bf1ba2edc9145a01d651a920 diff --git a/spec/.repo/.git-orig/refs/heads/featB b/test/fixtures/.repo/.git-orig/refs/heads/featB similarity index 100% rename from spec/.repo/.git-orig/refs/heads/featB rename to test/fixtures/.repo/.git-orig/refs/heads/featB diff --git a/spec/.repo/.git-orig/refs/heads/featC b/test/fixtures/.repo/.git-orig/refs/heads/featC similarity index 100% rename from spec/.repo/.git-orig/refs/heads/featC rename to test/fixtures/.repo/.git-orig/refs/heads/featC diff --git a/spec/.repo/.git-orig/refs/heads/master b/test/fixtures/.repo/.git-orig/refs/heads/master similarity index 100% rename from spec/.repo/.git-orig/refs/heads/master rename to test/fixtures/.repo/.git-orig/refs/heads/master diff --git a/spec/.repo/A.txt b/test/fixtures/.repo/A.txt similarity index 100% rename from spec/.repo/A.txt rename to test/fixtures/.repo/A.txt