[Tarantool-patches] [PATCH v2] core: handle fiber cancellation for fiber.cond

Alexander Turenko alexander.turenko at tarantool.org
Tue Dec 1 00:46:33 MSK 2020


> > diff --git a/test/app-tap/gh-5013-fiber-cancel.test.lua b/test/app-tap/gh-5013-fiber-cancel.test.lua
> > new file mode 100755
> > index 000000000..ca4ca2c90
> > --- /dev/null
> > +++ b/test/app-tap/gh-5013-fiber-cancel.test.lua
> > @@ -0,0 +1,23 @@
> > +#!/usr/bin/env tarantool
> > +
> > +local tap = require('tap')
> > +local fiber = require('fiber')
> > +local test = tap.test("gh-5013-fiber-cancel")
> > +
> > +test:plan(2)
> > +
> > +local result = {}
> > +
> > +function test_f()
> > +    local cond = fiber.cond()
> > +    local res, err = pcall(cond.wait, cond)
> > +    result.res = res
> > +    result.err = err
> > +end
> > +
> > +local f = fiber.create(test_f)
> > +f:cancel()
> > +fiber.yield()
> > +
> > +test:ok(result.res == false, 'expected result is false')
> > +test:ok(tostring(result.err) == 'fiber is cancelled', 'fiber cancellation should be reported')
> 
> 2. I think you are also supposed to call os.exit with test:check()
> like other tap tests do. Otherwise it probably always ends with 0
> code, and won't work properly when we will make tap tests non-diff
> based.

Just side note. TAP13 tests are already not diff-based. test-run parses
and verifies TAP13 output if a result file is not present. test-run also
checks the exit code of a process. (That's all are about 'core = app'
test suites.)

But I anyway think that it is good property to return non-zero exit code
from a test if it is not passed. When all tests are written this way, we
have more freedom around ways to run a test. Who knows, maybe we'll want
to run some tests in a very restricted environment, where it will be
hard to get all this python stuff workable?


More information about the Tarantool-patches mailing list