test: improve test conventions

Work on https://github.com/neovim/neovim/issues/27004.
This commit is contained in:
dundargoc
2024-04-08 11:03:20 +02:00
committed by dundargoc
parent 978962f9a0
commit 7035125b2b
488 changed files with 4176 additions and 4235 deletions

View File

@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local pathsep = helpers.get_pathsep()
local fn = helpers.fn
local api = helpers.api
local exec_lua = helpers.exec_lua
local t = require('test.functional.testutil')(after_each)
local clear = t.clear
local command = t.command
local eq = t.eq
local pathsep = t.get_pathsep()
local fn = t.fn
local api = t.api
local exec_lua = t.exec_lua
local testdir = 'Xtest-editorconfig'
@@ -20,8 +20,8 @@ local function test_case(name, expected)
end
setup(function()
helpers.mkdir_p(testdir)
helpers.write_file(
t.mkdir_p(testdir)
t.write_file(
testdir .. pathsep .. '.editorconfig',
[[
root = true
@@ -96,7 +96,7 @@ setup(function()
end)
teardown(function()
helpers.rmdir(testdir)
t.rmdir(testdir)
end)
describe('editorconfig', function()
@@ -178,18 +178,18 @@ But not this one
-- luacheck: pop
local trimmed = untrimmed:gsub('%s+\n', '\n')
helpers.write_file(filename, untrimmed)
t.write_file(filename, untrimmed)
command('edit ' .. filename)
command('write')
command('bdelete')
eq(trimmed, helpers.read_file(filename))
eq(trimmed, t.read_file(filename))
filename = testdir .. pathsep .. 'no_trim.txt'
helpers.write_file(filename, untrimmed)
t.write_file(filename, untrimmed)
command('edit ' .. filename)
command('write')
command('bdelete')
eq(untrimmed, helpers.read_file(filename))
eq(untrimmed, t.read_file(filename))
end)
it('sets textwidth', function()