d5f207424b
e2e Tests / e2e (macos-latest) (push) Waiting to run
Nix CI / check (push) Waiting to run
Python CI / Python bindings (macos-latest) (push) Waiting to run
e2e Tests / e2e (windows-latest) (push) Waiting to run
Python CI / Python bindings (windows-latest) (push) Waiting to run
Build & Publish / Build Neovim aarch64-apple-darwin (push) Waiting to run
Build & Publish / Build Neovim aarch64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build Neovim x86_64-apple-darwin (push) Waiting to run
Build & Publish / Build Neovim x86_64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build C FFI aarch64-apple-darwin (push) Waiting to run
Build & Publish / Build C FFI aarch64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build C FFI x86_64-apple-darwin (push) Waiting to run
Build & Publish / Build C FFI x86_64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build MCP aarch64-apple-darwin (push) Waiting to run
Build & Publish / Build MCP aarch64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build MCP x86_64-apple-darwin (push) Waiting to run
Build & Publish / Build MCP x86_64-pc-windows-msvc (push) Waiting to run
Build & Publish / Build Python wheels aarch64 (macos-latest) (push) Waiting to run
Build & Publish / Build Python wheels x86_64 (macos-latest) (push) Waiting to run
Build & Publish / Build Python wheels x86_64 (windows-latest) (push) Waiting to run
Build & Publish / Release (push) Blocked by required conditions
Build & Publish / Publish Python wheels to PyPI (push) Blocked by required conditions
Build & Publish / Publish Rust crates (push) Blocked by required conditions
Build & Publish / Publish npm packages (push) Blocked by required conditions
Rust CI / Fuzz Tests (windows-latest) (push) Waiting to run
Rust CI / Test (macos-latest) (push) Waiting to run
Rust CI / Test (windows-latest) (push) Waiting to run
Rust CI / Fuzz Tests (macos-latest) (push) Waiting to run
Python CI / Python bindings (ubuntu-latest) (push) Failing after 0s
Build & Publish / Build Neovim aarch64-linux-android (push) Failing after 0s
Build & Publish / Build Neovim aarch64-unknown-linux-gnu (push) Failing after 0s
Build & Publish / Build MCP x86_64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build Python wheels aarch64 (ubuntu-latest) (push) Failing after 0s
Build & Publish / Build Python wheels x86_64 (ubuntu-latest) (push) Failing after 1s
Build & Publish / Build Python sdist (push) Failing after 1s
Rust CI / Fuzz Tests (ubuntu-latest) (push) Failing after 1s
Rust CI / Build i686-unknown-linux-gnu (push) Failing after 0s
Rust CI / cargo clippy (push) Failing after 1s
e2e Tests / e2e (ubuntu-latest) (push) Failing after 1s
Lua CI / luacheck lint (push) Failing after 1s
Build & Publish / Build Neovim aarch64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build Neovim x86_64-unknown-linux-gnu (push) Failing after 0s
Build & Publish / Build Neovim x86_64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build C FFI aarch64-linux-android (push) Failing after 0s
Build & Publish / Build C FFI aarch64-unknown-linux-gnu (push) Failing after 0s
Build & Publish / Build C FFI aarch64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build C FFI x86_64-unknown-linux-gnu (push) Failing after 0s
Build & Publish / Build C FFI x86_64-unknown-linux-musl (push) Failing after 1s
Build & Publish / Build MCP aarch64-unknown-linux-gnu (push) Failing after 1s
Build & Publish / Build MCP aarch64-unknown-linux-musl (push) Failing after 0s
Build & Publish / Build MCP x86_64-unknown-linux-gnu (push) Failing after 1s
Spelling / Spell Check with Typos (push) Failing after 0s
Rust CI / Test (ubuntu-latest) (push) Failing after 0s
Rust CI / cargo fmt (push) Failing after 0s
Stylua / Check lua files using Stylua (push) Failing after 1s
Lua CI / lua-language-server type check (push) Failing after 12m29s
e2e Tests / e2e (alpine-musl) (push) Successful in 57m31s
127 lines
5.1 KiB
Lua
127 lines
5.1 KiB
Lua
--- Test fixtures for fff.nvim snapshot tests.
|
|
---
|
|
--- Builds a deterministic, throwaway directory tree on disk and tears it down
|
|
--- after each test. Also scopes frecency/history DBs to temp paths so picker
|
|
--- ordering is reproducible regardless of the developer's history.
|
|
|
|
local M = {}
|
|
|
|
--- Files used by every snapshot test. Sized to overflow the list page so
|
|
--- snapshots reflect realistic scrolling/clipping behaviour.
|
|
local FIXTURE_FILES = {
|
|
['README.md'] = '# Fixture\n',
|
|
['src/main.rs'] = 'fn main() {}\n',
|
|
['src/main_helper.rs'] = 'pub fn helper() {}\n',
|
|
['src/main_utils.rs'] = 'pub fn util() {}\n',
|
|
['src/main_runner.rs'] = 'pub fn run() {}\n',
|
|
['src/main_loop.rs'] = 'pub fn loop_() {}\n',
|
|
['src/lib.rs'] = 'pub fn it_works() -> i32 { 42 }\n',
|
|
['src/utils.rs'] = 'pub fn helper() {}\n',
|
|
['src/parser.rs'] = 'pub fn parse() {}\n',
|
|
['src/runner.rs'] = 'pub fn run() {}\n',
|
|
['src/state.rs'] = 'pub struct State {}\n',
|
|
['src/config.rs'] = 'pub struct Config {}\n',
|
|
['src/error.rs'] = 'pub enum Error {}\n',
|
|
['src/types.rs'] = 'pub type Id = u64;\n',
|
|
['src/store.rs'] = 'pub struct Store {}\n',
|
|
['src/api.rs'] = 'pub fn api() {}\n',
|
|
['src/cli.rs'] = 'pub fn cli() {}\n',
|
|
['src/components/button.tsx'] = 'export const Button = () => null\n',
|
|
['src/components/input.tsx'] = 'export const Input = () => null\n',
|
|
['src/components/dialog.tsx'] = 'export const Dialog = () => null\n',
|
|
['src/components/menu.tsx'] = 'export const Menu = () => null\n',
|
|
['src/components/list.tsx'] = 'export const List = () => null\n',
|
|
['src/components/table.tsx'] = 'export const Table = () => null\n',
|
|
['docs/intro.md'] = '# Intro\n',
|
|
['docs/guide.md'] = '# Guide\n',
|
|
['docs/reference.md'] = '# Reference\n',
|
|
['docs/changelog.md'] = '# Changelog\n',
|
|
['docs/contributing.md'] = '# Contributing\n',
|
|
['docs/license.md'] = '# License\n',
|
|
['tests/main_test.rs'] = '#[test] fn main_test() {}\n',
|
|
['tests/integration.rs'] = '#[test] fn it() {}\n',
|
|
['tests/regression.rs'] = '#[test] fn regress() {}\n',
|
|
}
|
|
|
|
--- @class fff.snapshot.Fixture
|
|
--- @field root string absolute path to fixture root
|
|
--- @field frecency_db string
|
|
--- @field history_db string
|
|
|
|
--- Create a fresh fixture: deterministic file tree, scoped DBs, fff config
|
|
--- pointing at the temp DB paths.
|
|
--- @return fff.snapshot.Fixture
|
|
function M.create()
|
|
local raw_root = vim.fn.tempname() .. '_fff_snap_fixture'
|
|
vim.fn.mkdir(raw_root, 'p')
|
|
-- Resolve symlinks (on macOS /tmp → /private/tmp). Without this, picker_ui's
|
|
-- change_indexing_directory canonicalises the path and silently reinitialises
|
|
-- the FilePicker, which invalidates query-tracker entries we've trained
|
|
-- against the original path.
|
|
local root = vim.fn.resolve(raw_root)
|
|
|
|
for rel, content in pairs(FIXTURE_FILES) do
|
|
local path = root .. '/' .. rel
|
|
vim.fn.mkdir(vim.fn.fnamemodify(path, ':h'), 'p')
|
|
local f = assert(io.open(path, 'w'))
|
|
f:write(content)
|
|
f:close()
|
|
end
|
|
|
|
-- Initialise as a git repo so the picker exercises its git-status path the
|
|
-- same way it would in real use.
|
|
vim.fn.system({ 'git', '-C', root, 'init', '-q' })
|
|
vim.fn.system({ 'git', '-C', root, '-c', 'user.email=t@t', '-c', 'user.name=t', 'add', '-A' })
|
|
vim.fn.system({ 'git', '-C', root, '-c', 'user.email=t@t', '-c', 'user.name=t', 'commit', '-q', '-m', 'init' })
|
|
|
|
local frecency_db = vim.fn.tempname() .. '_fff_snap_frecency'
|
|
local history_db = vim.fn.tempname() .. '_fff_snap_history'
|
|
|
|
return { root = root, frecency_db = frecency_db, history_db = history_db }
|
|
end
|
|
|
|
--- Apply fff config that uses the fixture's scoped DBs and sane defaults for
|
|
--- snapshot tests (no debounce, fixed sizes).
|
|
--- @param fixture fff.snapshot.Fixture
|
|
function M.configure(fixture)
|
|
---@diagnostic disable-next-line: missing-fields
|
|
vim.g.fff = {
|
|
frecency = { enabled = true, db_path = fixture.frecency_db },
|
|
---@diagnostic disable-next-line: missing-fields
|
|
history = { enabled = true, db_path = fixture.history_db },
|
|
}
|
|
-- Reload config so the new vim.g.fff is picked up.
|
|
package.loaded['fff.conf'] = nil
|
|
end
|
|
|
|
--- Destroy fixture artefacts on disk and reset module state.
|
|
--- @param fixture fff.snapshot.Fixture
|
|
function M.cleanup(fixture)
|
|
local rust_ok, fff_rust = pcall(require, 'fff.rust')
|
|
if rust_ok then
|
|
pcall(fff_rust.stop_background_monitor)
|
|
pcall(fff_rust.cleanup_file_picker)
|
|
pcall(fff_rust.destroy_frecency_db)
|
|
pcall(fff_rust.destroy_query_db)
|
|
end
|
|
|
|
if fixture.root then vim.fn.delete(fixture.root, 'rf') end
|
|
if fixture.frecency_db then vim.fn.delete(fixture.frecency_db, 'rf') end
|
|
if fixture.history_db then vim.fn.delete(fixture.history_db, 'rf') end
|
|
|
|
vim.g.fff = nil
|
|
package.loaded['fff.conf'] = nil
|
|
end
|
|
|
|
--- Initialise the picker against the fixture and wait for the initial scan.
|
|
--- @param fixture fff.snapshot.Fixture
|
|
function M.init_picker(fixture)
|
|
vim.cmd('cd ' .. vim.fn.fnameescape(fixture.root))
|
|
local fff_rust = require('fff.rust')
|
|
assert(fff_rust.init_db(fixture.frecency_db, fixture.history_db, true), 'init_db failed')
|
|
assert(fff_rust.init_file_picker(fixture.root), 'init_file_picker failed')
|
|
fff_rust.wait_for_initial_scan(10000)
|
|
end
|
|
|
|
return M
|