mirror of
https://github.com/neovim/neovim.git
synced 2026-08-04 06:38:44 +00:00
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`.
This commit is contained in:
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local neq, eq, command = t.neq, t.eq, n.command
|
||||
local clear = n.clear
|
||||
local expect, eval = n.expect, n.eval
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local eq = t.eq
|
||||
local clear = n.clear
|
||||
local fn = n.fn
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 feed = n.feed
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 api = n.api
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local environ = n.fn.environ
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear = n.clear
|
||||
local command = n.command
|
||||
local eq = t.eq
|
||||
|
||||
@@ -13,6 +13,8 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each, setup, teardown, pending, finally =
|
||||
t.describe, t.it, t.before_each, t.setup, t.teardown, t.pending, t.finally
|
||||
local mkdir = t.mkdir
|
||||
local pcall_err = t.pcall_err
|
||||
local clear = n.clear
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, setup, teardown, pending =
|
||||
t.describe, t.it, t.before_each, t.setup, t.teardown, t.pending
|
||||
local eq, clear, call, write_file, command = t.eq, n.clear, n.call, t.write_file, n.command
|
||||
local eval, fn = n.eval, n.fn
|
||||
local is_os = t.is_os
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local eq = t.eq
|
||||
local eval = n.eval
|
||||
local clear = n.clear
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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, clear, call = t.eq, n.clear, n.call
|
||||
local command = n.command
|
||||
local matches = t.matches
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, setup, teardown =
|
||||
t.describe, t.it, t.before_each, t.setup, t.teardown
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local exec_lua = n.exec_lua
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local it, before_each = t.it, t.before_each
|
||||
local clear = n.clear
|
||||
local eval = n.eval
|
||||
local matches = t.matches
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local n = require('test.functional.testnvim')()
|
||||
local t = require('test.testutil')
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear = n.clear
|
||||
local exec = n.exec
|
||||
local feed = n.feed
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local call = n.call
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local clear, command, eval, eq = n.clear, n.command, n.eval, t.eq
|
||||
local mkdir = t.mkdir
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each, pending = t.describe, t.it, t.before_each, t.pending
|
||||
local clear = n.clear
|
||||
local connect = n.connect
|
||||
local get_session = n.get_session
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 ok = t.ok
|
||||
local call = n.call
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local eq = t.eq
|
||||
local pcall_err = t.pcall_err
|
||||
local feed = n.feed
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local clear = n.clear
|
||||
local fn = n.fn
|
||||
local api = n.api
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, pending = t.describe, t.it, t.before_each, t.pending
|
||||
local clear, eval, eq = n.clear, n.eval, t.eq
|
||||
local source = n.source
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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 clear = n.clear
|
||||
local command = n.command
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local eval = n.eval
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local eq = t.eq
|
||||
local pcall_err = t.pcall_err
|
||||
local clear = n.clear
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local eq = t.eq
|
||||
local eval = n.eval
|
||||
local command = n.command
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local assert_alive = n.assert_alive
|
||||
local clear, command, write_file = n.clear, n.command, t.write_file
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local t = require('test.testutil')
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local pcall_err = t.pcall_err
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local command = n.command
|
||||
local clear = n.clear
|
||||
local api = n.api
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local eq = t.eq
|
||||
local eval = n.eval
|
||||
local clear = n.clear
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local pcall_err = t.pcall_err
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear, eq, ok = n.clear, t.eq, t.ok
|
||||
local neq, command, fn = t.neq, n.command, n.fn
|
||||
local matches = t.matches
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each, setup = t.describe, t.it, t.before_each, t.setup
|
||||
local clear, eq, neq = n.clear, t.eq, t.neq
|
||||
local command, api, fn = n.command, n.api, n.fn
|
||||
local tbl_deep_extend = vim.tbl_deep_extend
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear, eq, api = n.clear, t.eq, n.api
|
||||
local command, fn = n.command, n.fn
|
||||
local feed = n.feed
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, before_each, pending = t.describe, t.before_each, t.pending
|
||||
local clear, eq, api = n.clear, t.eq, n.api
|
||||
local command, fn = n.command, n.fn
|
||||
local feed = n.feed
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local setpos = n.fn.setpos
|
||||
local getpos = n.fn.getpos
|
||||
local insert = n.insert
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local eq = t.eq
|
||||
local NIL = vim.NIL
|
||||
local eval = n.eval
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local command = n.command
|
||||
local fn = n.fn
|
||||
local clear = n.clear
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local exec = n.exec
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
local command = n.command
|
||||
|
||||
@@ -4,6 +4,8 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each, after_each, pending, finally =
|
||||
t.describe, t.it, t.before_each, t.after_each, t.pending, t.finally
|
||||
local assert_alive = n.assert_alive
|
||||
local testprg = n.testprg
|
||||
local eq, call, clear, eval, feed_command, feed, api =
|
||||
|
||||
@@ -2,6 +2,7 @@ local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local feed, eq, eval, ok = n.feed, t.eq, n.eval, t.ok
|
||||
local source, async_meths, run = n.source, n.async_meths, n.run
|
||||
local clear, command, fn = n.clear, n.command, n.fn
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, setup = t.describe, t.it, t.setup
|
||||
local eq = t.eq
|
||||
local clear = n.clear
|
||||
local command = n.command
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local t = require('test.testutil')
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local pcall_err = t.pcall_err
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each = t.describe, t.it, t.before_each
|
||||
local call = n.call
|
||||
local clear = n.clear
|
||||
local command = n.command
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
|
||||
local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
|
||||
local mkdir = t.mkdir
|
||||
local clear = n.clear
|
||||
local eq = t.eq
|
||||
|
||||
Reference in New Issue
Block a user