From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org>, Maxim Kokryashkin <m.kokryashkin@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH luajit 3/5] test: introduce test:skipall TAP helper Date: Mon, 27 Feb 2023 09:07:21 +0000 [thread overview] Message-ID: <2b510bb3d602fb66b7ee0310ca027f9e8be66480.1677236706.git.imun@tarantool.org> (raw) In-Reply-To: <cover.1677236706.git.imun@tarantool.org> Sometimes one need to skip all tests in the script. TAP13 protocol 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. test with no parent) tests and subtests are not supported at the moment. The corresponding assertion with FIXME reason is added to <finalize>. Signed-off-by: Igor Munkin <imun@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
next prev parent reply other threads:[~2023-02-27 9:11 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-27 9:07 [Tarantool-patches] [PATCH luajit 0/5] Tarantool tests enhancements Igor Munkin via Tarantool-patches 2023-02-27 9:07 ` [Tarantool-patches] [PATCH luajit 1/5] ci: use LuaJIT-test target in testing workflows Igor Munkin via Tarantool-patches 2023-02-27 9:41 ` Sergey Kaplun via Tarantool-patches 2023-02-28 7:42 ` Maxim Kokryashkin via Tarantool-patches 2023-02-27 9:07 ` [Tarantool-patches] [PATCH luajit 2/5] test: stop using utils.selfrun in tests Igor Munkin via Tarantool-patches 2023-02-27 10:08 ` Sergey Kaplun via Tarantool-patches 2023-02-27 18:04 ` Igor Munkin via Tarantool-patches 2023-02-28 7:46 ` Maxim Kokryashkin via Tarantool-patches 2023-02-27 9:07 ` Igor Munkin via Tarantool-patches [this message] 2023-02-27 9:51 ` [Tarantool-patches] [PATCH luajit 3/5] test: introduce test:skipall TAP helper Sergey Kaplun via Tarantool-patches 2023-02-27 18:04 ` Igor Munkin via Tarantool-patches 2023-02-28 7:51 ` Maxim Kokryashkin via Tarantool-patches 2023-02-28 16:26 ` Igor Munkin via Tarantool-patches 2023-02-27 9:07 ` [Tarantool-patches] [PATCH luajit 4/5] test: introduce test:skiprest " Igor Munkin via Tarantool-patches 2023-02-27 9:56 ` Sergey Kaplun via Tarantool-patches 2023-02-27 18:04 ` Igor Munkin via Tarantool-patches 2023-02-28 7:55 ` Maxim Kokryashkin via Tarantool-patches 2023-02-28 16:26 ` Igor Munkin via Tarantool-patches 2023-02-27 9:07 ` [Tarantool-patches] [PATCH luajit 5/5] test: make skipcond helper more convenient Igor Munkin via Tarantool-patches 2023-02-27 10:01 ` Sergey Kaplun via Tarantool-patches 2023-02-28 8:10 ` Maxim Kokryashkin via Tarantool-patches 2023-03-02 17:07 ` [Tarantool-patches] [PATCH luajit 0/5] Tarantool tests enhancements Igor Munkin via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=2b510bb3d602fb66b7ee0310ca027f9e8be66480.1677236706.git.imun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit 3/5] test: introduce test:skipall TAP helper' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox