diff options
author | Evan Huus <eapache@gmail.com> | 2014-05-17 10:49:54 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-05-21 03:17:15 +0000 |
commit | a1e6b10239e47626a60177891521fecf87e54766 (patch) | |
tree | 65b40d640a48cf04eee31f74cc8775cf802356e6 /test | |
parent | 0ac1779822b88990940ddd731a0f47c664e065f3 (diff) |
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 <eapache@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/dir.lua | 30 |
1 files changed, 16 insertions, 14 deletions
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") |