From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id F0EC76EC5C; Tue, 20 Jul 2021 19:32:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F0EC76EC5C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626798726; bh=pmF9BtI6b81GckYbZ8eJ7K1AproaJ/GilGPTRedkcgw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=d+7FEzYRmj3DR8jXYxIMMPE98YN1PKMM/B2TxAtgycwCwYG77NDGVdJ8WtS3gy/I5 cadpDa2UxUlSjI8AimvKRKNYLn7ppRHr6DL6JdHjaQbo4CsCII5YfAErthvqvzxgkw dzMxLfCQqFU0XJ+Ka3sfDBUIi/BEK9CTvVlN4Zuk= Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 309D86F3C3 for ; Tue, 20 Jul 2021 19:28:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 309D86F3C3 Received: by mail-lj1-f176.google.com with SMTP id t3so1657711ljc.3 for ; Tue, 20 Jul 2021 09:28:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L4NDm/OaCSb4SUKgPCoP+5UL6IhZbrEtuPwQeWMD5co=; b=Eyx18QCtYE2YXVtVGlNVhDPXy9f5v0zOsZsyu4Gu+999r0n+zJg6NE1KTtPMSaJIXG oDWRlIMrX/Bya6IqA3NSbGbFUMXx78Jzo+6tSXvohkd8OlBNtfnkKAgp3Hxuy1zABSAZ Erj1yXIR899ZbkBxZUhiojYb2aizBZh+6KYEIUBoQJ4VSvNuAwJRaweBuIH4qpm1c6my 6zXjKRVTOy5CFAqrt9kXYp4CxFGdyWwyeiU7tqgHNU1AjmjHmt6j+IG2+a4RZEWEHH6/ i2uGLcCz0UN4elqiCUacIi7RjLDdBm4y8hgM5OdoJi7LUwSrY3W3KC4Jajj+Dm5sYmeo aaEw== X-Gm-Message-State: AOAM531HTOwutzELVmOEP1e4xBvOkP0D3KnaKYpl62DL94giSJiTtwiX hO7yp35IqGfHwNZLcXv/piQw3TUJHQGS2tT1 X-Google-Smtp-Source: ABdhPJyyWM+EOu9DUStOncDhZQhsRfzTHRsMwnhyXFdCOmVe8GS5W1rSkLQl9VVqeup2pO/Mxpgvvw== X-Received: by 2002:a2e:a36a:: with SMTP id i10mr6437524ljn.389.1626798483425; Tue, 20 Jul 2021 09:28:03 -0700 (PDT) Received: from localhost.localdomain ([2a00:1fa0:44c8:ff00:875c:6e54:99e0:fb4a]) by smtp.gmail.com with ESMTPSA id d8sm1562660lfi.129.2021.07.20.09.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 09:28:03 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org Date: Tue, 20 Jul 2021 19:26:57 +0300 Message-Id: <72be0416bbad48dca0240fbb8046ee5e6e596227.1626797225.git.m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 09/10] test: update lua-Harness to b7b1a9a2 X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch backports several small commits from lua-Harness suite: - follow ravi 1.0-beta4[1] - refactor with near[2] - follow LuaJIT[3] - fix when no debug[4] - check if luac exists[5] - https[6] - more assert[7] [1]: https://framagit.org/fperrad/lua-Harness/-/commit/9455281b [2]: https://framagit.org/fperrad/lua-Harness/-/commit/70404580 [3]: https://framagit.org/fperrad/lua-Harness/-/commit/ac7671b6 [4]: https://framagit.org/fperrad/lua-Harness/-/commit/4db7e539 [5]: https://framagit.org/fperrad/lua-Harness/-/commit/97e9e4c1 [6]: https://framagit.org/fperrad/lua-Harness/-/commit/673c7869 [7]: https://framagit.org/fperrad/lua-Harness/-/commit/b7b1a9a2 Part of #5970 Part of #4473 --- test/lua-Harness-tests/200-examples.t | 2 +- test/lua-Harness-tests/203-lexico.t | 2 +- test/lua-Harness-tests/241-standalone.t | 3 +- test/lua-Harness-tests/242-luac.t | 4 +++ test/lua-Harness-tests/301-basic.t | 2 +- test/lua-Harness-tests/304-string.t | 2 +- test/lua-Harness-tests/307-math.t | 44 +++++++++++------------ test/lua-Harness-tests/310-debug.t | 2 -- test/lua-Harness-tests/320-stdin.t | 14 +++++--- test/lua-Harness-tests/401-bitop.t | 2 +- test/lua-Harness-tests/402-ffi.t | 2 +- test/lua-Harness-tests/403-jit.t | 2 +- test/lua-Harness-tests/404-ext.t | 2 +- test/lua-Harness-tests/411-luajit.t | 2 +- test/lua-Harness-tests/profile_ravi.lua | 4 +-- test/lua-Harness-tests/test_assertion.lua | 9 +++++ 16 files changed, 57 insertions(+), 41 deletions(-) diff --git a/test/lua-Harness-tests/200-examples.t b/test/lua-Harness-tests/200-examples.t index 7020af4d..9d7ec6d9 100755 --- a/test/lua-Harness-tests/200-examples.t +++ b/test/lua-Harness-tests/200-examples.t @@ -70,7 +70,7 @@ equals(iter_factorial(7), 5040, "factorial (iter)") --[[ Knuth's "man or boy" test. - See http://en.wikipedia.org/wiki/Man_or_boy_test + See https://en.wikipedia.org/wiki/Man_or_boy_test ]] diff --git a/test/lua-Harness-tests/203-lexico.t b/test/lua-Harness-tests/203-lexico.t index 396a167f..ef6f9212 100755 --- a/test/lua-Harness-tests/203-lexico.t +++ b/test/lua-Harness-tests/203-lexico.t @@ -19,7 +19,7 @@ =head2 Description See "Lua 5.3 Reference Manual", section 3.1 "Lexical Conventions", -L. +L. See section "Lexical Conventions" L, diff --git a/test/lua-Harness-tests/241-standalone.t b/test/lua-Harness-tests/241-standalone.t index e4cf83b5..afbcf5b8 100755 --- a/test/lua-Harness-tests/241-standalone.t +++ b/test/lua-Harness-tests/241-standalone.t @@ -45,6 +45,7 @@ end local lua = _retrieve_progname() local luac = jit and lua or (lua .. 'c') +local exists_luac = io.open(luac, 'r') if not pcall(io.popen, lua .. [[ -e "a=1"]]) then skip_all "io.popen not supported" @@ -78,7 +79,7 @@ else end f:close() -if has_bytecode then +if has_bytecode and exists_luac then if jit then os.execute(lua .. " -b hello-241.lua hello-241.luac") else diff --git a/test/lua-Harness-tests/242-luac.t b/test/lua-Harness-tests/242-luac.t index 526b31fe..c15c9a54 100755 --- a/test/lua-Harness-tests/242-luac.t +++ b/test/lua-Harness-tests/242-luac.t @@ -41,6 +41,10 @@ end local lua = _retrieve_progname() local luac = lua .. 'c' +if not io.open(luac, 'r') then + skip_all "no luac" +end + if not pcall(io.popen, lua .. [[ -e "a=1"]]) then skip_all "io.popen not supported" end diff --git a/test/lua-Harness-tests/301-basic.t b/test/lua-Harness-tests/301-basic.t index 01e187d9..4adbb55c 100755 --- a/test/lua-Harness-tests/301-basic.t +++ b/test/lua-Harness-tests/301-basic.t @@ -167,7 +167,7 @@ end f:close() dofile('lib-301.lua') local n = norm(3.4, 1.0) - matches(twice(n), '^7%.088', "function dofile") + near(twice(n), 7.088, 0.001, "function dofile") os.remove('lib-301.lua') -- clean up diff --git a/test/lua-Harness-tests/304-string.t b/test/lua-Harness-tests/304-string.t index 82e0408d..ac7e802a 100755 --- a/test/lua-Harness-tests/304-string.t +++ b/test/lua-Harness-tests/304-string.t @@ -277,7 +277,7 @@ do -- format equals(string.format("%s %d", r, r:len()), r .. " 200") error_matches(function () string.format("%s %s", 1) end, - "^[^:]+:%d+: bad argument #3 to 'format' %(.-no value%)", + "^[^:]+:%d+: bad argument #3 to 'format' %(.-value.-%)", "function format (too few arg)") error_matches(function () string.format('%d', 'toto') end, diff --git a/test/lua-Harness-tests/307-math.t b/test/lua-Harness-tests/307-math.t index 08b1e5ec..757637f8 100755 --- a/test/lua-Harness-tests/307-math.t +++ b/test/lua-Harness-tests/307-math.t @@ -56,20 +56,20 @@ do -- abs end do -- acos - matches(math.acos(0.5), '^1%.047', "function acos") + near(math.acos(0.5), 1.047, 0.001, "function acos") end do -- asin - matches(math.asin(0.5), '^0%.523', "function asin") + near(math.asin(0.5), 0.523, 0.001, "function asin") end do -- atan - matches(math.atan(0.5), '^0%.463', "function atan") + near(math.atan(0.5), 0.463, 0.001, "function atan") end -- atan2 if has_mathx then - matches(math.atan2(1.0, 2.0), '^0%.463', "function atan2") + near(math.atan2(1.0, 2.0), 0.463, 0.001, "function atan2") else is_nil(math.atan2, "function atan2 (removed)") end @@ -84,12 +84,12 @@ do -- ceil end do -- cos - matches(math.cos(1.0), '^0%.540', "function cos") + near(math.cos(1.0), 0.540, 0.001, "function cos") end -- cosh if has_mathx then - matches(math.cosh(1.0), '^1%.543', "function cosh") + near(math.cosh(1.0), 1.543, 0.001, "function cosh") else is_nil(math.cosh, "function cosh (removed)") end @@ -99,7 +99,7 @@ do -- deg end do -- exp - matches(math.exp(1.0), '^2%.718', "function exp") + near(math.exp(1.0), 2.718, 0.001, "function exp") end do -- floor @@ -112,9 +112,9 @@ do -- floor end do -- fmod - matches(math.fmod(7.0001, 0.3), '^0%.100', "function fmod (float)") - matches(math.fmod(-7.0001, 0.3), '^-0%.100') - matches(math.fmod(-7.0001, -0.3), '^-0%.100') + near(math.fmod(7.0001, 0.3), 0.100, 0.001, "function fmod (float)") + near(math.fmod(-7.0001, 0.3), -0.100, 0.001) + near(math.fmod(-7.0001, -0.3), -0.100, 0.001) if math.type then equals(math.type(math.fmod(7.0, 0.3)), 'float') end @@ -155,17 +155,17 @@ else end do -- log - matches(math.log(47), '^3%.85', "function log") + near(math.log(47), 3.85, 0.01, "function log") if has_log_with_base then - matches(math.log(47, math.exp(1)), '^3%.85', "function log (base e)") - matches(math.log(47, 2), '^5%.554', "function log (base 2)") - matches(math.log(47, 10), '^1%.672', "function log (base 10)") + near(math.log(47, math.exp(1)), 3.85, 0.01, "function log (base e)") + near(math.log(47, 2), 5.554, 0.001, "function log (base 2)") + near(math.log(47, 10), 1.672, 0.001, "function log (base 10)") end end -- log10 if has_log10 then - matches(math.log10(47.0), '^1%.672', "function log10") + near(math.log10(47.0), 1.672, 0.001, "function log10") else is_nil(math.log10, "function log10 (removed)") end @@ -223,7 +223,7 @@ do -- modf end do -- pi - matches(tostring(math.pi), '^3%.14', "variable pi") + near(math.pi, 3.14, 0.01, "variable pi") end -- pow @@ -234,7 +234,7 @@ else end do -- rad - matches(math.rad(180), '^3%.14', "function rad") + near(math.rad(180), 3.14, 0.01, "function rad") end do -- random @@ -291,27 +291,27 @@ do -- randomseed end do -- sin - matches(math.sin(1.0), '^0%.841', "function sin") + near(math.sin(1.0), 0.841, 0.001, "function sin") end -- sinh if has_mathx then - matches(math.sinh(1), '^1%.175', "function sinh") + near(math.sinh(1), 1.175, 0.001, "function sinh") else is_nil(math.sinh, "function sinh (removed)") end do -- sqrt - matches(math.sqrt(2), '^1%.414', "function sqrt") + near(math.sqrt(2), 1.414, 0.001, "function sqrt") end do -- tan - matches(math.tan(1.0), '^1%.557', "function tan") + near(math.tan(1.0), 1.557, 0.001, "function tan") end -- tanh if has_mathx then - matches(math.tanh(1), '^0%.761', "function tanh") + near(math.tanh(1), 0.761, 0.001, "function tanh") else is_nil(math.tanh, "function tanh (removed)") end diff --git a/test/lua-Harness-tests/310-debug.t b/test/lua-Harness-tests/310-debug.t index f8338d1f..a75047f2 100755 --- a/test/lua-Harness-tests/310-debug.t +++ b/test/lua-Harness-tests/310-debug.t @@ -42,8 +42,6 @@ local has_setmetatable52 = _VERSION >= 'Lua 5.2' or (profile.luajit_compat52 and local has_upvalueid = _VERSION >= 'Lua 5.2' or jit local has_upvaluejoin = _VERSION >= 'Lua 5.2' or jit -local debug = require 'debug' - if not debug then skip_all("no debug") end diff --git a/test/lua-Harness-tests/320-stdin.t b/test/lua-Harness-tests/320-stdin.t index f4de97fd..cc867309 100755 --- a/test/lua-Harness-tests/320-stdin.t +++ b/test/lua-Harness-tests/320-stdin.t @@ -32,7 +32,7 @@ if not pcall(io.popen, lua .. [[ -e "a=1"]]) then skip_all "io.popen not supported" end -plan(12) +plan'no_plan' do local f = io.open('lib-320.lua', 'w') @@ -49,7 +49,7 @@ end local cmd = lua .. [[ -e "dofile(); n = norm(3.4, 1.0); print(twice(n))" < lib-320.lua]] f = io.popen(cmd) - matches(f:read'*l', '^7%.088', "function dofile (stdin)") + near(f:read'*n', 7.088, 0.001, "function dofile (stdin)") f:close() os.remove('lib-320.lua') -- clean up @@ -102,14 +102,14 @@ do local cmd = lua .. [[ -e "while true do local n1, n2, n3 = io.read('*number', '*number', '*number'); if not n1 then break end; print(math.max(n1, n2, n3)) end" < number-320.txt]] f = io.popen(cmd) - matches(f:read'*l', '15000%.?', "function io:read *number") - equals(f:read'*l', '1000001') + equals(f:read'*n', 15000, "function io:read *number") + equals(f:read'*n', 1000001) f:close() os.remove('number-320.txt') -- clean up end -do +if debug then local f = io.open('dbg-320.txt', 'w') f:write("print 'ok'\n") f:write("error 'dbg'\n") @@ -123,8 +123,12 @@ do f:close() os.remove('dbg-320.txt') -- clean up +else + diag("no debug") end +done_testing() + -- Local Variables: -- mode: lua -- lua-indent-level: 4 diff --git a/test/lua-Harness-tests/401-bitop.t b/test/lua-Harness-tests/401-bitop.t index 84259cd3..66a99eb2 100755 --- a/test/lua-Harness-tests/401-bitop.t +++ b/test/lua-Harness-tests/401-bitop.t @@ -18,7 +18,7 @@ =head2 Description -See L. +See L. =cut diff --git a/test/lua-Harness-tests/402-ffi.t b/test/lua-Harness-tests/402-ffi.t index 48ae8c20..22d47aec 100755 --- a/test/lua-Harness-tests/402-ffi.t +++ b/test/lua-Harness-tests/402-ffi.t @@ -18,7 +18,7 @@ =head2 Description -See L. +See L. =cut diff --git a/test/lua-Harness-tests/403-jit.t b/test/lua-Harness-tests/403-jit.t index 1724dfd1..0f986da9 100755 --- a/test/lua-Harness-tests/403-jit.t +++ b/test/lua-Harness-tests/403-jit.t @@ -18,7 +18,7 @@ =head2 Description -See L. +See L. =cut diff --git a/test/lua-Harness-tests/404-ext.t b/test/lua-Harness-tests/404-ext.t index 45701671..c3b8370d 100755 --- a/test/lua-Harness-tests/404-ext.t +++ b/test/lua-Harness-tests/404-ext.t @@ -18,7 +18,7 @@ =head2 Description -See L. +See L. =cut diff --git a/test/lua-Harness-tests/411-luajit.t b/test/lua-Harness-tests/411-luajit.t index da1af9ce..3a9a7b8f 100755 --- a/test/lua-Harness-tests/411-luajit.t +++ b/test/lua-Harness-tests/411-luajit.t @@ -18,7 +18,7 @@ =head2 Description -See L +See L =cut diff --git a/test/lua-Harness-tests/profile_ravi.lua b/test/lua-Harness-tests/profile_ravi.lua index 8cd2464e..fcee5cb1 100644 --- a/test/lua-Harness-tests/profile_ravi.lua +++ b/test/lua-Harness-tests/profile_ravi.lua @@ -31,7 +31,7 @@ local profile = { --]] nocvtn2s = false, - nocvts2n = false, + nocvts2n = true, compat53 = false, --[[ @@ -51,7 +51,7 @@ package.loaded.profile = profile -- prevents loading of default profile return profile -- --- Copyright (c) 2018-2019 Francois Perrad +-- Copyright (c) 2018-2021 Francois Perrad -- -- This library is licensed under the terms of the MIT/X11 license, -- like Lua itself. diff --git a/test/lua-Harness-tests/test_assertion.lua b/test/lua-Harness-tests/test_assertion.lua index 67cf37f9..a4a9c6ca 100644 --- a/test/lua-Harness-tests/test_assertion.lua +++ b/test/lua-Harness-tests/test_assertion.lua @@ -94,6 +94,15 @@ function not_equals (got, not_expected, name) end end +function near (got, expected, tolerance, name) + local pass = got >= (expected - tolerance) and got <= (expected + tolerance) + truthy(pass, name) + if not pass then + diag(" got: " .. tostring(got)) + diag(" expected: " .. tostring(expected) .. " +/- " .. tostring(tolerance)) + end +end + function matches (got, pattern, name) local pass = tostring(got):match(pattern) truthy(pass, name) -- 2.32.0