From a510e4a3c734af94144d109d7e327b2ab93e1a79 Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Tue, 18 Jun 2024 12:07:49 +0100 Subject: [PATCH] Don't check for inclusion when running tr/tn --- lua/clojure-test/api/init.lua | 23 +++++++++++++++++------ lua/clojure-test/api/tests.lua | 13 ++----------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lua/clojure-test/api/init.lua b/lua/clojure-test/api/init.lua index ed44516..3edfa7a 100644 --- a/lua/clojure-test/api/init.lua +++ b/lua/clojure-test/api/init.lua @@ -23,10 +23,18 @@ end function M.run_tests() nio.run(function() local current_test = location.get_test_at_cursor() - local tests = tests_api.select_tests(current_test) + + local tests + if current_test then + tests = { current_test } + else + tests = tests_api.select_tests() + end + if #tests == 0 then return end + M.state.previous = tests run_api.run_tests(tests) end) @@ -34,23 +42,26 @@ end function M.run_tests_in_ns() nio.run(function() + local namespaces local current_namespace = location.get_current_namespace() - - local namespaces = tests_api.select_namespaces(current_namespace) - if #namespaces == 0 then - return + if current_namespace then + namespaces = { current_namespace } + else + namespaces = tests_api.select_namespaces() end + local tests = {} for _, namespace in ipairs(namespaces) do - print(namespace) local ns_tests = tests_api.get_tests_in_ns(namespace) for _, test in ipairs(ns_tests) do table.insert(tests, test) end end + if #tests == 0 then return end + M.state.previous = tests run_api.run_tests(tests) end) diff --git a/lua/clojure-test/api/tests.lua b/lua/clojure-test/api/tests.lua index dfdbe33..2c14c50 100644 --- a/lua/clojure-test/api/tests.lua +++ b/lua/clojure-test/api/tests.lua @@ -1,5 +1,4 @@ local eval = require("clojure-test.api.eval") -local utils = require("clojure-test.utils") local nio = require("nio") local select = nio.wrap(function(choices, opts, cb) @@ -22,13 +21,9 @@ function M.get_all_tests() return tests end -function M.select_tests(current_test) +function M.select_tests() local tests = M.get_all_tests() - if current_test and utils.included_in_table(tests, current_test) then - return { current_test } - end - local test = select(tests, { prompt = "Select test" }) if not test then return {} @@ -36,16 +31,12 @@ function M.select_tests(current_test) return { test } end -function M.select_namespaces(current_namespace) +function M.select_namespaces() local namespaces = eval.eval(eval.API.get_test_namespaces) if not namespaces then return {} end - if current_namespace and utils.included_in_table(namespaces, current_namespace) then - return { current_namespace } - end - local namespace = select(namespaces, { prompt = "Select namespace" }) if not namespace then return {}