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 A680D2ADDE4; Mon, 27 Feb 2023 12:11:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A680D2ADDE4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1677489094; bh=NR0iPISarPCI6R+ZJ+vyD1OhZgcDm8ES8T2gP+JCt+w=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tTTYmkiQ4xznbP94b3w1by03x0LblkDkl+UwnKubIMekC/+KYhOhnhFpyefJhCCgv 0+RJw4q1+DXWqWwMj185QYRoXIwv5Nwd6RgdLnmeh+/FQi3fKZq7gN/+5CnQtQ5CVr 5zKf/J+DoSmJy1VV0l+RWS5ggNuXe3dKL7NIyCYA= Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [95.163.41.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 295382ADDE4 for ; Mon, 27 Feb 2023 12:10:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 295382ADDE4 Received: by smtp31.i.mail.ru with esmtpa (envelope-from ) id 1pWZWG-002jL3-0A; Mon, 27 Feb 2023 12:10:04 +0300 To: Sergey Kaplun , Maxim Kokryashkin Date: Mon, 27 Feb 2023 09:07:21 +0000 Message-Id: <2b510bb3d602fb66b7ee0310ca027f9e8be66480.1677236706.git.imun@tarantool.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9806C989EC2150E3328F2CD81DB6B81556375ED936772CB93182A05F5380850406E56738A20CC3156AF931F91C1AA1ACB39E6BC7627365892F600E77B57AAB791 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AC4684DF4EC4B256EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FA81DCE0280C9CC68F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB553375661CAE6147465D531EAF5F589687C37D1A1948BA020B90D3E8A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7F1FF917D59728F209FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C369BF13FED57427F1117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFAF0AC7AF9D4D80F4BA3038C0950A5D36C8A9BA7A39EFB766EC990983EF5C0329BA3038C0950A5D36D5E8D9A59859A8B6AE053DFED46ECC3876E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C837C4FEFBD186071C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5AA253F5706ED70F6AB363DFE61A064F4537183508B3293F24EAF44D9B582CE87C8A4C02DF684249CC203C45FEA855C8F X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34CC972AA0E2E780C42E2641FF2BD7D18E6E3E175859C49920D765DDAD6C2E4A589F3C9029F79FA93B1D7E09C32AA3244CBB1440BEFD00830F74BCAC1EA92E8493A90944CA99CF22E3927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojY+HhiuGRi+qOqe9H6cilig== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D53124005329899888351118B64796B86AEA3E538EFCE493DF052326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 3/5] test: introduce test:skipall TAP helper 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sometimes one need to skip all tests in the script. TAP13 protocol supports this via the following line: | 1..0 # SKIP Within this commit helper is introduced that yields the aforementined line to the TAP consumer and exits the test script. It's worth to mention, that skipall helper is implemented only for root (i.e. test with no parent) tests and subtests are not supported at the moment. The corresponding assertion with FIXME reason is added to . Signed-off-by: Igor Munkin --- test/tarantool-tests/tap.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/test/tarantool-tests/tap.lua b/test/tarantool-tests/tap.lua index a1f54d20..92d59ce9 100644 --- a/test/tarantool-tests/tap.lua +++ b/test/tarantool-tests/tap.lua @@ -7,6 +7,12 @@ local ffi = require("ffi") local NULL = ffi.new("void *") +local function finalize(test) + -- TODO: implement finalization for subtests too. + assert(test.parent == nil, 'FIXME: There is no way to use finalize subtest') + os.exit(test:check() and 0 or 1) +end + local function indent(level, size) -- Use the default indent size if none is specified. size = tonumber(size) or 4 @@ -90,6 +96,11 @@ local function skip(test, message, extra) ok(test, true, message .. " # skip", extra) end +local function skipall(test, reason) + test:plan(0, reason) + finalize(test) +end + local function like(test, got, pattern, message, extra) extra = extra or {} extra.got = got @@ -246,7 +257,7 @@ local function new(parent, name, fun, ...) level = level, total = 0, failed = 0, - planned = 0, + planned = nil, trace = parent == nil and true or parent.trace, -- Set test.strict = true if test:is, test:isnt and -- test:is_deeply must be compared strictly with nil. @@ -266,9 +277,14 @@ local function new(parent, name, fun, ...) return test:check() end -local function plan(test, planned) +local function plan(test, planned, reason) + if test.planned then + -- Use call location in the error message. + error("plan called twice", 2) + end test.planned = planned - io.write(indent(test.level), ("1..%d\n"):format(planned)) + local tail = planned == 0 and (" # SKIP %s"):format(reason) or "" + io.write(indent(test.level), ("1..%d%s\n"):format(planned, tail)) end local function check(test) @@ -313,6 +329,7 @@ test_mt = { ok = ok, fail = fail, skip = skip, + skipall = skipall, is = is, isnt = isnt, isnil = isnil, -- 2.30.2