Solve a tuple error in Lua and unify Lua and Python tests

This commit is contained in:
2026-06-05 01:47:00 +02:00
parent 3fb982b057
commit 811e3d356e
7 changed files with 298 additions and 126 deletions

View File

@@ -56,9 +56,17 @@ function handle.func_call(params)
if err == nil then if err == nil then
print(string.format("Function executed from '%s'", pfile)) print(string.format("Function executed from '%s'", pfile))
utils.log("func_call function found '%s', '%s'", file, fname) utils.log("func_call function found '%s', '%s'", file, fname)
succ, ret = pcall(func, unpack(prms)) err_res = {pcall(func, unpack(prms))}
utils.log("func_call returned '%s', '%s'", tostring(succ), tostring(ret)) utils.log("func_call returned '%s', '%s'", tostring(succ), tostring(ret))
-- manage tuple ouput of a lua function
succ = table.remove(err_res, 1)
if #err_res > 1 then
ret = err_res
else
ret = unpack(err_res)
end
if succ then if succ then
res = ret res = ret
else else

View File

@@ -12,12 +12,12 @@ function module.assertparam(param)
end end
function module.checkglobal(param) function module.checkglobal(param)
local res = tm.gd(param) assert(param=='test parameter')
return res return 0
end end
function module.checkglobal2(index) function module.checkglobal2(index)
return tm.gd("lua_data_to_be_returned")[index] return tm.gd("data_to_be_returned")[index+1]
end end
function module.should_not_be_called(param) function module.should_not_be_called(param)
@@ -53,7 +53,7 @@ function module.return_nothing()
-- Returns no value: ret is nil but no error. -- Returns no value: ret is nil but no error.
end end
function module.return_explicit_nil() function module.return_explicit_none()
return nil return nil
end end

View File

@@ -1,6 +1,6 @@
skipped_test_item: ['skipped_checkglobal'] skipped_test_item: ['skipped_checkglobal']
lua_data_to_be_returned: data_to_be_returned:
- 1 - 1
- {a: 1, b: 2} - {a: 1, b: 2}
- ["a", 1, 2.1, True] - ["a", 1, 2.1, True]

View File

