From d8a9f1d9cf0cd639186213d8b29d05f60b8cecbf Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Thu, 5 Mar 2020 22:10:11 +0100 Subject: [PATCH] test: fix fio.test.lua flakiness In 89c73e64c071cb7402406bf1eb8d767d4dfe4e6e ("fio: respect $TMPDIR in fio.tempdir(), when it is set") was added a test checking that fio.tempdir() returns a path to a folder, stored by a path specified in $TMPDIR environment variable. Check was done by calling Lua returned_path:find(tmpdir_path). If tmpdir path contained 'special' characters such as '.', it didn't match, because string.find() takes a regular expression, not just a string. string.startswith() works fine. Follow-up #4794 --- test/app/fio.result | 6 +++--- test/app/fio.test.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/app/fio.result b/test/app/fio.result index cd18ed32c7..783fa4fab5 100644 --- a/test/app/fio.result +++ b/test/app/fio.result @@ -1465,7 +1465,7 @@ cwd = fio.cwd() old_tmpdir = os.getenv('TMPDIR') --- ... -tmpdir = cwd..'/tmp' +tmpdir = cwd..'/tmp-.dot.-' --- ... fio.mkdir(tmpdir) @@ -1478,7 +1478,7 @@ os.setenv('TMPDIR', tmpdir) dir = fio.tempdir() --- ... -dir:find(tmpdir) ~= nil or {dir, tmpdir} +dir:startswith(tmpdir) or {dir, tmpdir} --- - true ... @@ -1503,7 +1503,7 @@ os.setenv('TMPDIR', nil) dir = fio.tempdir() --- ... -dir:find('/tmp') ~= nil or dir +dir:startswith('/tmp') or dir --- - true ... diff --git a/test/app/fio.test.lua b/test/app/fio.test.lua index 242ff08ad7..6825b882f4 100644 --- a/test/app/fio.test.lua +++ b/test/app/fio.test.lua @@ -481,11 +481,11 @@ fio.mktree('/dev/null/dir') cwd = fio.cwd() old_tmpdir = os.getenv('TMPDIR') -tmpdir = cwd..'/tmp' +tmpdir = cwd..'/tmp-.dot.-' fio.mkdir(tmpdir) os.setenv('TMPDIR', tmpdir) dir = fio.tempdir() -dir:find(tmpdir) ~= nil or {dir, tmpdir} +dir:startswith(tmpdir) or {dir, tmpdir} fio.stat(dir) ~= nil or fio.stat(dir) tmpdir = cwd..'/tmp2' @@ -494,7 +494,7 @@ fio.tempdir() os.setenv('TMPDIR', nil) dir = fio.tempdir() -dir:find('/tmp') ~= nil or dir +dir:startswith('/tmp') or dir tmpdir = cwd..'/'..string.rep('t', 5000) os.setenv('TMPDIR', tmpdir) -- GitLab