[Tarantool-patches] [PATCH 1/1] test: fix fio.test.lua flakiness

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Fri Mar 6 00:15:17 MSK 2020


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
---
Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-4794-follow-up-test
Issue: https://github.com/tarantool/tarantool/issues/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 cd18ed32c..783fa4fab 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 242ff08ad..6825b882f 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)
-- 
2.21.1 (Apple Git-122.3)



More information about the Tarantool-patches mailing list