#!/bin/sh

set -eu

mkdir -p "$AUTOPKGTEST_TMP"
cp -r tests "$AUTOPKGTEST_TMP"/tests
# mock nvim-web-devicons
mkdir -p "$AUTOPKGTEST_TMP/lua"
cat > "$AUTOPKGTEST_TMP/lua/nvim-web-devicons.lua" <<'EOF'
local M = {}
local icons = {
  txt = { icon = "󰈙", color = "#a89984" },
  lua = { icon = "", color = "#a89984" },
}
function M.get_icon(name, ext, _)
  local e = ext or (name and name:match("^.+%.(.+)$"))
  local it = e and icons[e]
  if not it then return nil end
  return it.icon, it.color
end
function M.get_icon_color(name, ext, opts)
  local icon, color = M.get_icon(name, ext, opts)
  return icon, color
end
return M
EOF

cd "$AUTOPKGTEST_TMP"

nvim --headless -c "PlenaryBustedDirectory tests/ {sequential = true}" +qa
