diff --git a/test_files/expected_tree_parametric_file.lua b/test_files/expected_tree_parametric_file.lua index b513354..f077061 100644 --- a/test_files/expected_tree_parametric_file.lua +++ b/test_files/expected_tree_parametric_file.lua @@ -1,176 +1,178 @@ -local path = "./test_files/parametric_tests_spec.lua" +return function(path) + local tail_path = vim.fn.fnamemodify(path, ":t") -return { - { - id = path, - name = "parametric_tests_spec.lua", - path = path, - range = { 0, 0, 29, 0 }, - type = "file", - }, - { + return { { - id = path .. '::"namespace 1"', - name = '"namespace 1"', + id = path, + name = tail_path, path = path, - range = { 0, 0, 12, 4 }, - type = "namespace", + range = { 0, 0, 29, 0 }, + type = "file", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"', - name = '"nested namespace 1"', + id = path .. '::"namespace 1"', + name = '"namespace 1"', path = path, - range = { 1, 4, 11, 8 }, + range = { 0, 0, 12, 4 }, type = "namespace", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', - name = '("test %d"):format(i)', + id = path .. '::"namespace 1"::"nested namespace 1"', + name = '"nested namespace 1"', path = path, - range = { 3, 12, 5, 16 }, - type = "test", + range = { 1, 4, 11, 8 }, + type = "namespace", }, - -- Two new nodes have been added to the tree for the two parametric tests that were run { { - id = path .. "::namespace::1::nested::namespace::1::test::1", - in_tree = false, - name = "test 1", - lnum = 4, + id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', + name = '("test %d"):format(i)', path = path, + range = { 3, 12, 5, 16 }, type = "test", }, - }, - { + -- Two new nodes have been added to the tree for the two parametric tests that were run { - id = path .. "::namespace::1::nested::namespace::1::test::2", - in_tree = false, - name = "test 2", - lnum = 4, - path = path, - type = "test", + { + id = path .. "::namespace::1::nested::namespace::1::test::1", + in_tree = false, + name = "test 1", + lnum = 4, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::1::nested::namespace::1::test::2", + in_tree = false, + name = "test 2", + lnum = 4, + path = path, + type = "test", + }, }, - }, - }, - { - { - id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', - name = '"test " .. "3"', - path = path, - range = { 8, 8, 10, 12 }, - type = "test", }, { { - id = path .. "::namespace::1::nested::namespace::1::test::3", - in_tree = false, - name = "test 3", - lnum = 9, + id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', + name = '"test " .. "3"', path = path, + range = { 8, 8, 10, 12 }, type = "test", }, + { + { + id = path .. "::namespace::1::nested::namespace::1::test::3", + in_tree = false, + name = "test 3", + lnum = 9, + path = path, + type = "test", + }, + }, }, }, }, - }, - { - { - id = path .. '::"namespace 2"', - name = '"namespace 2"', - path = path, - range = { 14, 0, 28, 4 }, - type = "namespace", - }, { { - id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', - name = '"nested namespace 2 - " .. tostring(i)', + id = path .. '::"namespace 2"', + name = '"namespace 2"', path = path, - range = { 16, 8, 26, 12 }, + range = { 14, 0, 28, 4 }, type = "namespace", }, { { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', - name = '"some test"', + id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', + name = '"nested namespace 2 - " .. tostring(i)', path = path, - range = { 17, 12, 19, 16 }, - type = "test", + range = { 16, 8, 26, 12 }, + type = "namespace", }, { { - id = path .. "::namespace::2::nested::namespace::2::-::1::some::test", - in_tree = false, - name = "some test", - lnum = 18, + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', + name = '"some test"', path = path, + range = { 17, 12, 19, 16 }, type = "test", }, - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::2::some::test", - in_tree = false, - name = "some test", - lnum = 18, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::1::some::test", + in_tree = false, + name = "some test", + lnum = 18, + path = path, + type = "test", + }, }, - }, - }, - { - { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', - name = '("test %d"):format(j)', - path = path, - range = { 22, 16, 24, 20 }, - type = "test", - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::1::test::1", - in_tree = false, - name = "test 1", - lnum = 23, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::2::some::test", + in_tree = false, + name = "some test", + lnum = 18, + path = path, + type = "test", + }, }, }, { { - id = path .. "::namespace::2::nested::namespace::2::-::1::test::2", - in_tree = false, - name = "test 2", - lnum = 23, + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', + name = '("test %d"):format(j)', path = path, + range = { 22, 16, 24, 20 }, type = "test", }, - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::2::test::1", - in_tree = false, - name = "test 1", - lnum = 23, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::1::test::1", + in_tree = false, + name = "test 1", + lnum = 23, + path = path, + type = "test", + }, }, - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::2::test::2", - in_tree = false, - name = "test 2", - lnum = 23, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::1::test::2", + in_tree = false, + name = "test 2", + lnum = 23, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::2::test::1", + in_tree = false, + name = "test 1", + lnum = 23, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::2::test::2", + in_tree = false, + name = "test 2", + lnum = 23, + path = path, + type = "test", + }, }, }, }, }, - }, -} + } +end diff --git a/test_files/expected_tree_parametric_namespace.lua b/test_files/expected_tree_parametric_namespace.lua index 6c188de..dc644c9 100644 --- a/test_files/expected_tree_parametric_namespace.lua +++ b/test_files/expected_tree_parametric_namespace.lua @@ -1,145 +1,147 @@ -local path = "./test_files/parametric_tests_spec.lua" +return function(path) + local tail_path = vim.fn.fnamemodify(path, ":t") -return { - { - id = path, - name = "parametric_tests_spec.lua", - path = path, - range = { 0, 0, 29, 0 }, - type = "file", - }, - { + return { { - id = path .. '::"namespace 1"', - name = '"namespace 1"', + id = path, + name = tail_path, path = path, - range = { 0, 0, 12, 4 }, - type = "namespace", + range = { 0, 0, 29, 0 }, + type = "file", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"', - name = '"nested namespace 1"', + id = path .. '::"namespace 1"', + name = '"namespace 1"', path = path, - range = { 1, 4, 11, 8 }, + range = { 0, 0, 12, 4 }, type = "namespace", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', - name = '("test %d"):format(i)', + id = path .. '::"namespace 1"::"nested namespace 1"', + name = '"nested namespace 1"', path = path, - range = { 3, 12, 5, 16 }, - type = "test", - }, - }, - { - { - id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', - name = '"test " .. "3"', - path = path, - range = { 8, 8, 10, 12 }, - type = "test", - }, - }, - }, - }, - { - { - id = path .. '::"namespace 2"', - name = '"namespace 2"', - path = path, - range = { 14, 0, 28, 4 }, - type = "namespace", - }, - { - { - id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', - name = '"nested namespace 2 - " .. tostring(i)', - path = path, - range = { 16, 8, 26, 12 }, - type = "namespace", - }, - { - { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', - name = '"some test"', - path = path, - range = { 17, 12, 19, 16 }, - type = "test", + range = { 1, 4, 11, 8 }, + type = "namespace", }, { { - id = path .. "::namespace::2::nested::namespace::2::-::1::some::test", - in_tree = false, - name = "some test", - lnum = 18, + id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', + name = '("test %d"):format(i)', path = path, + range = { 3, 12, 5, 16 }, type = "test", }, }, { { - id = path .. "::namespace::2::nested::namespace::2::-::2::some::test", - in_tree = false, - name = "some test", - lnum = 18, + id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', + name = '"test " .. "3"', path = path, + range = { 8, 8, 10, 12 }, type = "test", }, }, }, + }, + { + { + id = path .. '::"namespace 2"', + name = '"namespace 2"', + path = path, + range = { 14, 0, 28, 4 }, + type = "namespace", + }, { { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', - name = '("test %d"):format(j)', + id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', + name = '"nested namespace 2 - " .. tostring(i)', path = path, - range = { 22, 16, 24, 20 }, - type = "test", + range = { 16, 8, 26, 12 }, + type = "namespace", }, { { - id = path .. "::namespace::2::nested::namespace::2::-::1::test::1", - in_tree = false, - name = "test 1", - lnum = 23, + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', + name = '"some test"', path = path, + range = { 17, 12, 19, 16 }, type = "test", }, - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::1::test::2", - in_tree = false, - name = "test 2", - lnum = 23, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::1::some::test", + in_tree = false, + name = "some test", + lnum = 18, + path = path, + type = "test", + }, }, - }, - { { - id = path .. "::namespace::2::nested::namespace::2::-::2::test::1", - in_tree = false, - name = "test 1", - lnum = 23, - path = path, - type = "test", + { + id = path .. "::namespace::2::nested::namespace::2::-::2::some::test", + in_tree = false, + name = "some test", + lnum = 18, + path = path, + type = "test", + }, }, }, { { - id = path .. "::namespace::2::nested::namespace::2::-::2::test::2", - in_tree = false, - name = "test 2", - lnum = 23, + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', + name = '("test %d"):format(j)', path = path, + range = { 22, 16, 24, 20 }, type = "test", }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::1::test::1", + in_tree = false, + name = "test 1", + lnum = 23, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::1::test::2", + in_tree = false, + name = "test 2", + lnum = 23, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::2::test::1", + in_tree = false, + name = "test 1", + lnum = 23, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::2::nested::namespace::2::-::2::test::2", + in_tree = false, + name = "test 2", + lnum = 23, + path = path, + type = "test", + }, + }, }, }, }, - }, -} + } +end diff --git a/test_files/parametric_test_output_fail.json b/test_files/expected_tree_parametric_namespace_failed.lua similarity index 100% rename from test_files/parametric_test_output_fail.json rename to test_files/expected_tree_parametric_namespace_failed.lua diff --git a/test_files/expected_tree_parametric_test.lua b/test_files/expected_tree_parametric_test.lua index 7e14ffe..a91a735 100644 --- a/test_files/expected_tree_parametric_test.lua +++ b/test_files/expected_tree_parametric_test.lua @@ -1,106 +1,108 @@ -local path = "./test_files/parametric_tests_spec.lua" +return function(path) + local tail_path = vim.fn.fnamemodify(path, ":t") -return { - { - id = path, - name = "parametric_tests_spec.lua", - path = path, - range = { 0, 0, 29, 0 }, - type = "file", - }, - { + return { { - id = path .. '::"namespace 1"', - name = '"namespace 1"', + id = path, + name = tail_path, path = path, - range = { 0, 0, 12, 4 }, - type = "namespace", + range = { 0, 0, 29, 0 }, + type = "file", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"', - name = '"nested namespace 1"', + id = path .. '::"namespace 1"', + name = '"namespace 1"', path = path, - range = { 1, 4, 11, 8 }, + range = { 0, 0, 12, 4 }, type = "namespace", }, { { - id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', - name = '("test %d"):format(i)', + id = path .. '::"namespace 1"::"nested namespace 1"', + name = '"nested namespace 1"', path = path, - range = { 3, 12, 5, 16 }, - type = "test", + range = { 1, 4, 11, 8 }, + type = "namespace", }, - -- Two new nodes have been added to the tree for the two parametric tests that were run { { - id = path .. "::namespace::1::nested::namespace::1::test::1", - in_tree = false, - name = "test 1", - lnum = 4, + id = path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)', + name = '("test %d"):format(i)', path = path, + range = { 3, 12, 5, 16 }, type = "test", }, + -- Two new nodes have been added to the tree for the two parametric tests that were run + { + { + id = path .. "::namespace::1::nested::namespace::1::test::1", + in_tree = false, + name = "test 1", + lnum = 4, + path = path, + type = "test", + }, + }, + { + { + id = path .. "::namespace::1::nested::namespace::1::test::2", + in_tree = false, + name = "test 2", + lnum = 4, + path = path, + type = "test", + }, + }, }, { { - id = path .. "::namespace::1::nested::namespace::1::test::2", - in_tree = false, - name = "test 2", - lnum = 4, + id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', + name = '"test " .. "3"', path = path, + range = { 8, 8, 10, 12 }, type = "test", }, }, }, - { - { - id = path .. '::"namespace 1"::"nested namespace 1"::"test " .. "3"', - name = '"test " .. "3"', - path = path, - range = { 8, 8, 10, 12 }, - type = "test", - }, - }, - }, - }, - { - { - id = path .. '::"namespace 2"', - name = '"namespace 2"', - path = path, - range = { 14, 0, 28, 4 }, - type = "namespace", }, { { - id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', - name = '"nested namespace 2 - " .. tostring(i)', + id = path .. '::"namespace 2"', + name = '"namespace 2"', path = path, - range = { 16, 8, 26, 12 }, + range = { 14, 0, 28, 4 }, type = "namespace", }, { { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', - name = '"some test"', + id = path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)', + name = '"nested namespace 2 - " .. tostring(i)', path = path, - range = { 17, 12, 19, 16 }, - type = "test", + range = { 16, 8, 26, 12 }, + type = "namespace", }, - }, - { { - id = path - .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', - name = '("test %d"):format(j)', - path = path, - range = { 22, 16, 24, 20 }, - type = "test", + { + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::"some test"', + name = '"some test"', + path = path, + range = { 17, 12, 19, 16 }, + type = "test", + }, + }, + { + { + id = path + .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)::("test %d"):format(j)', + name = '("test %d"):format(j)', + path = path, + range = { 22, 16, 24, 20 }, + type = "test", + }, }, }, }, - }, -} + } +end diff --git a/test_files/parametric_test_output_fail_file.json b/test_files/parametric_test_output_fail_file.json new file mode 100644 index 0000000..e02049a --- /dev/null +++ b/test_files/parametric_test_output_fail_file.json @@ -0,0 +1,287 @@ +{ + "duration": 0.0038699998985976, + "errors": [], + "failures": [ + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1356566.747586, + "starttime": 1730295697.4426, + "trace": { + "currentline": 4, + "lastlinedefined": 12, + "linedefined": 2, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:4: in function <./test_files/parametric_tests_fail_spec.lua:2>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "name": "namespace 1 nested namespace 1 test 1", + "trace": { + "currentline": 5, + "lastlinedefined": 6, + "linedefined": 4, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:5: in function <./test_files/parametric_tests_fail_spec.lua:4>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1356566.747833, + "starttime": 1730295697.4428, + "trace": { + "currentline": 4, + "lastlinedefined": 12, + "linedefined": 2, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:4: in function <./test_files/parametric_tests_fail_spec.lua:2>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "name": "namespace 1 nested namespace 1 test 2", + "trace": { + "currentline": 5, + "lastlinedefined": 6, + "linedefined": 4, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:5: in function <./test_files/parametric_tests_fail_spec.lua:4>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 3", + "starttick": 1356566.748027, + "starttime": 1730295697.443, + "trace": { + "currentline": 9, + "lastlinedefined": 12, + "linedefined": 2, + "message": "test 3", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:9: in function <./test_files/parametric_tests_fail_spec.lua:2>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:10: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "name": "namespace 1 nested namespace 1 test 3", + "trace": { + "currentline": 10, + "lastlinedefined": 11, + "linedefined": 9, + "message": "./test_files/parametric_tests_fail_spec.lua:10: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:10: in function <./test_files/parametric_tests_fail_spec.lua:9>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "some test", + "starttick": 1356566.748777, + "starttime": 1730295697.4438, + "trace": { + "currentline": 18, + "lastlinedefined": 27, + "linedefined": 17, + "message": "some test", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:18: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 some test", + "trace": { + "currentline": 19, + "lastlinedefined": 20, + "linedefined": 18, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:19: in function <./test_files/parametric_tests_fail_spec.lua:18>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1356566.749134, + "starttime": 1730295697.4441, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 test 1", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1356566.749381, + "starttime": 1730295697.4444, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 test 2", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "some test", + "starttick": 1356566.749776, + "starttime": 1730295697.4448, + "trace": { + "currentline": 18, + "lastlinedefined": 27, + "linedefined": 17, + "message": "some test", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:18: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 some test", + "trace": { + "currentline": 19, + "lastlinedefined": 20, + "linedefined": 18, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:19: in function <./test_files/parametric_tests_fail_spec.lua:18>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1356566.749961, + "starttime": 1730295697.445, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 test 1", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1356566.75016, + "starttime": 1730295697.4452, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 test 2", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + } + ], + "pendings": [], + "successes": [] +} diff --git a/test_files/parametric_test_output_fail_namespace.json b/test_files/parametric_test_output_fail_namespace.json new file mode 100644 index 0000000..4c9482f --- /dev/null +++ b/test_files/parametric_test_output_fail_namespace.json @@ -0,0 +1,194 @@ +{ + "duration": 0.0026219999417663, + "errors": [], + "failures": [ + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "some test", + "starttick": 1354674.247178, + "starttime": 1730293804.9422, + "trace": { + "currentline": 18, + "lastlinedefined": 27, + "linedefined": 17, + "message": "some test", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:18: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 some test", + "trace": { + "currentline": 19, + "lastlinedefined": 20, + "linedefined": 18, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:19: in function <./test_files/parametric_tests_fail_spec.lua:18>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1354674.247373, + "starttime": 1730293804.9424, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 test 1", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1354674.247561, + "starttime": 1730293804.9426, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 1 test 2", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "some test", + "starttick": 1354674.247959, + "starttime": 1730293804.943, + "trace": { + "currentline": 18, + "lastlinedefined": 27, + "linedefined": 17, + "message": "some test", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:18: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 some test", + "trace": { + "currentline": 19, + "lastlinedefined": 20, + "linedefined": 18, + "message": "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:19: in function <./test_files/parametric_tests_fail_spec.lua:18>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1354674.248136, + "starttime": 1730293804.9431, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 test 1", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1354674.248312, + "starttime": 1730293804.9433, + "trace": { + "currentline": 23, + "lastlinedefined": 27, + "linedefined": 17, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:23: in function <./test_files/parametric_tests_fail_spec.lua:17>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "name": "namespace 2 nested namespace 2 - 2 test 2", + "trace": { + "currentline": 24, + "lastlinedefined": 25, + "linedefined": 23, + "message": "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:24: in function <./test_files/parametric_tests_fail_spec.lua:23>\n", + "what": "Lua" + } + } + ], + "pendings": [], + "successes": [] +} diff --git a/test_files/parametric_test_output_fail_test.json b/test_files/parametric_test_output_fail_test.json new file mode 100644 index 0000000..9b18b79 --- /dev/null +++ b/test_files/parametric_test_output_fail_test.json @@ -0,0 +1,70 @@ +{ + "duration": 0.0018740000668913, + "errors": [], + "failures": [ + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 1", + "starttick": 1288528.917024, + "starttime": 1730227660.4828, + "trace": { + "currentline": 4, + "lastlinedefined": 12, + "linedefined": 2, + "message": "test 1", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:4: in function <./test_files/parametric_tests_fail_spec.lua:2>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "name": "namespace 1 nested namespace 1 test 1", + "trace": { + "currentline": 5, + "lastlinedefined": 6, + "linedefined": 4, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:5: in function <./test_files/parametric_tests_fail_spec.lua:4>\n", + "what": "Lua" + } + }, + { + "element": { + "attributes": [], + "descriptor": "it", + "name": "test 2", + "starttick": 1288528.917272, + "starttime": 1730227660.483, + "trace": { + "currentline": 4, + "lastlinedefined": 12, + "linedefined": 2, + "message": "test 2", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:4: in function <./test_files/parametric_tests_fail_spec.lua:2>\n", + "what": "Lua" + } + }, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "name": "namespace 1 nested namespace 1 test 2", + "trace": { + "currentline": 5, + "lastlinedefined": 6, + "linedefined": 4, + "message": "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + "short_src": "./test_files/parametric_tests_fail_spec.lua", + "source": "@./test_files/parametric_tests_fail_spec.lua", + "traceback": "\nstack traceback:\n\t./test_files/parametric_tests_fail_spec.lua:5: in function <./test_files/parametric_tests_fail_spec.lua:4>\n", + "what": "Lua" + } + } + ], + "pendings": [], + "successes": [] +} diff --git a/test_files/parametric_tests_fail_spec.lua b/test_files/parametric_tests_fail_spec.lua new file mode 100644 index 0000000..4257454 --- /dev/null +++ b/test_files/parametric_tests_fail_spec.lua @@ -0,0 +1,29 @@ +describe("namespace 1", function() + describe("nested namespace 1", function() + for i = 1, 2 do + it(("test %d"):format(i), function() + assert.is_false(true) + end) + end + + it("test " .. "3", function() + assert.is_false(true) + end) + end) +end) + +describe("namespace 2", function() + for i = 1, 2 do + describe("nested namespace 2 - " .. tostring(i), function() + it("some test", function() + assert.is_true(false) + end) + + for j = 1, 2 do + it(("test %d"):format(j), function() + assert.is_true(false) + end) + end + end) + end +end) diff --git a/tests/adapter_results_spec.lua b/tests/adapter_results_spec.lua index d631186..e9ddc82 100644 --- a/tests/adapter_results_spec.lua +++ b/tests/adapter_results_spec.lua @@ -9,6 +9,7 @@ local stub = require("luassert.stub") local adapter = require("neotest-busted")() local config = require("neotest-busted.config") +-- TODO: Refactor describe("adapter.results", function() local test_path = "/Users/user/vim/project/tests/test_spec.lua" local parametric_test_path = "./test_files/parametric_tests_spec.lua" @@ -50,6 +51,24 @@ describe("adapter.results", function() ) end + ---@param test_path string + ---@param json_path string + ---@return neotest.Tree + local function discover_positions(test_path, json_path) + -- NOTE: neotest.lib.treesitter.parse_positions uses lib.file.read so + -- temporarily revert it + ---@diagnostic disable-next-line: undefined-field + lib.files.read:revert() + + local tree = adapter.discover_positions(test_path) + local parametric_test_json = table.concat(vim.fn.readfile(json_path), "\n") + + stub(lib.files, "read", parametric_test_json) + + ---@cast tree -nil + return tree + end + before_each(function() assert:set_parameter("TableFormatLevel", 10) @@ -163,20 +182,9 @@ describe("adapter.results", function() -- } -- ) - -- NOTE: neotest.lib.treesitter.parse_positions uses lib.file.read so temporarily revert it - ---@diagnostic disable-next-line: undefined-field - lib.files.read:revert() - local path = parametric_test_path - local tree = adapter.discover_positions(path) - ---@cast tree -nil - - local parametric_test_json = table.concat( - vim.fn.readfile("./test_files/parametric_test_output_success_test.json"), - "\n" - ) - - stub(lib.files, "read", parametric_test_json) + local tree = + discover_positions(path, "./test_files/parametric_test_output_success_test.json") -- Get the subtree rooted at the the first parametric test in the file local subtree = tree:children()[1]:children()[1]:children()[1] @@ -212,7 +220,7 @@ describe("adapter.results", function() }, }) - local expected_tree = require("./test_files/expected_tree_parametric_test") + local expected_tree = require("./test_files/expected_tree_parametric_test")(path) assert.are.same(tree:to_list(), expected_tree) @@ -243,21 +251,12 @@ describe("adapter.results", function() -- } -- ) - -- NOTE: neotest.lib.treesitter.parse_positions uses lib.file.read so temporarily revert it - ---@diagnostic disable-next-line: undefined-field - lib.files.read:revert() - local path = parametric_test_path - local tree = adapter.discover_positions(path) - ---@cast tree -nil - - local parametric_test_json = table.concat( - vim.fn.readfile("./test_files/parametric_test_output_success_namespace.json"), - "\n" + local tree = discover_positions( + path, + "./test_files/parametric_test_output_success_namespace.json" ) - stub(lib.files, "read", parametric_test_json) - -- Get the subtree rooted at the the first parametric namespace in the file local subtree = tree:children()[2]:children()[1] @@ -295,38 +294,38 @@ describe("adapter.results", function() output = strategy_result.output, }, [path .. "::namespace::2::nested::namespace::2::-::1::some::test"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 some test: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::1::test::1"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 test 1: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::1::test::2"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 test 2: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::some::test"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 some test: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::test::1"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 test 1: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::test::2"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 test 2: passed", status = "passed", }, }) - local expected_tree = require("test_files/expected_tree_parametric_namespace") + local expected_tree = require("./test_files/expected_tree_parametric_namespace")(path) assert.are.same(tree:to_list(), expected_tree) @@ -340,37 +339,9 @@ describe("adapter.results", function() function() config.configure({ parametric_test_discovery = true }) - -- Stub nio process functions since running `busted --list` appears to be broken - -- stub( - -- nio.process, - -- "run", - -- -- Fake process object - -- { - -- stderr = { - -- read = function() - -- return table.concat(stderr_output, "\r\n"), nil - -- end, - -- }, - -- result = function() - -- return 0 - -- end, - -- } - -- ) - - -- NOTE: neotest.lib.treesitter.parse_positions uses lib.file.read so temporarily revert it - ---@diagnostic disable-next-line: undefined-field - lib.files.read:revert() - local path = parametric_test_path - local tree = adapter.discover_positions(path) - ---@cast tree -nil - - local parametric_test_json = table.concat( - vim.fn.readfile("./test_files/parametric_test_output_success_file.json"), - "\n" - ) - - stub(lib.files, "read", parametric_test_json) + local tree = + discover_positions(path, "./test_files/parametric_test_output_success_file.json") local parametric_pos_id_key1 = path .. "::namespace::1::nested::namespace::1::test::1" local parametric_pos_id_key2 = path .. "::namespace::1::nested::namespace::1::test::2" @@ -404,9 +375,9 @@ describe("adapter.results", function() assert.are.same(neotest_results, { [path] = { - output = "test_console_output", - short = "parametric_tests_spec.lua: passed", status = "passed", + short = "parametric_tests_spec.lua: passed", + output = strategy_result.output, }, [path .. "::namespace::1::nested::namespace::1::test::1"] = { status = types.ResultStatus.passed, @@ -424,48 +395,420 @@ describe("adapter.results", function() output = strategy_result.output, }, [path .. "::namespace::2::nested::namespace::2::-::1::some::test"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 some test: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::1::test::1"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 test 1: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::1::test::2"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 1 test 2: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::some::test"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 some test: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::test::1"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 test 1: passed", status = "passed", }, [path .. "::namespace::2::nested::namespace::2::-::2::test::2"] = { - output = "test_console_output", + output = strategy_result.output, short = "namespace 2 nested namespace 2 - 2 test 2: passed", status = "passed", }, }) - local expected_tree = require("./test_files/expected_tree_parametric_file") + local expected_tree = require("./test_files/expected_tree_parametric_file")(path) + + assert.are.same(tree:to_list(), expected_tree) + + assert.stub(lib.files.read).was.called_with(spec.context.results_path) + assert.stub(logger.error).was_not_called() + end + ) + + async.it( + "creates neotest results for failed parametric tests and updates tree (test)", + function() + config.configure({ parametric_test_discovery = true }) + + -- Stub nio process functions since running `busted --list` appears to be broken + stub( + nio.process, + "run", + -- Fake process object + { + stderr = { + read = function() + return table.concat(stderr_output, "\r\n"), nil + end, + }, + result = function() + return 0 + end, + } + ) + + local path = "./test_files/parametric_tests_fail_spec.lua" + local tree = + discover_positions(path, "./test_files/parametric_test_output_fail_test.json") + + -- Get the subtree rooted at the the first parametric test in the file + local subtree = tree:children()[1]:children()[1]:children()[1] + assert.is_not_nil(subtree) + + local parametric_pos_id_key1 = path .. "::namespace::1::nested::namespace::1::test::1" + local parametric_pos_id_key2 = path .. "::namespace::1::nested::namespace::1::test::2" + + spec.context.position_id_mapping = { + [path .. "::namespace 1 nested namespace 1 test 1::4"] = parametric_pos_id_key1, + [path .. "::namespace 1 nested namespace 1 test 2::4"] = parametric_pos_id_key2, + } + + local neotest_results = adapter.results(spec, strategy_result, subtree) + + assert.are.same(neotest_results, { + [path .. '::"namespace 1"::"nested namespace 1"::("test %d"):format(i)'] = { + status = types.ResultStatus.failed, + short = '("test %d"):format(i): failed', + output = strategy_result.output, + }, + [parametric_pos_id_key1] = { + status = types.ResultStatus.failed, + short = "namespace 1 nested namespace 1 test 1: failed", + output = strategy_result.output, + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + line = 4, + }, + }, + }, + [parametric_pos_id_key2] = { + status = types.ResultStatus.failed, + short = "namespace 1 nested namespace 1 test 2: failed", + output = strategy_result.output, + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + line = 4, + }, + }, + }, + }) + + local expected_tree = require("./test_files/expected_tree_parametric_test")(path) assert.are.same(tree:to_list(), expected_tree) assert.stub(lib.files.read).was.called_with(spec.context.results_path) assert.stub(logger.error).was_not_called() + + nio.process.run:revert() end ) - ---- async.it("creates neotest results for failed parametric tests and updates tree", function() - ---- end) + async.it( + "creates neotest results for failed parametric tests and updates tree (namespace)", + function() + config.configure({ parametric_test_discovery = true }) + + -- Stub nio process functions since running `busted --list` appears to be broken + stub( + nio.process, + "run", + -- Fake process object + { + stderr = { + read = function() + return table.concat(stderr_output, "\r\n"), nil + end, + }, + result = function() + return 0 + end, + } + ) + + local path = "./test_files/parametric_tests_fail_spec.lua" + local tree = + discover_positions(path, "./test_files/parametric_test_output_fail_namespace.json") + + -- Get the subtree rooted at the the first parametric namespace in the file + local subtree = tree:children()[2]:children()[1] + assert.is_not_nil(subtree) + + local parametric_pos_id_key1 = path + .. "::namespace::2::nested::namespace::2::-::1::some::test" + local parametric_pos_id_key2 = path + .. "::namespace::2::nested::namespace::2::-::2::some::test" + local parametric_pos_id_key3 = path + .. "::namespace::2::nested::namespace::2::-::1::test::1" + local parametric_pos_id_key4 = path + .. "::namespace::2::nested::namespace::2::-::1::test::2" + local parametric_pos_id_key5 = path + .. "::namespace::2::nested::namespace::2::-::2::test::1" + local parametric_pos_id_key6 = path + .. "::namespace::2::nested::namespace::2::-::2::test::2" + + spec.context.position_id_mapping = { + [path .. "::namespace 2 nested namespace 2 - 1 some test::18"] = parametric_pos_id_key1, + [path .. "::namespace 2 nested namespace 2 - 2 some test::18"] = parametric_pos_id_key2, + [path .. "::namespace 2 nested namespace 2 - 1 test 1::23"] = parametric_pos_id_key3, + [path .. "::namespace 2 nested namespace 2 - 1 test 2::23"] = parametric_pos_id_key4, + [path .. "::namespace 2 nested namespace 2 - 2 test 1::23"] = parametric_pos_id_key5, + [path .. "::namespace 2 nested namespace 2 - 2 test 2::23"] = parametric_pos_id_key6, + } + + local neotest_results = adapter.results(spec, strategy_result, subtree) + + assert.are.same(neotest_results, { + [path .. '::"namespace 2"::"nested namespace 2 - " .. tostring(i)'] = { + status = types.ResultStatus.failed, + short = '"nested namespace 2 - " .. tostring(i): failed', + output = strategy_result.output, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::some::test"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 some test: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 18, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::test::1"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 test 1: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::test::2"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 test 2: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::some::test"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 some test: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 18, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::test::1"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 test 1: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::test::2"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 test 2: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + }) + + local expected_tree = require("./test_files/expected_tree_parametric_namespace")(path) + + assert.are.same(tree:to_list(), expected_tree) + + assert.stub(lib.files.read).was.called_with(spec.context.results_path) + assert.stub(logger.error).was_not_called() + + nio.process.run:revert() + end + ) + + async.it( + "creates neotest results for failed parametric tests and updates tree (file)", + function() + config.configure({ parametric_test_discovery = true }) + + local path = "./test_files/parametric_tests_fail_spec.lua" + local tree = + discover_positions(path, "./test_files/parametric_test_output_fail_file.json") + + local parametric_pos_id_key1 = path .. "::namespace::1::nested::namespace::1::test::1" + local parametric_pos_id_key2 = path .. "::namespace::1::nested::namespace::1::test::2" + local parametric_pos_id_key3 = path .. "::namespace::1::nested::namespace::1::test::3" + local parametric_pos_id_key4 = path + .. "::namespace::2::nested::namespace::2::-::1::some::test" + local parametric_pos_id_key5 = path + .. "::namespace::2::nested::namespace::2::-::2::some::test" + local parametric_pos_id_key6 = path + .. "::namespace::2::nested::namespace::2::-::1::test::1" + local parametric_pos_id_key7 = path + .. "::namespace::2::nested::namespace::2::-::1::test::2" + local parametric_pos_id_key8 = path + .. "::namespace::2::nested::namespace::2::-::2::test::1" + local parametric_pos_id_key9 = path + .. "::namespace::2::nested::namespace::2::-::2::test::2" + + spec.context.position_id_mapping = { + [path .. "::namespace 1 nested namespace 1 test 1::4"] = parametric_pos_id_key1, + [path .. "::namespace 1 nested namespace 1 test 2::4"] = parametric_pos_id_key2, + [path .. "::namespace 1 nested namespace 1 test 3::9"] = parametric_pos_id_key3, + [path .. "::namespace 2 nested namespace 2 - 1 some test::18"] = parametric_pos_id_key4, + [path .. "::namespace 2 nested namespace 2 - 2 some test::18"] = parametric_pos_id_key5, + [path .. "::namespace 2 nested namespace 2 - 1 test 1::23"] = parametric_pos_id_key6, + [path .. "::namespace 2 nested namespace 2 - 1 test 2::23"] = parametric_pos_id_key7, + [path .. "::namespace 2 nested namespace 2 - 2 test 1::23"] = parametric_pos_id_key8, + [path .. "::namespace 2 nested namespace 2 - 2 test 2::23"] = parametric_pos_id_key9, + } + + local neotest_results = adapter.results(spec, strategy_result, tree) + + assert.are.same(neotest_results, { + [path] = { + status = types.ResultStatus.failed, + short = "parametric_tests_fail_spec.lua: failed", + output = strategy_result.output, + }, + [path .. "::namespace::1::nested::namespace::1::test::1"] = { + status = types.ResultStatus.failed, + short = "namespace 1 nested namespace 1 test 1: failed", + output = strategy_result.output, + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + line = 4, + }, + }, + }, + [path .. "::namespace::1::nested::namespace::1::test::2"] = { + status = types.ResultStatus.failed, + short = "namespace 1 nested namespace 1 test 2: failed", + output = strategy_result.output, + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:5: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + line = 4, + }, + }, + }, + [path .. "::namespace::1::nested::namespace::1::test::3"] = { + status = types.ResultStatus.failed, + short = "namespace 1 nested namespace 1 test 3: failed", + output = strategy_result.output, + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:10: Expected objects to be the same.\nPassed in:\n(boolean) true\nExpected:\n(boolean) false", + line = 9, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::some::test"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 some test: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 18, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::test::1"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 test 1: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::1::test::2"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 1 test 2: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::some::test"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 some test: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:19: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 18, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::test::1"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 test 1: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + [path .. "::namespace::2::nested::namespace::2::-::2::test::2"] = { + output = strategy_result.output, + short = "namespace 2 nested namespace 2 - 2 test 2: failed", + status = "failed", + errors = { + { + message = "./test_files/parametric_tests_fail_spec.lua:24: Expected objects to be the same.\nPassed in:\n(boolean) false\nExpected:\n(boolean) true", + line = 23, + }, + }, + }, + }) + + local expected_tree = require("./test_files/expected_tree_parametric_file")(path) + + assert.are.same(tree:to_list(), expected_tree) + + assert.stub(lib.files.read).was.called_with(spec.context.results_path) + assert.stub(logger.error).was_not_called() + end + ) it("handles failure to read json test output", function() stub(vim, "schedule", function(func)