[Tarantool-patches] [PATCH luajit 3/5] test: introduce test:skipall TAP helper
Maxim Kokryashkin
m.kokryashkin at tarantool.org
Tue Feb 28 10:51:10 MSK 2023
Hi, Igor!
Thanks for the patch!
LGTM, except for a few nits regarding the commit message.
>
>>Sometimes one need to skip all tests in the script. TAP13 protocol
>Typo: s/TAP 13/The TAP 13/
>>supports this via the following line:
>>| 1..0 # SKIP <reason>
>>
>>Within this commit <test:skipall> 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.
>Typo: s/worth to mention/worth mentioning/
>>test with no parent) tests and subtests are not supported at the moment.
>>The corresponding assertion with FIXME reason is added to <finalize>.
>Typo: s/with/with a/
>>
>>Signed-off-by: Igor Munkin < imun at tarantool.org >
>>---
>> 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 <plan> 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
>--
>Best regards,
>Maxim Kokryashkin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20230228/39448908/attachment.htm>
More information about the Tarantool-patches
mailing list