From e581baccac8540b19ec31fbeeb621ae1466a47d8 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 18 Sep 2025 19:53:13 -0400 Subject: [PATCH] feat(test,ci): testing framework w/ ci integration --- .busted | 8 ++++++++ .github/workflows/ci.yml | 13 +++++++++++++ .luarocks | 4 ++++ cp.nvim-scm-1.rockspec | 12 ++++++++++++ spec/init_spec.lua | 18 ++++++++++++++++++ tests/minimal.lua | 4 ++++ 6 files changed, 59 insertions(+) create mode 100644 .busted create mode 100644 .luarocks create mode 100644 cp.nvim-scm-1.rockspec create mode 100644 spec/init_spec.lua create mode 100644 tests/minimal.lua diff --git a/.busted b/.busted new file mode 100644 index 0000000..b29936d --- /dev/null +++ b/.busted @@ -0,0 +1,8 @@ +return { + _all = { + lua = 'nlua', + lpath = 'lua/?.lua;lua/?/init.lua', + helper = 'tests/minimal.lua', + }, + default = { verbose = true }, +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecde609..cc5a926 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,3 +64,16 @@ jobs: run: uv tool install ruff - name: Lint Python files with ruff run: ruff check scrapers/ + + test: + name: Tests + runs-on: ubuntu-latest + strategy: + matrix: + nvim_version: [stable, nightly] + steps: + - uses: actions/checkout@v4 + - name: Run tests + uses: nvim-neorocks/nvim-busted-action@v1 + with: + nvim_version: ${{ matrix.nvim_version }} diff --git a/.luarocks b/.luarocks new file mode 100644 index 0000000..82b1cf3 --- /dev/null +++ b/.luarocks @@ -0,0 +1,4 @@ +lua_version = "5.1" +variables = { + CC = "gcc" +} \ No newline at end of file diff --git a/cp.nvim-scm-1.rockspec b/cp.nvim-scm-1.rockspec new file mode 100644 index 0000000..7b828db --- /dev/null +++ b/cp.nvim-scm-1.rockspec @@ -0,0 +1,12 @@ +rockspec_format = '3.0' +package = 'cp.nvim' +version = 'scm-1' + +source = { url = 'git://github.com/barrett-ruth/cp.nvim' } +build = { type = 'builtin' } + +test_dependencies = { + 'lua >= 5.1', + 'nlua', + 'busted >= 2.1.1', +} \ No newline at end of file diff --git a/spec/init_spec.lua b/spec/init_spec.lua new file mode 100644 index 0000000..9b127b1 --- /dev/null +++ b/spec/init_spec.lua @@ -0,0 +1,18 @@ +describe('cp.nvim', function() + it('can be required', function() + local cp = require('cp') + assert.is_not_nil(cp) + assert.is_function(cp.setup) + assert.is_function(cp.handle_command) + end) + + it('has health check', function() + local health = require('cp.health') + assert.is_not_nil(health) + end) + + it('initializes properly', function() + local cp = require('cp') + assert.is_true(cp.is_initialized()) + end) +end) \ No newline at end of file diff --git a/tests/minimal.lua b/tests/minimal.lua new file mode 100644 index 0000000..91c9b01 --- /dev/null +++ b/tests/minimal.lua @@ -0,0 +1,4 @@ +vim.env.XDG_CONFIG_HOME = vim.fn.getcwd() .. '/.tests/xdg/config' +vim.env.XDG_DATA_HOME = vim.fn.getcwd() .. '/.tests/xdg/data' +vim.env.XDG_STATE_HOME = vim.fn.getcwd() .. '/.tests/xdg/state' +vim.opt.runtimepath:append(vim.fn.getcwd()) \ No newline at end of file