From 716adbcc4563f5b4d1b7bc0301530296c538a33c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Dec 2024 04:16:44 -0800 Subject: fix(api): deprecate nvim_subscribe, nvim_unsubscribe #30456 Problem: - nvim_subscribe, nvim_unsubscribe were deprecated in aec4938a21a02d279d13a9eb64ef3b7cc592c374 but this wasn't set in the API metadata. - The function annotations ``` FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY FUNC_API_DEPRECATED_SINCE(13) ``` cause this test to fail: ``` RUN T3 api metadata functions are compatible with old metadata or have new level: 3.00 ms ERR test/functional/api/version_spec.lua:135: function vim_subscribe was removed but exists in level 0 which nvim should be compatible with stack traceback: test/functional/api/version_spec.lua:135: in function ``` Solution: - Set the API metadata. - Rearrange the annotations so that FUNC_API_DEPRECATED_SINCE is 2nd: ``` FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(13) FUNC_API_REMOTE_ONLY ``` --- test/functional/api/version_spec.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/functional/api/version_spec.lua') diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index 617786eb2d..72b5e307ee 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -93,28 +93,28 @@ describe('api metadata', function() local function clean_level_0(metadata) for _, f in ipairs(metadata.functions) do f.can_fail = nil - f.async = nil + f.async = nil -- XXX: renamed to "fast". f.receives_channel_id = nil f.since = 0 end end - local api_info, compat, stable, api_level + local api_info --[[@type table]] + local compat --[[@type integer]] + local stable --[[@type integer]] + local api_level --[[@type integer]] local old_api = {} setup(function() clear() -- Ensure a session before requesting api_info. + --[[@type { version: {api_compatible: integer, api_level: integer, api_prerelease: boolean} }]] api_info = api.nvim_get_api_info()[2] compat = api_info.version.api_compatible api_level = api_info.version.api_level - if api_info.version.api_prerelease then - stable = api_level - 1 - else - stable = api_level - end + stable = api_info.version.api_prerelease and api_level - 1 or api_level for level = compat, stable do local path = ('test/functional/fixtures/api_level_' .. tostring(level) .. '.mpack') - old_api[level] = read_mpack_file(path) + old_api[level] = read_mpack_file(path) --[[@type table]] if old_api[level] == nil then local errstr = 'missing metadata fixture for stable level ' .. level .. '. ' if level == api_level and not api_info.version.api_prerelease then -- cgit From 25bd2782a5f7cd6cec32d5d592a814951045a71b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Nov 2024 21:07:28 -0500 Subject: test(version_spec): expect vim.NIL, not nil, for "build" if not in a git clone --- test/functional/api/version_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/api/version_spec.lua') diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index 72b5e307ee..68c4ef7503 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -43,7 +43,7 @@ describe("api_info()['version']", function() eq(0, fn.has('nvim-' .. major .. '.' .. minor .. '.' .. (patch + 1))) eq(0, fn.has('nvim-' .. major .. '.' .. (minor + 1) .. '.' .. patch)) eq(0, fn.has('nvim-' .. (major + 1) .. '.' .. minor .. '.' .. patch)) - assert(build == nil or type(build) == 'string') + assert(build == vim.NIL or type(build) == 'string') end) end) -- cgit