Home

Awesome

<!-- markdownlint-disable --> <br /> <div align="center"> <a href="https://github.com/nvim-neorocks/neorocks"> <img src="https://avatars.githubusercontent.com/u/124081866?s=400&u=0da379a468d46456477a1f68048b020cf7a99f34&v=4" alt="neorocks"> </a> <p align="center"> <a href="https://github.com/nvim-neorocks/neorocks/issues">Report Bug</a> </p> <p> <strong> neorocks <br /> Run <a href="https://lunarmodules.github.io/busted/">busted</a> tests with <a href="https://neovim.io/">Neovim in your Nix CI</a>. </strong> </p> <h2>🌒</h> </div> <!-- markdownlint-restore -->

Neovim Lua Nix

GPL2 License Issues Build Status

What?

Why?

So you can use busted to test your Neovim plugins with access to the Neovim Lua API.

How?

In a Nix flake

This project provides a Nix overlay with a neorocksTest function. Here is an example of how to use it in a Nix flake:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    neorocks.url = "github:nvim-neorocks/neorocks";
  };
  outputs = {
    self,
    nixpkgs,
    neorocks,
    ...
  }: let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      overlays = [
        neorocks.overlays.default
      ];
    };
  in {
    # ...
    checks.${system} = {
      neorocks-test = pkgs.neorocksTest {
        src = self; # Project containing the rockspec and .busted files.
        # Plugin name. If running multiple tests,
        # you can use pname for the plugin name instead
        name = "my-plugin.nvim"
        version = "scm-1"; # Optional, defaults to "scm-1";
        neovim = pkgs.neovim-nightly; # Optional, defaults to neovim-nightly.
        luaPackages = ps: # Optional
          with ps; [
            # LuaRocks dependencies must be added here.
            plenary-nvim
          ];
        extraPackages = []; # Optional. External test runtime dependencies.
      };
    };
  };
}

In a Nix shell

nix shell "github:nvim-neorocks/neorocks"
busted

Without Nix (using nlua)

See: mfussenegger/nlua

Without nlua

To run busted tests locally, without neorocks or neolua...

<!-- markdownlint-disable -->
#!/bin/sh
export BUSTED_VERSION="2.1.2-3"
luarocks init
luarocks install busted "$BUSTED_VERSION"
luarocks config --scope project lua_version 5.1
nvim -u NONE \
  -c "lua package.path='lua_modules/share/lua/5.1/?.lua;lua_modules/share/lua/5.1/?/init.lua;'..package.path;package.cpath='lua_modules/lib/lua/5.1/?.so;'..package.cpath;local k,l,_=pcall(require,'luarocks.loader') _=k and l.add_context('busted','$BUSTED_VERSION')" \
  -l "lua_modules/lib/luarocks/rocks-5.1/busted/$BUSTED_VERSION/bin/busted" "$@"
<!-- markdownlint-restore -->

Note

If your tests are not in a spec directory, pass the name of the test directory to the script. e.g., ./run-tests.sh tests

With GitHub Actions

<!-- MARKDOWN LNIKS & IMAGES -->