@@ -1,7 +1,15 @@
- let: - let:
name: lua_func test constants, name: lua_func test constants,
values: values:
- lua_func test parameter: test parameter lua_func - func_test_parameter: test parameter
- lua_func:
name: pass lua_func
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: assertparam
param:
- true
- lua_func: - lua_func:
name: fail lua_func name: fail lua_func
@@ -12,7 +20,7 @@
- false - false
- lua_func: - lua_func:
name: fail lua_func with expected result FAIL name: fail lua_func with expected result "FAIL"
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: assertparam func_name: assertparam
@@ -62,35 +70,7 @@
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal func_name: checkglobal
param: param:
- lua_func test parameter - $(func_test_parameter)
expected_result: $(lua_func test parameter)
- lua_func:
name: global param lua_func 1
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 1
expected_result: ($(lua_data_to_be_returned))[0]
- lua_func:
name: global param lua_func 2
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 2
expected_result: ($(lua_data_to_be_returned))[1]
- lua_func:
name: global param lua_func 3
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 3
expected_result: ($(lua_data_to_be_returned))[2]
- let: - let:
name: python2func name: python2func
@@ -98,88 +78,189 @@
values: values:
- py: $(test_path)$(psep)lua_func.lua - py: $(test_path)$(psep)lua_func.lua
- lua_func:
name: global param int
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 0
expected_result: ($(data_to_be_returned))[0]
- lua_func:
name: global param dict
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 1
expected_result: ($(data_to_be_returned))[1]
- lua_func:
name: global param list
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal2
param:
- 2
expected_result: ($(data_to_be_returned))[2]
- lua_func:
name: global param lua_func
key: $(test)_PASS
file: $(py)
func_name: checkglobal
param:
- $(func_test_parameter)
- lua_func: - lua_func:
name: skipped_checkglobal name: skipped_checkglobal
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: should_not_be_called func_name: should_not_be_called
param: param:
- $(test parameter) - $(func_test_parameter)
- lua_func: - lua_func:
name: skipped true name: skipped true
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal func_name: echo
skipped: true skipped: true
param: param:
- $(test parameter) - "skipped"
- lua_func: - lua_func:
name: skipped 1 name: skipped 1
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: checkglobal func_name: echo
skipped: 1 skipped: 1
param: param:
- $(test parameter) - "skipped"
- group: - group:
name: Function results check name: Function results check
steps: steps:
- group: - group:
name: Function result failure name: Functions result
steps: steps:
- lua_func: - lua_func:
name: int failure name: int
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: echo func_name: echo
param: [-1] param: [-1]
- lua_func: - lua_func:
name: float failure name: float
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: echo func_name: echo
param: [-1.3] param: [-20.3]
- lua_func: - lua_func:
name: String failure name: String
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: echo func_name: echo
param: [ "FAIL" ] param: [ "FAIL" ]
- lua_func: - lua_func:
name: Tuple int,str failure name: Tuple int,str
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: tuple_return
param: [ -1, "Got a failure" ]
- group:
name: Functions result success
steps:
- lua_func:
name: int success
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [0]
- lua_func:
name: float success
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [0.3]
- lua_func:
name: String success
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ "Something that is not only strictly FAIL" ]
- lua_func:
name: Tuple int,str success
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: tuple_return func_name: tuple_return
param: [ 0, "OK" ] param: [ 0, "OK" ]
- group:
name: Functions result expected
steps:
- lua_func:
name: int expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [18]
expected_result: 18
- lua_func:
name: float expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [0.3]
expected_result: 0.3
- lua_func:
name: String expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ "Something" ]
expected_result: Something
- lua_func:
name: Tuple int,str expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: tuple_return
param: [ 0, "OK" ]
expected_result: [0, "OK"]
- lua_func:
name: small list expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ [-23] ]
expected_result: [-23]
- lua_func:
name: big list expected
key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ [-23, 17, 67] ]
expected_result: [-23, 17, 67]
- group:
name: Function result not expected
steps:
- lua_func:
name: int not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [18]
expected_result: 17
- lua_func:
name: float not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [0.3]
expected_result: 0.5
- lua_func:
name: String not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ "Something" ]
expected_result: Nothing
- lua_func:
name: Tuple int,str not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: tuple_return
param: [ 0, "OK" ]
expected_result: [0, "OUPS"]
- lua_func:
name: small list not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ [-23] ]
expected_result: [-22]
- lua_func:
name: big list not expected
key: $(test)_FAIL
file: $(test_path)$(psep)lua_func.lua
func_name: echo
param: [ [-23, 17, 67] ]
expected_result: [-23, 16, 67]
- lua_func: - lua_func:
name: delgd test name: delgd test
key: $(test)_PASS key: $(test)_PASS
@@ -193,40 +274,39 @@
func_name: return_nothing func_name: return_nothing
- lua_func: - lua_func:
name: function returning explicit nil should succeed name: function returning explicit None should succeed
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: return_explicit_nil func_name: return_explicit_none
- group: - group:
name: context_id tests name: context_id tests
steps: steps:
- lua_func: - lua_func:
name: set context value name: set serializable value
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: set_context_value func_name: set_context_value
context_id: lua_ctx_test
param: param:
- hello lua - hello context
expected_result: hello lua expected_result: hello context
- lua_func: - lua_func:
name: get context value (same context_id) name: get serializable value (same context_id)
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: get_context_value func_name: get_context_value
context_id: lua_ctx_test context_id: ctx_test
expected_result: hello lua expected_result: hello context
- lua_func: - lua_func:
name: get context value (no context_id, from main gd) name: get serializable value (no context_id, from main gd)
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: get_context_value func_name: get_context_value
expected_result: hello lua expected_result: hello context
- lua_func: - lua_func:
name: get context value (different context_id) name: get serializable value (different context_id)
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)lua_func.lua file: $(test_path)$(psep)lua_func.lua
func_name: get_context_value func_name: get_context_value
context_id: lua_ctx_other context_id: ctx_other
expected_result: hello lua expected_result: hello context

View File

@@ -1 +1,6 @@
skipped_test_item: ['skipped_checkglobal'] skipped_test_item: ['skipped_checkglobal']
data_to_be_returned:
- 1
- {a: 1, b: 2}
- ["a", 1, 2.1, True]

View File

@@ -16,8 +16,8 @@ def checkglobal(param):
assert param=='test parameter' assert param=='test parameter'
return 0 return 0
def checkglobal2(): def checkglobal2(index):
return tm.gd("py_func test parameter") return tm.gd("data_to_be_returned")[index]
def should_not_be_called(param): def should_not_be_called(param):
raise raise

View File

