File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 23
23
function M .run_tests ()
24
24
nio .run (function ()
25
25
local current_test = location .get_test_at_cursor ()
26
- local tests = tests_api .select_tests (current_test )
26
+
27
+ local tests
28
+ if current_test then
29
+ tests = { current_test }
30
+ else
31
+ tests = tests_api .select_tests ()
32
+ end
33
+
27
34
if # tests == 0 then
28
35
return
29
36
end
37
+
30
38
M .state .previous = tests
31
39
run_api .run_tests (tests )
32
40
end )
33
41
end
34
42
35
43
function M .run_tests_in_ns ()
36
44
nio .run (function ()
45
+ local namespaces
37
46
local current_namespace = location .get_current_namespace ()
38
-
39
- local namespaces = tests_api . select_namespaces ( current_namespace )
40
- if # namespaces == 0 then
41
- return
47
+ if current_namespace then
48
+ namespaces = { current_namespace }
49
+ else
50
+ namespaces = tests_api . select_namespaces ()
42
51
end
52
+
43
53
local tests = {}
44
54
for _ , namespace in ipairs (namespaces ) do
45
- print (namespace )
46
55
local ns_tests = tests_api .get_tests_in_ns (namespace )
47
56
for _ , test in ipairs (ns_tests ) do
48
57
table.insert (tests , test )
49
58
end
50
59
end
60
+
51
61
if # tests == 0 then
52
62
return
53
63
end
64
+
54
65
M .state .previous = tests
55
66
run_api .run_tests (tests )
56
67
end )
Original file line number Diff line number Diff line change 1
1
local eval = require (" clojure-test.api.eval" )
2
- local utils = require (" clojure-test.utils" )
3
2
local nio = require (" nio" )
4
3
5
4
local select = nio .wrap (function (choices , opts , cb )
@@ -22,30 +21,22 @@ function M.get_all_tests()
22
21
return tests
23
22
end
24
23
25
- function M .select_tests (current_test )
24
+ function M .select_tests ()
26
25
local tests = M .get_all_tests ()
27
26
28
- if current_test and utils .included_in_table (tests , current_test ) then
29
- return { current_test }
30
- end
31
-
32
27
local test = select (tests , { prompt = " Select test" })
33
28
if not test then
34
29
return {}
35
30
end
36
31
return { test }
37
32
end
38
33
39
- function M .select_namespaces (current_namespace )
34
+ function M .select_namespaces ()
40
35
local namespaces = eval .eval (eval .API .get_test_namespaces )
41
36
if not namespaces then
42
37
return {}
43
38
end
44
39
45
- if current_namespace and utils .included_in_table (namespaces , current_namespace ) then
46
- return { current_namespace }
47
- end
48
-
49
40
local namespace = select (namespaces , { prompt = " Select namespace" })
50
41
if not namespace then
51
42
return {}
You can’t perform that action at this time.
0 commit comments