Skip to content

Commit

Permalink
test: limit code and comment max length by 80
Browse files Browse the repository at this point in the history
The patch sets a max length with 80 symbols and fixes tests
exceeding this length.
  • Loading branch information
ligurio committed Feb 11, 2025
1 parent b98550d commit b136c78
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ std = 'luajit'
-- This fork also introduces a new global for misc API namespace.
read_globals = { 'misc' }

max_line_length = 80
max_code_line_length = 80
max_string_line_length = 80
max_comment_line_length = 80

-- The `_TARANTOOL` global is often used for skip condition
-- checks in tests.
files['test/tarantool-tests/'] = {
Expand Down
4 changes: 4 additions & 0 deletions test/tarantool-tests/fix-argv-handling.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ test:plan(1)
-- to a single empty string if it is empty [1], so the issue is
-- not reproducible on new kernels.
--
-- luacheck: push no max comment line length
--
-- [1]: https://lore.kernel.org/all/[email protected]/
--
-- luacheck: pop

local utils = require('utils')
local execlib = require('execlib')
Expand Down
3 changes: 3 additions & 0 deletions test/tarantool-tests/gh-3196-incorrect-string-length.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ test:plan(2)
--
-- gh-3196: incorrect string length if Lua hash returns 0
--
-- luacheck: push no max code line length
--
local h = "\x1F\x93\xE2\x1C\xCA\xDE\x28\x08\x26\x01\xED\x0A\x2F\xE4\x21\x02\x97\x77\xD9\x3E"
test:is(h:len(), 20)

h = "\x0F\x93\xE2\x1C\xCA\xDE\x28\x08\x26\x01\xED\x0A\x2F\xE4\x21\x02\x97\x77\xD9\x3E"
test:is(h:len(), 20)
-- luacheck: pop

test:done(true)
4 changes: 4 additions & 0 deletions test/tarantool-tests/gh-6163-min-max.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ jit.opt.start('hotloop=1')
-- pair is emitted, and the result is `NaN`, which is inconsistent with
-- the result of the non-optimized mcode.
--
-- luacheck: push no max comment line length
--
-- [1]: https://developer.arm.com/documentation/dui0801/g/A64-Floating-point-Instructions/FCMP
-- [2]: https://developer.arm.com/documentation/100069/0608/A64-Floating-point-Instructions/FCSEL
-- [3]: https://developer.arm.com/documentation/dui0068/b/ARM-Instruction-Reference/Conditional-execution
--
-- luacheck: pop

local result = {}
for k = 1, 4 do
Expand Down
10 changes: 8 additions & 2 deletions test/tarantool-tests/lj-366-strtab-correct-size.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ local utils = require('utils')
--
-- $ readelf --symbols xxx.obj
--
-- luacheck: push no max comment line length
--
-- Symbol table '.symtab' contains 2 entries:
-- Num: Value Size Type Bind Vis Ndx Name
-- 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
-- 1: 0000000000000000 66 OBJECT GLOBAL DEFAULT 4 luaJIT_BC_lango_team
--
-- luacheck: pop
--
-- and to display the information contained in the file's section
-- headers, if it has any. For our purposes, we are interested in
-- .symtab section, so other sections are snipped in the output:
Expand Down Expand Up @@ -143,7 +147,8 @@ end
-- and symtab sections.
local function read_elf(elf_content)
local ELFobj_type = ffi.typeof(is64 and 'ELF64obj *' or 'ELF32obj *')
local ELFsectheader_type = ffi.typeof(is64 and 'ELF64sectheader *' or 'ELF32sectheader *')
local ELFsectheader_type = ffi.typeof(is64 and 'ELF64sectheader *' or
'ELF32sectheader *')
local elf = ffi.cast(ELFobj_type, elf_content)
local symtab_hdr, strtab_hdr
-- Iterate by section headers.
Expand Down Expand Up @@ -178,7 +183,8 @@ assert(sym_cnt ~= 0, 'number of symbols is zero')
test:is(strtab_size, EXPECTED_STRTAB_SIZE, 'check .strtab size')
test:is(strtab_offset, EXPECTED_STRTAB_OFFSET, 'check .strtab offset')

local strtab_str = string.sub(elf_content, strtab_offset, strtab_offset + strtab_size)
local strtab_str = string.sub(elf_content, strtab_offset,
strtab_offset + strtab_size)

local strtab_p = ffi.cast('char *', strtab_str)
local sym_is_found = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ collectgarbage()
for c, v in pairs(victims) do
str_hash(v)[0] = orig_hash[c]
end
test:ok(true, "table keys collisions are resolved properly (no assertions failed)")
test:ok(true,
"table keys collisions are resolved properly (no assertions failed)")

test:done(true)
2 changes: 2 additions & 0 deletions test/tarantool-tests/lj-688-snap-ir-rename.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jit.opt.start('hotloop=1')
-- platform-agnostic, there is no real necessity to test it
-- against ARM/ARM64 separately.
--
-- luacheck: push no max comment line length
-- See also https://drive.google.com/file/d/1iYkFx3F0DOtB9o9ykWfCEm-OdlJNCCL0/view?usp=share_link
-- luacheck: pop


local vals = {-0.1, 0.1, -0.1, 0.1}
Expand Down
6 changes: 4 additions & 2 deletions test/tarantool-tests/lj-819-fix-missing-uclo.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ local f = missing_uclo()
local res = f()
-- Without a patch we don't get here a function, because upvalue isn't closed
-- as desirable.
test:ok(type(res) == 'function', 'virtual machine consistency: type of returned value is correct')
test:ok(type(res) == 'function',
'virtual machine consistency: type of returned value is correct')

-- Make JIT compiler aggressive.
jit.opt.start('hotloop=1')
Expand All @@ -110,6 +111,7 @@ f()
f = missing_uclo()
local _
_, res = pcall(f)
test:ok(type(res) == 'function', 'consistency on compilation: type of returned value is correct')
test:ok(type(res) == 'function',
'consistency on compilation: type of returned value is correct')

test:done(true)
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ local _2pow52 = 2 ^ 52
-- double rounding. The numbers from the original issue are good
-- enough.
--
-- luacheck: push no max comment line length
--
-- [1]:https://developer.arm.com/documentation/dui0801/g/A64-Floating-point-Instructions/FMSUB
-- [2]:https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
--
-- luacheck: pop
--
-- IEEE754 components to double:
-- sign * (2 ^ (exp - 1023)) * (mantissa / _2pow52 + normal).
local a = 1 * (2 ^ (1083 - 1023)) * (4080546448249347 / _2pow52 + 1)
Expand Down
4 changes: 4 additions & 0 deletions test/tarantool-tests/lj-918-fma-numerical-accuracy.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ local _2pow52 = 2 ^ 52
-- double rounding. The numbers from the original issue are good
-- enough.
--
-- luacheck: push no max comment line length
--
-- [1]:https://developer.arm.com/documentation/dui0801/g/A64-Floating-point-Instructions/FMSUB
-- [2]:https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
--
-- luacheck: pop
--
-- IEEE754 components to double:
-- sign * (2 ^ (exp - 1023)) * (mantissa / _2pow52 + normal).
local a = 1 * (2 ^ (1083 - 1023)) * (4080546448249347 / _2pow52 + 1)
Expand Down
4 changes: 4 additions & 0 deletions test/tarantool-tests/or-144-gc64-asmref-l.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ local test = tap.test('or-144-gc64-asmref-l'):skipcond({

test:plan(1)

-- luacheck: push no max comment line length
--
-- Test file to demonstrate LuaJIT `IR_LREF` assembling incorrect
-- behaviour.
-- See also:
-- * https://github.com/openresty/lua-resty-core/issues/144.
-- * https://www.freelists.org/post/luajit/Consistent-SEGV-on-x64-with-the-latest-LuaJIT-v21-GC64-mode.
--
-- luacheck: pop

jit.opt.start('hotloop=1')

Expand Down

0 comments on commit b136c78

Please sign in to comment.