[Tarantool-patches] [PATCH v2 luajit 03/30] test: adapt Lua 5.1 suite for out-of-source build

Sergey Kaplun skaplun at tarantool.org
Fri Mar 26 17:25:40 MSK 2021


Hi!

Thanks for the review!

On 26.03.21, Sergey Ostanevich wrote:
> LGTM, just minor changes to commit message.
> 
> Sergos
> 
> 
> > On 26 Mar 2021, at 10:42, Sergey Kaplun <skaplun at tarantool.org> wrote:
> > 
> > When tests are run out-of-source redefined `dofile()` function
>                                   ^ I had problem reading here the 
> ‘out-of-source redefined’. Can you put the ‘when..’ to the appropriate
> place at the end of the sentence? ’The redefined … when … ‘

Fixed.

The new committ message is the following (branch is force-pushed):

===================================================================
test: adapt Lua 5.1 suite for out-of-source build

When tests are run out-of-source redefined `dofile()` function failed to
find the test file to load. So, fullpath is detected considering
`arg[0]` value. Moreover, some tests use `loadfile()` instead, so their
argument is adjusted to the full path to the files.

However, test in <verybig.lua> creates a temporary file
and executes it via `dofile()` too, so this case is handled by
the second argument -- `prefix` equals an empty string for
current working directory.

Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
===================================================================

>  
> > failed to find file to load. So, fullpath is detected considering
> > `arg[0]` value. Moreover, some tests use `loadfile()` instead, so
> > their argument is adjusted to the full path to the files.
> > 
> > However, test in <verybig.lua> creates a temporary file
> > and executes it via `dofile()` too, so this case is handled by
> > the second argument -- `prefix` equals an empty string for
> > current working directory.
> > 
> > Part of tarantool/tarantool#5845
> > Part of tarantool/tarantool#4473
> > ---
> > test/PUC-Lua-5.1-tests/all.lua     | 17 +++++++++++++----
> > test/PUC-Lua-5.1-tests/verybig.lua |  4 +++-
> > 2 files changed, 16 insertions(+), 5 deletions(-)
> > 
> > diff --git a/test/PUC-Lua-5.1-tests/all.lua b/test/PUC-Lua-5.1-tests/all.lua
> > index 8c4afac..85beff8 100755
> > --- a/test/PUC-Lua-5.1-tests/all.lua
> > +++ b/test/PUC-Lua-5.1-tests/all.lua
> > @@ -58,9 +58,18 @@ end
> > --
> > -- redefine dofile to run files through dump/undump
> > --
> > -dofile = function (n)
> > +-- LuaJIT: Adapt tests for testing with out-of-source build.
> > +-- XXX: Test in <verybig.lua> creates a temporary file
> > +-- and executes it via `dofile()` too, so this case is handled by
> > +-- the second argument -- `prefix` equals an empty string for
> > +-- current working directory.
> > +-- <all.lua> is in the same directory, where are other common
> > +-- executed files situated.
> > +local path_to_sources = arg[0]:gsub('([^/]+)%.lua$', '')
> > +dofile = function (n, prefix)
> > +  local pr = prefix or path_to_sources
> >   showmem()
> > -  local f = assert(loadfile(n))
> > +  local f = assert(loadfile(pr..n))
> >   local b = string.dump(f)
> >   f = assert(loadstring(b))
> >   return f()
> > @@ -77,7 +86,7 @@ do
> >   end
> > end
> > 
> > -local f = assert(loadfile('gc.lua'))
> > +local f = assert(loadfile(path_to_sources..'gc.lua'))
> > f()
> > dofile('db.lua')
> > assert(dofile('calls.lua') == deep and deep)
> > @@ -88,7 +97,7 @@ assert(dofile('locals.lua') == 5)
> > dofile('constructs.lua')
> > dofile('code.lua')
> > do
> > -  local f = coroutine.wrap(assert(loadfile('big.lua')))
> > +  local f = coroutine.wrap(assert(loadfile(path_to_sources..'big.lua')))
> >   assert(f() == 'b')
> >   assert(f() == 'a')
> > end
> > diff --git a/test/PUC-Lua-5.1-tests/verybig.lua b/test/PUC-Lua-5.1-tests/verybig.lua
> > index 59e0142..edb170d 100644
> > --- a/test/PUC-Lua-5.1-tests/verybig.lua
> > +++ b/test/PUC-Lua-5.1-tests/verybig.lua
> > @@ -93,7 +93,9 @@ for s in string.gmatch(prog, "$([^$]+)") do
> >   if not n then io.write(s) else F[n]() end
> > end
> > io.close()
> > -result = dofile(file)
> > +-- LuaJIT: Adapt test for testing with out-of-source build.
> > +-- See comment in <all.lua> near `dofile()` redefinition.
> > +result = dofile(file, "")
> > assert(os.remove(file))
> > print'OK'
> > return result
> > -- 
> > 2.31.0
> > 
> 

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list