Skip to content

Commit

Permalink
Don't check for inclusion when running tr/tn
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Jun 19, 2024
1 parent 237d588 commit a510e4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
23 changes: 17 additions & 6 deletions lua/clojure-test/api/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,45 @@ 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)
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)
Expand Down
13 changes: 2 additions & 11 deletions lua/clojure-test/api/tests.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -22,30 +21,22 @@ 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 {}
end
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 {}
Expand Down

0 comments on commit a510e4a

Please sign in to comment.