@@ -10,6 +10,27 @@ local has_all_executables = function(execs)
1010 return true
1111end
1212
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+
1334describe (" Job" , function ()
1435 describe (" > cat manually >" , function ()
1536 it (" should split simple stdin" , function ()
@@ -25,6 +46,8 @@ describe("Job", function()
2546 job :start ()
2647 job :send " hello\n "
2748 job :send " world\n "
49+
50+ wait_for_result (job , { " hello" , " world" })
2851 job :shutdown ()
2952
3053 assert .are .same (job :result (), { " hello" , " world" })
@@ -46,6 +69,8 @@ describe("Job", function()
4669 job :send " \n "
4770 job :send " world\n "
4871 job :send " \n "
72+
73+ wait_for_result (job , { " hello" , " " , " world" , " " })
4974 job :shutdown ()
5075
5176 assert .are .same (job :result (), { " hello" , " " , " world" , " " })
@@ -66,6 +91,8 @@ describe("Job", function()
6691 job :start ()
6792 job :send " hello\n wor"
6893 job :send " ld\n "
94+
95+ wait_for_result (job , { " hello" , " world" })
6996 job :shutdown ()
7097
7198 assert .are .same (job :result (), { " hello" , " world" })
@@ -655,6 +682,7 @@ describe("Job", function()
655682 input_pipe :write " job.lua\n "
656683 input_pipe :close ()
657684
685+ wait_for_result (fzf , " job.lua" )
658686 fzf :shutdown ()
659687
660688 local results = fzf :result ()
@@ -692,6 +720,7 @@ describe("Job", function()
692720 input_pipe :write " job.lua"
693721 input_pipe :close ()
694722
723+ wait_for_result (fzf , " job.lua" )
695724 fzf :shutdown ()
696725
697726 local results = fzf :result ()
0 commit comments