@@ -533,27 +533,39 @@ func Test_nl_err_to_out_pipe()
533533 call assert_equal (1 , found_send)
534534 call assert_equal (1 , found_recv)
535535 call assert_equal (1 , found_stop)
536+ " On MS-Windows need to sleep for a moment to be able to delete the file.
537+ sleep 10 m
536538 call delete (' Xlog' )
537539 endtry
538540endfunc
539541
542+ func Stop_g_job ()
543+ call job_stop (g: job )
544+ if has (' win32' )
545+ " On MS-Windows the server must close the file handle before we are able
546+ " to delete the file.
547+ call WaitFor (' job_status(g:job) == "dead"' )
548+ sleep 10 m
549+ endif
550+ endfunc
551+
540552func Test_nl_read_file ()
541553 if ! has (' job' )
542554 return
543555 endif
544556 call ch_log (' Test_nl_read_file()' )
545557 call writefile ([' echo something' , ' echoerr wrong' , ' double this' ], ' Xinput' )
546- let job = job_start (s: python . " test_channel_pipe.py" ,
558+ let g: job = job_start (s: python . " test_channel_pipe.py" ,
547559 \ {' in_io' : ' file' , ' in_name' : ' Xinput' })
548- call assert_equal (" run" , job_status (job))
560+ call assert_equal (" run" , job_status (g: job ))
549561 try
550- let handle = job_getchannel (job)
562+ let handle = job_getchannel (g: job )
551563 call assert_equal (" something" , ch_readraw (handle))
552564 call assert_equal (" wrong" , ch_readraw (handle, {' part' : ' err' }))
553565 call assert_equal (" this" , ch_readraw (handle))
554566 call assert_equal (" AND this" , ch_readraw (handle))
555567 finally
556- call job_stop (job )
568+ call Stop_g_job ( )
557569 call delete (' Xinput' )
558570 endtry
559571endfunc
@@ -563,18 +575,18 @@ func Test_nl_write_out_file()
563575 return
564576 endif
565577 call ch_log (' Test_nl_write_out_file()' )
566- let job = job_start (s: python . " test_channel_pipe.py" ,
578+ let g: job = job_start (s: python . " test_channel_pipe.py" ,
567579 \ {' out_io' : ' file' , ' out_name' : ' Xoutput' })
568- call assert_equal (" run" , job_status (job))
580+ call assert_equal (" run" , job_status (g: job ))
569581 try
570- let handle = job_getchannel (job)
582+ let handle = job_getchannel (g: job )
571583 call ch_sendraw (handle, " echo line one\n " )
572584 call ch_sendraw (handle, " echo line two\n " )
573585 call ch_sendraw (handle, " double this\n " )
574586 call WaitFor (' len(readfile("Xoutput")) > 2' )
575587 call assert_equal ([' line one' , ' line two' , ' this' , ' AND this' ], readfile (' Xoutput' ))
576588 finally
577- call job_stop (job )
589+ call Stop_g_job ( )
578590 call delete (' Xoutput' )
579591 endtry
580592endfunc
@@ -584,18 +596,18 @@ func Test_nl_write_err_file()
584596 return
585597 endif
586598 call ch_log (' Test_nl_write_err_file()' )
587- let job = job_start (s: python . " test_channel_pipe.py" ,
599+ let g: job = job_start (s: python . " test_channel_pipe.py" ,
588600 \ {' err_io' : ' file' , ' err_name' : ' Xoutput' })
589- call assert_equal (" run" , job_status (job))
601+ call assert_equal (" run" , job_status (g: job ))
590602 try
591- let handle = job_getchannel (job)
603+ let handle = job_getchannel (g: job )
592604 call ch_sendraw (handle, " echoerr line one\n " )
593605 call ch_sendraw (handle, " echoerr line two\n " )
594606 call ch_sendraw (handle, " doubleerr this\n " )
595607 call WaitFor (' len(readfile("Xoutput")) > 2' )
596608 call assert_equal ([' line one' , ' line two' , ' this' , ' AND this' ], readfile (' Xoutput' ))
597609 finally
598- call job_stop (job )
610+ call Stop_g_job ( )
599611 call delete (' Xoutput' )
600612 endtry
601613endfunc
@@ -605,19 +617,19 @@ func Test_nl_write_both_file()
605617 return
606618 endif
607619 call ch_log (' Test_nl_write_both_file()' )
608- let job = job_start (s: python . " test_channel_pipe.py" ,
620+ let g: job = job_start (s: python . " test_channel_pipe.py" ,
609621 \ {' out_io' : ' file' , ' out_name' : ' Xoutput' , ' err_io' : ' out' })
610- call assert_equal (" run" , job_status (job))
622+ call assert_equal (" run" , job_status (g: job ))
611623 try
612- let handle = job_getchannel (job)
624+ let handle = job_getchannel (g: job )
613625 call ch_sendraw (handle, " echoerr line one\n " )
614626 call ch_sendraw (handle, " echo line two\n " )
615627 call ch_sendraw (handle, " double this\n " )
616628 call ch_sendraw (handle, " doubleerr that\n " )
617629 call WaitFor (' len(readfile("Xoutput")) > 5' )
618630 call assert_equal ([' line one' , ' line two' , ' this' , ' AND this' , ' that' , ' AND that' ], readfile (' Xoutput' ))
619631 finally
620- call job_stop (job )
632+ call Stop_g_job ( )
621633 call delete (' Xoutput' )
622634 endtry
623635endfunc
0 commit comments