diff --git a/doc/examples/example_conditional.tum b/doc/examples/example_conditional.tum index 7aaadf6..f04aa19 100644 --- a/doc/examples/example_conditional.tum +++ b/doc/examples/example_conditional.tum @@ -35,7 +35,7 @@ main: no_fail: True exit_condition: - value: <| "$(last_test_result)" == "PASS" |> + value: <| "$(last_step_result)" == "PASS" |> - let: diff --git a/doc/manual/sphinx/source/test_items/items_common_attributes.rst b/doc/manual/sphinx/source/test_items/items_common_attributes.rst index b9c2f15..cc7e024 100644 --- a/doc/manual/sphinx/source/test_items/items_common_attributes.rst +++ b/doc/manual/sphinx/source/test_items/items_common_attributes.rst @@ -92,12 +92,12 @@ if not provided is given in the table as well. last test result ----------------------------------------------- -The global variable ``last_test_result`` is automatically set at the end of a test item execution. +The global variable ``last_step_result`` is automatically set at the end of a test item execution. -If the corresponding test item does not return any acutal, the content of the ``last_test_result`` +If the corresponding test item does not return any acutal, the content of the ``last_step_result`` variable will be the test success (``PASS``, ``FAIL`` or ``SKIP``). -It the test item returns a value, the ``last_test_result`` variable will contain the returned value. +It the test item returns a value, the ``last_step_result`` variable will contain the returned value. The main test items returning a value are: @@ -192,7 +192,7 @@ Export attribute - check: name: Example of result specific to the step 001 values: - - $(last_test_result) == PASS + - $(last_step_result) == PASS key: - GID-1510554_step_1 report: diff --git a/doc/manual/sphinx/source/tum_syntax.rst b/doc/manual/sphinx/source/tum_syntax.rst index 4cecc6b..ce204a3 100644 --- a/doc/manual/sphinx/source/tum_syntax.rst +++ b/doc/manual/sphinx/source/tum_syntax.rst @@ -132,7 +132,7 @@ library API (see :ref:`helper library`) * ``test_name``: The name of the file being executed without extension, * ``home``: the path of the current user's home directory, * ``test_outputs``: list of the paths of the test log and test report (if any), -* ``last_test_result``: test result of the last step (see :ref:`sec_item_common`), +* ``last_step_result``: test result of the last step (see :ref:`sec_item_common`), * ``ts_start_``: timestamp at the start of test item execution (see :ref:`sec_item_common`), * ``ts_end_``: timestamp at the end of test item execution (see :ref:`sec_item_common`), * ``ts_duration_``: duration of test item execution in seconds (see :ref:`sec_item_common`), diff --git a/doc/manual/testium_manual.pdf b/doc/manual/testium_manual.pdf index eb9a886..fb2ace6 100644 Binary files a/doc/manual/testium_manual.pdf and b/doc/manual/testium_manual.pdf differ diff --git a/src/testium/interpreter/test_items/test_item.py b/src/testium/interpreter/test_items/test_item.py index 2557e0c..d1953f6 100644 --- a/src/testium/interpreter/test_items/test_item.py +++ b/src/testium/interpreter/test_items/test_item.py @@ -279,9 +279,9 @@ class TestItem: self.result.sendStatus(self.status_queue) if not self.result.value is None: - tm.setgd("last_test_result", str(self.result.value)) + tm.setgd("last_step_result", str(self.result.value)) else: - tm.setgd("last_test_result", str(self.result.test_result)) + tm.setgd("last_step_result", str(self.result.test_result)) self.write_footer() self._is_running = False self._is_stopped = False @@ -316,12 +316,6 @@ class TestItem: print(e) self.result.set(TestValue.FAILURE, "Result processing failed") - if isinstance(self.result.value, bool): - if self.result.value: - self.result.set(TestValue.SUCCESS, "Processing result returned 'True'") - else: - self.result.set(TestValue.FAILURE, "Processing result returned 'False'") - def process_report(self, report_eval): tm.print_debug(f"Export reported values:") rep_eval = self._prms.expanse(report_eval) diff --git a/src/testium/interpreter/utils/params.py b/src/testium/interpreter/utils/params.py index d8c22a1..4c39ea4 100644 --- a/src/testium/interpreter/utils/params.py +++ b/src/testium/interpreter/utils/params.py @@ -10,7 +10,7 @@ class TestItemParams: self._parent = parent def expanse(self, param_value): - return expanse(param_value, self._parent) + return expanse(param_value, parent=self._parent) def getParam(self, parameter, default=None, required=False, processed=False): """Returns a parameter value from the test item dictionnary. diff --git a/test/validation/items/common/results/test.tum b/test/validation/items/common/results/test.tum index fb17fbe..f9cec2c 100644 --- a/test/validation/items/common/results/test.tum +++ b/test/validation/items/common/results/test.tum @@ -49,7 +49,7 @@ file: $(test_path)$(psep)results$(psep)results.py func_name: echo param: [ 28 ] - expected_result: "$(last_test_result)" + expected_result: "$(last_step_result)" - group: name : Expected result Failure raised issue diff --git a/test/validation/items/lua_func/lua_func.lua b/test/validation/items/lua_func/lua_func.lua new file mode 100644 index 0000000..ad3c409 --- /dev/null +++ b/test/validation/items/lua_func/lua_func.lua @@ -0,0 +1,30 @@ +tm = require("tm") + +local module = {} + +function module.donothing(param) + return 0 +end + +function module.assertparam(param) + assert(param) +end + +function module.checkglobal(param, index) + return tm.gd("lua_data_to_be_returned")[index] +end + +function module.should_not_be_called(param) + assert(false) +end + +function module.echo(param) + return param +end + +function module.tuple_return(first, second) + return first, second +end + + +return module \ No newline at end of file diff --git a/test/validation/items/lua_func/param.yaml b/test/validation/items/lua_func/param.yaml new file mode 100644 index 0000000..3caeeaf --- /dev/null +++ b/test/validation/items/lua_func/param.yaml @@ -0,0 +1,6 @@ +skipped_test_item: ['skipped_checkglobal'] + +lua_data_to_be_returned: + - 1 + - {a: 1, b: 2} + - ["a", 1, 2.1, True] \ No newline at end of file diff --git a/test/validation/items/func/test.tum b/test/validation/items/lua_func/test.tum similarity index 100% rename from test/validation/items/func/test.tum rename to test/validation/items/lua_func/test.tum diff --git a/test/validation/items/func/param.yaml b/test/validation/items/py_func/param.yaml similarity index 100% rename from test/validation/items/func/param.yaml rename to test/validation/items/py_func/param.yaml diff --git a/test/validation/items/func/func.py b/test/validation/items/py_func/py_func.py similarity index 100% rename from test/validation/items/func/func.py rename to test/validation/items/py_func/py_func.py diff --git a/test/validation/items/py_func/test.tum b/test/validation/items/py_func/test.tum new file mode 100644 index 0000000..7819af3 --- /dev/null +++ b/test/validation/items/py_func/test.tum @@ -0,0 +1,179 @@ + +- lua_func: + name: pass lua_func + key: $(test)_PASS + file: lua_func.lua + func_name: func_to_be_executed + param: + - true + +- lua_func: + name: fail lua_func + key: $(test)_FAIL + file: $(test_path)$(psep)lua_func.lua + func_name: assertparam + param: + - false + +- lua_func: + name: fail lua_func with expected result FAIL + key: $(test)_PASS + file: $(test_path)$(psep)lua_func.lua + func_name: assertparam + param: + - false + expected_result: FAIL + +- lua_func: + name: pass lua_func with expected result FAIL + key: $(test)_FAIL + file: $(test_path)$(psep)lua_func.lua + func_name: assertparam + param: + - true + expected_result: FAIL + +- lua_func: + name: expected -1 + key: $(test)_PASS + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: + - -1 + expected_result: -1 + +- lua_func: + name: expected eval + key: $(test)_PASS + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: + - -1 + expected_result: "354848436 - 354848437" + +- lua_func: + name: expected table + key: $(test)_PASS + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: + - [-1, a, {toto: tata}] + expected_result: "[-1, 'a', {'toto': 'tata'}]" + +- lua_func: + name: global param lua_func + key: $(test)_PASS + file: $(test_path)$(psep)lua_func.lua + func_name: checkglobal + param: + - $(test parameter) + +- let: + name: python2func + key: $(test)_PASS + values: + - py: $(test_path)$(psep)lua_func.lua + +- lua_func: + name: global param lua_func + key: $(test)_PASS + file: $(py) + func_name: checkglobal + param: + - $(test parameter) + +- lua_func: + name: skipped_checkglobal + file: $(test_path)$(psep)lua_func.lua + func_name: should_not_be_called + param: + - $(test parameter) + +- lua_func: + name: skipped true + file: $(test_path)$(psep)lua_func.lua + func_name: checkglobal + skipped: true + param: + - $(test parameter) + +- lua_func: + name: skipped true + file: $(test_path)$(psep)lua_func.lua + func_name: checkglobal + skipped: true + param: + - $(test parameter) + +- lua_func: + name: skipped 1 + file: $(test_path)$(psep)lua_func.lua + func_name: checkglobal + skipped: 1 + param: + - $(test parameter) + +- lua_func: + name: FunctionItem test + file: $(test_path)$(psep)lua_func.lua + func_name: ValidationTest + param: + - $(test parameter) + +- group: + name: Function results check + steps: + - group: + name: Function result failure + steps: + - lua_func: + name: int failure + key: $(test)_FAIL + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: [-1] + - lua_func: + name: float failure + key: $(test)_FAIL + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: [-1.3] + - lua_func: + name: String failure + key: $(test)_FAIL + file: $(test_path)$(psep)lua_func.lua + func_name: echo + param: [ "FAIL" ] + - lua_func: + name: Tuple int,str failure + key: $(test)_FAIL + 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 + file: $(test_path)$(psep)lua_func.lua + func_name: tuple_return + param: [ 0, "OK" ]