lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


(tl;dr: RTFM)

Did you read the test documentation at <https://www.lua.org/tests/>?

The portable tests should be run as `.../lua -e"_U=true" all.lua`.

The full tests require you to build included libraries first. As you say
that

I then expand the testing tarball and run:

/opt/lua/5.3.4/bin/lua all.lua
(with no mention of that compilation step) I assume that you didn't,
which might explain the error.

Further, it's always a good idea to read the area around the test that
fails - there may already be instructions there on what might need
changing.  It's also helpful to include the source around the offending
location in the mail – the tests change between minor versions (which
makes line numbers from a stack trace useless), so everyone who wants to
help has to find exactly the right version of the files to have a chance
of identifying the reason.

In this case (if I have the same version as you) the source in
attrib.lua around line 246 is

----------------------------------------------------------------------
-- testing require of C libraries                              -- L237


local p = ""   -- On Mac OS X, redefine this to "_"            -- L240

-- check whether loadlib works in this system
local st, err, when = package.loadlib(DC"lib1", "*")           -- L243
if not st then
  local f, err, when = package.loadlib("donotexist", p.."xuxu")
  assert(not f and type(err) == "string" and when == "absent") -- L246
  ;(Message or print)('\n >>> cannot load dynamic library <<<\n')
  print(err, when)
else
----------------------------------------------------------------------

which points at problems with those libraries.  However, if I try to run
that line in my REPL, I get

package.loadlib( "foo", "bar" )
nil	foo: cannot […] No such file or directory	open

so the (when == "absent") part of the test would fail for me as well,
because (when == "open") – IF I reach that line while running the tests.
But… if I compile the libraries in libs/ first, the loading of "lib1" on
line 243 succeeds, so we end up in the else branch & skip this test - so
everything runs fine.

So you probably did not read the documentation. :(

(But now _I_ am wondering what that line is supposed to do…)

Unfortunately, the reference manual doesn't say _anything_ about the
expected return values of the `package.loadlib` function.  So let's
quickly check `loadlib.c` (which provides `package.*` functions).

`package.loadlib` corresponds to `ll_loadlib`, which returns (on error)
nil, whatever dlerror() returned, (stat == ERRLIB) ? LIB_FAIL : "init".
LIB_FAIL is defined as "open" when dynamic libraries are supported and
as "absent" otherwise.

So all is well, the test works as expected.  That line would pass if
dynamic libraries are not supported (and would print a warning
afterwards).  It fails if dynamic libraries _should_ work but something
is broken (e.g. you forgot to compile the library).

-- nobody