Skip to content

Commit

Permalink
test: adjust treegen for TMPDIR ending with slash
Browse files Browse the repository at this point in the history
Our macOS runners have such a TMPDIR value. It breaks
`config-luatest/basic_test.lua`, because net.box seems unable to connect
a Unix domain socket using an URI with a double slash in the middle.

See the comment in the code for details.

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC

(cherry picked from commit 8c3b4c0)
  • Loading branch information
Totktonada committed Dec 29, 2023
1 parent 1605613 commit 078b548
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/treegen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,39 @@ function treegen.prepare_directory(g, scripts, replacements)
assert(type(replacements) == 'table')

local dir = fio.tempdir()

-- fio.tempdir() follows the TMPDIR environment variable.
-- If it ends with a slash, the return value contains a double
-- slash in the middle: for example, if TMPDIR=/tmp/, the
-- result is like `/tmp//rfbWOJ`.
--
-- It looks harmless on the first glance, but this directory
-- path may be used later to form an URI for a Unix domain
-- socket. As result the URI looks like
-- `unix/:/tmp//rfbWOJ/instance-001.iproto`.
--
-- It confuses net_box.connect(): it reports EAI_NONAME error
-- from getaddrinfo().
--
-- It seems, the reason is a peculiar of the URI parsing:
--
-- tarantool> uri.parse('unix/:/foo/bar.iproto')
-- ---
-- - host: unix/
-- service: /foo/bar.iproto
-- unix: /foo/bar.iproto
-- ...
--
-- tarantool> uri.parse('unix/:/foo//bar.iproto')
-- ---
-- - host: unix
-- path: /foo//bar.iproto
-- ...
--
-- Let's normalize the path using fio.abspath(), which
-- eliminates the double slashes.
dir = fio.abspath(dir)

table.insert(g.tempdirs, dir)

for _, script in ipairs(scripts) do
Expand Down

0 comments on commit 078b548

Please sign in to comment.