@@ -10,6 +10,27 @@ local has_all_executables = function(execs)
10
10
return true
11
11
end
12
12
13
+ local tables_equal = function (t1 , t2 )
14
+ if # t1 ~= # t2 then
15
+ return false
16
+ end
17
+ for i , t1_v in ipairs (t1 ) do
18
+ if t2 [i ] ~= t1_v then
19
+ return false
20
+ end
21
+ end
22
+ return true
23
+ end
24
+
25
+ local wait_for_result = function (job , result )
26
+ if type (result ) == " string" then
27
+ result = { result }
28
+ end
29
+ vim .wait (1000 , function ()
30
+ return tables_equal (job :result (), result )
31
+ end )
32
+ end
33
+
13
34
describe (" Job" , function ()
14
35
describe (" > cat manually >" , function ()
15
36
it (" should split simple stdin" , function ()
@@ -25,6 +46,8 @@ describe("Job", function()
25
46
job :start ()
26
47
job :send " hello\n "
27
48
job :send " world\n "
49
+
50
+ wait_for_result (job , { " hello" , " world" })
28
51
job :shutdown ()
29
52
30
53
assert .are .same (job :result (), { " hello" , " world" })
@@ -46,6 +69,8 @@ describe("Job", function()
46
69
job :send " \n "
47
70
job :send " world\n "
48
71
job :send " \n "
72
+
73
+ wait_for_result (job , { " hello" , " " , " world" , " " })
49
74
job :shutdown ()
50
75
51
76
assert .are .same (job :result (), { " hello" , " " , " world" , " " })
@@ -66,6 +91,8 @@ describe("Job", function()
66
91
job :start ()
67
92
job :send " hello\n wor"
68
93
job :send " ld\n "
94
+
95
+ wait_for_result (job , { " hello" , " world" })
69
96
job :shutdown ()
70
97
71
98
assert .are .same (job :result (), { " hello" , " world" })
@@ -655,6 +682,7 @@ describe("Job", function()
655
682
input_pipe :write " job.lua\n "
656
683
input_pipe :close ()
657
684
685
+ wait_for_result (fzf , " job.lua" )
658
686
fzf :shutdown ()
659
687
660
688
local results = fzf :result ()
@@ -692,6 +720,7 @@ describe("Job", function()
692
720
input_pipe :write " job.lua"
693
721
input_pipe :close ()
694
722
723
+ wait_for_result (fzf , " job.lua" )
695
724
fzf :shutdown ()
696
725
697
726
local results = fzf :result ()
0 commit comments