From a1e6b10239e47626a60177891521fecf87e54766 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Sat, 17 May 2014 10:49:54 -0400 Subject: Fix lua directory tests. The underlying directory iterator is not guaranteed to return directories in the same order according to the glib documentation, so don't rely on the directory order being the same when testing it. https://developer.gnome.org/glib/2.37/glib-File-Utilities.html#g-dir-read-name Bug:10009 Change-Id: I4b1078e1f3981921b1e83c4f77b4bc30a5d21b46 Reviewed-on: https://code.wireshark.org/review/1671 Reviewed-by: Evan Huus --- test/lua/dir.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'test/lua') diff --git a/test/lua/dir.lua b/test/lua/dir.lua index 88ecbe2ce9..51ea84e5f0 100644 --- a/test/lua/dir.lua +++ b/test/lua/dir.lua @@ -131,18 +131,17 @@ test("Dir.open", typeof(t.result) == 'Dir') io.stdout:write("calling Dir object...") local dir = t.result -local file = dir() +local files = {} +files[dir()] = true io.stdout:write("passed\n") +files[dir()] = true +files[dir()] = true -test("Dir.call", file == "file1.txt") -file = dir() -test("Dir.call", file == "file2.txt") -file = dir() -test("Dir.call", file == "file3.txt") -file = dir() -test("Dir.call", file == nil) -file = dir() -test("Dir.call", file == nil) +test("Dir.call", files["file1.txt"]) +test("Dir.call", files["file2.txt"]) +test("Dir.call", files["file3.txt"]) +test("Dir.call", dir() == nil) +test("Dir.call", dir() == nil) testing("Dir.close") @@ -154,14 +153,17 @@ testing("Negative testing 1") test("Dir.open", pcall(callDirFunc, "open", "temp", t)) dir = t.result -- call dir() now -file = dir() -test("Dir.call", file == "file1.txt") +files = {} +files[dir()] = true Dir.remove_all("temp") -- call it again -file = dir() -test("Dir.call", file == "file2.txt") +files[dir()] = true +files[dir()] = true +test("Dir.call", files["file1.txt"]) +test("Dir.call", files["file2.txt"]) +test("Dir.call", files["file3.txt"]) test("Dir.close", pcall(callDirFunc, "close", dir, t)) testing("Negative testing 2") -- cgit v1.2.3