aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-10 15:18:24 -0400
committerAnders Broman <a.broman58@gmail.com>2014-03-11 05:30:58 +0000
commit9961ee369c97768d5ed906d5ef5d17b718d33d3e (patch)
tree0c4c556d5949df2e4b99df061e3678729f928f5e /test
parentf4de2a2dd1142e7d7c9069bc923eeb8c7ac20333 (diff)
Fix Bug 9870 'Lua: trying to call/get an invalid name results in a get-loop error'
Due to the change I made previously for how methods are accessed, if you try to access one that doesn't exist (for example mistype it or whatever), you get an internal Lua error about a loop in table get, as opposed to the right error message about the field not existing. That's because I had set the class' metatable __index metamethod to point to the class table, which of course has the metatable with the __index metamethod, causing a lookup loop. Blech. Change-Id: I20d3717feadd45f652c2640e1671846184e7082d Reviewed-on: https://code.wireshark.org/review/593 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/lua/inspect.lua11
-rw-r--r--test/lua/verify_globals.lua9
2 files changed, 16 insertions, 4 deletions
diff --git a/test/lua/inspect.lua b/test/lua/inspect.lua
index 64b6b5bf5b..1a57ade8b6 100644
--- a/test/lua/inspect.lua
+++ b/test/lua/inspect.lua
@@ -648,10 +648,16 @@ end
function inspect.makeFilter(arrayTable)
local filter = {} -- our filter lookup tree (tables of tables)
local matchNode = {} -- a table instance we use as a key for nodes which match
+ local wildcard = {} -- a key table of wildcard match names
local function buildFilter(pathname)
local t = filter
local key
+ -- if the filtered name starts with a '.', it's a wildcard
+ if pathname:find("^%.") then
+ wildcard[pathname:sub(2)] = true
+ return
+ end
for sep, name in pathname:gmatch("([%.%[\"\']*)([^%.%[\"\'%]]+)[\"\'%]]?") do
if sep == '[' then
if name == 'true' then
@@ -689,8 +695,11 @@ function inspect.makeFilter(arrayTable)
buildFilter(pathname)
end
- return function(_,path)
+ return function(value,path)
local t = filter
+ if wildcard[ path[#path] ] then
+ return true
+ end
for _,v in ipairs(path) do
if not t[v] then
return false
diff --git a/test/lua/verify_globals.lua b/test/lua/verify_globals.lua
index 86d4a2a8b7..dbed8ceb91 100644
--- a/test/lua/verify_globals.lua
+++ b/test/lua/verify_globals.lua
@@ -19,7 +19,8 @@ local filter = {
-- differences caused by changes in wireshark 1.11
"NSTime",
"Proto",
- 'Listener["<metatable>"].__index'
+ 'Listener["<metatable>"].__index',
+ ".__index"
}
-- the following items don't have to exist
@@ -69,6 +70,8 @@ if #arg > 0 then
add_path = arg[1].."?.lua;"
end
+print("package.path = " .. package.path)
+
-- need the path to find inspect.lua
local old_path = package.path
package.path = add_path .. package.path
@@ -96,7 +99,7 @@ end
if #arg == 2 or arg[3] == "verify" then
print(string.rep("\n", 2))
- print("Verifying input file '"..arg[1].."' is contained within the global table")
+ print("Verifying input file '"..arg[2].."' is contained within the global table")
local ret, diff = inspect.compare(input, _G, {
['filter'] = inspect.makeFilter(filter),
['ignore'] = inspect.makeFilter(ignore),
@@ -114,7 +117,7 @@ if #arg == 2 or arg[3] == "verify" then
print("All tests passed!\n\n")
end
return
-elseif #arg > 1 and arg[2] == "new" then
+elseif #arg > 2 and arg[3] == "new" then
local ret, diff = inspect.compare(_G, input, {
['filter'] = inspect.makeFilter(filter),
['ignore'] = inspect.makeFilter(ignore),