Skip to content

Help with busted, local-lua config 🙏  #17

@aaharr

Description

@aaharr

Very much appreciate you targeting this use case (💯)

When I try to run busted tests, I get syntax errors seemingly from the busted executable. Just the sample busted test from the plenary docs, passes when running busted either via plenary or lua. Would love to be able to debug!

For every test:
E5112: Error while creating lua chunk: /usr/local/bin/busted:3: unexpected symbol near '-'

File is called test_spec.lua and there is an empty minimum_init.spec in the same directory. Plenary seems to be picking it up, but only since I named it test_spec.lua.

            -- Local Lua DAP
            -- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#local-lua-debugger-vscode
            dap.adapters["local-lua"] = {
                type = "executable",
                command = "node",
                args = {
                    "/home/aaron/local-lua-debugger-vscode/extension/debugAdapter.js",
                },
                enrich_config = function(config, on_config)
                    if not config["extensionPath"] then
                        local c = vim.deepcopy(config)
                        -- 💀 If this is missing or wrong you'll see
                        -- "module 'lldebugger' not found" errors in the dap-repl when trying to launch a debug session
                        c.extensionPath = "/home/aaron/local-lua-debugger-vscode/"
                        on_config(c)
                    else
                        on_config(config)
                    end
                end,
            }

            -- Local Lua Launch Config
            -- https://zignar.net/2023/06/10/debugging-lua-in-neovim/
            dap.configurations.lua = {
                {
                    name = "Launch file (local-lua)",
                    type = "local-lua",
                    request = "launch",
                    cwd = "${workspaceFolder}",
                    console = "integratedTerminal",
                    program = {
                        lua = "lua5.1",
                        file = "${file}",
                    },
                    args = {},
                },
            }
            -- Currently filetypes are not set for lua (why?), so you have to manually run
            -- :lua require('dap').run(require('dap').configurations.lua[1])
                adapters = {
                    -- require("neotest-plenary").setup({
                    --     -- min_init = ".minimal_init.lua",
                    -- }),
                    require("neotest-busted")({
                        -- Leave as nil to let neotest-busted automatically find busted
                        busted_command = "/usr/local/bin/busted",
                        -- Extra arguments to busted
                        -- busted_args = { "--shuffle-files" },
                        -- List of paths to add to package.path in neovim before running busted
                        -- busted_paths = { "my/custom/path/?.lua" },
                        -- List of paths to add to package.cpath in neovim before running busted
                        -- busted_cpaths = { "my/custom/path/?.so" },
                        -- Custom config to load via -u to set up testing.
                        -- If nil, will look for a 'minimal_init.lua' file
                        -- minimal_init = "custom_init.lua",
                    }),
                },

Hoping something jumps out at you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions