Files
neovim/test/functional/editor/xxd_spec.lua
Justin M. Keyes 6d8c8b18d5 test(harness): migrate away from magic globals
Problem:
The magic globals `it`, `describe`, etc., are more trouble than they are
worth.

- Hooking into `after_each` requires `getfenv()` hacks.
- They confuse luals/emmylua, because the top-level `.luarc.json` isn't
  merged with `test/.luarc.json` (apparently a luals limitation?)
- They totally defeat discoverability because the user just has to
  "know" about the various magic symbols.

So they harm DX, which means they serve no purpose at all.

Solution:
- Expose the test API from `testutil`, so tests can call `t.it()`,
  `t.describe()`, etc., in the conventional way.
- Drop `getfenv()` hacks.
- Drop the `setfenv()` injection in `load_chunk`.
- Drop `test/_meta.lua`.
2026-07-21 13:22:39 +02:00

30 lines
934 B
Lua

local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local describe, it, before_each = t.describe, t.it, t.before_each
local eq = t.eq
local eval = n.eval
local clear = n.clear
local fn = n.fn
local testprg = n.testprg
describe('xxd', function()
before_each(clear)
it('works', function()
t.skip(t.is_arch('s390x'), 'FIXME: xxd not built correctly on s390x with QEMU?')
-- Round-trip test: encode then decode should return original
local input = 'hello'
local encoded = fn.system({ testprg('xxd') }, input)
local decoded = fn.system({ testprg('xxd'), '-r' }, encoded)
eq(input, decoded)
end)
it('handles long lines in revert mode', function()
t.skip(t.is_arch('s390x'), 'FIXME: xxd not built correctly on s390x with QEMU?')
local long_line = ('4'):rep(512) .. '\n'
fn.system({ testprg('xxd'), '-r' }, long_line)
eq(0, eval('v:shell_error'))
end)
end)