From c753e70abb7af96205279d912ebe80f60dd00652 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 29 Apr 2025 09:44:54 +0800 Subject: [PATCH] test(lua/secure_spec): avoid magic number (#33700) Avoid magic number in skipping condition by moving the expected message to a variable. (cherry picked from commit c489b5a3e3e72abda731dd3768cf1d8b98f7264e) --- test/functional/lua/secure_spec.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/functional/lua/secure_spec.lua b/test/functional/lua/secure_spec.lua index b0e7af0b9c..71e2ff9d3d 100644 --- a/test/functional/lua/secure_spec.lua +++ b/test/functional/lua/secure_spec.lua @@ -55,7 +55,8 @@ describe('vim.secure', function() }) local cwd = fn.getcwd() - if #cwd + 23 > 500 then + local msg = cwd .. pathsep .. 'Xfile is not trusted.' + if #msg >= screen._width then pending('path too long') return end @@ -67,7 +68,7 @@ describe('vim.secure', function() {1:~{MATCH: +}}|*3 {2:{MATCH: +}}| :lua vim.secure.read('Xfile'){MATCH: +}| - {3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| + {3:]] .. msg .. [[}{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| ]]) feed('d') @@ -89,7 +90,7 @@ describe('vim.secure', function() {1:~{MATCH: +}}|*3 {2:{MATCH: +}}| :lua vim.secure.read('Xfile'){MATCH: +}| - {3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| + {3:]] .. msg .. [[}{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| ]]) feed('a') @@ -112,7 +113,7 @@ describe('vim.secure', function() {1:~{MATCH: +}}|*3 {2:{MATCH: +}}| :lua vim.secure.read('Xfile'){MATCH: +}| - {3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| + {3:]] .. msg .. [[}{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| ]]) feed('i') @@ -131,7 +132,7 @@ describe('vim.secure', function() {1:~{MATCH: +}}|*3 {2:{MATCH: +}}| :lua vim.secure.read('Xfile'){MATCH: +}| - {3:]] .. cwd .. pathsep .. [[Xfile is not trusted.}{MATCH: +}| + {3:]] .. msg .. [[}{MATCH: +}| {3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}| ]]) feed('v')