@@ -1,7 +1,7 @@
- let: - let:
name: py_func test constants, name: py_func test constants,
values: values:
- py_func test parameter: test parameter - func_test_parameter: test parameter
- py_func: - py_func:
name: pass py_func name: pass py_func
@@ -70,7 +70,7 @@
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: checkglobal func_name: checkglobal
param: param:
- $(py_func test parameter) - $(func_test_parameter)
- let: - let:
name: python2func name: python2func
@@ -79,11 +79,32 @@
- py: $(test_path)$(psep)py_func.py - py: $(test_path)$(psep)py_func.py
- py_func: - py_func:
name: global param py_func 2 name: global param int
key: $(test)_PASS key: $(test)_PASS
file: $(py) file: $(test_path)$(psep)py_func.py
func_name: checkglobal2 func_name: checkglobal2
expected_result: $(py_func test parameter) param:
- 0
expected_result: ($(data_to_be_returned))[0]
- py_func:
name: global param dict
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py
func_name: checkglobal2
param:
- 1
expected_result: ($(data_to_be_returned))[1]
- py_func:
name: global param list
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py
func_name: checkglobal2
param:
- 2
expected_result: ($(data_to_be_returned))[2]
- py_func: - py_func:
@@ -92,104 +113,162 @@
file: $(py) file: $(py)
func_name: checkglobal func_name: checkglobal
param: param:
- $(py_func test parameter) - $(func_test_parameter)
- py_func: - py_func:
name: skipped_checkglobal name: skipped_checkglobal
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: should_not_be_called func_name: should_not_be_called
param: param:
- $(py_func test parameter) - $(func_test_parameter)
- py_func: - py_func:
name: skipped true name: skipped true
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: checkglobal func_name: echo
skipped: true skipped: true
param: param:
- $(py_func test parameter) - "skipped"
- py_func: - py_func:
name: skipped 1 name: skipped 1
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: checkglobal func_name: echo
skipped: 1 skipped: 1
param: param:
- $(py_func test parameter) - "skipped"
- py_func: - py_func:
name: FunctionItem test name: FunctionItem test
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: ValidationTest func_name: ValidationTest
param: param:
- $(py_func test parameter) - $(func_test_parameter)
- group: - group:
name: Function results check name: Function results check
steps: steps:
- group: - group:
name: Function result 1 name: Functions result
steps: steps:
- py_func: - py_func:
name: int failure name: int
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [-1] param: [-1]
expected_result: -1
- py_func: - py_func:
name: float failure name: float
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [-1.3] param: [-20.3]
expected_result: -1.3
- py_func: - py_func:
name: String failure name: String
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [ "FAIL" ] param: [ "FAIL" ]
expected_result: FAIL
- py_func: - py_func:
name: Tuple int,str failure name: Tuple int,str
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: tuple_return func_name: tuple_return
param: [ -1, "Got a failure" ] param: [ 0, "OK" ]
expected_result: [-1, "Got a failure"]
- group: - group:
name: Functions result 2 name: Functions result expected
steps: steps:
- py_func: - py_func:
name: int success name: int expected
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [0] param: [18]
expected_result: 0 expected_result: 18
- py_func: - py_func:
name: float success name: float expected
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [0.3] param: [0.3]
expected_result: 0.3 expected_result: 0.3
- py_func: - py_func:
name: String success name: String expected
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: echo func_name: echo
param: [ "Something that is not only strictly FAIL" ] param: [ "Something" ]
expected_result: Something that is not only strictly FAIL expected_result: Something
- py_func: - py_func:
name: Tuple int,str success name: Tuple int,str expected
key: $(test)_PASS key: $(test)_PASS
file: $(test_path)$(psep)py_func.py file: $(test_path)$(psep)py_func.py
func_name: tuple_return func_name: tuple_return
param: [ 0, "OK" ] param: [ 0, "OK" ]
expected_result: [0, "OK"] expected_result: [0, "OK"]
- py_func:
name: small list expected
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [ [-23] ]
expected_result: [-23]
- py_func:
name: big list expected
key: $(test)_PASS
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [ [-23, 17, 67] ]
expected_result: [-23, 17, 67]
- group:
name: Function result not expected
steps:
- py_func:
name: int not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [18]
expected_result: 17
- py_func:
name: float not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [0.3]
expected_result: 0.5
- py_func:
name: String not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [ "Something" ]
expected_result: Nothing
- py_func:
name: Tuple int,str not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: tuple_return
param: [ 0, "OK" ]
expected_result: [0, "OUPS"]
- py_func:
name: small list not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [ [-23] ]
expected_result: [-22]
- py_func:
name: big list not expected
key: $(test)_FAIL
file: $(test_path)$(psep)py_func.py
func_name: echo
param: [ [-23, 17, 67] ]
expected_result: [-23, 16, 67]
- py_func: - py_func:
name: delgd test name: delgd test
key: $(test)_PASS key: $(test)_PASS