Skip to content

Commit 8ebc53c

Browse files
committed
System.Process.Vimproc: fix timeout unit
1 parent 1b9fab5 commit 8ebc53c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

autoload/vital/__vital__/System/Process/Vimproc.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ function! s:execute(args, options) abort
5151
" background process via Builtin always return exit_code:0 so mimic
5252
let status = 0
5353
else
54+
" System.Process.execute() {options} timeout unit as second.
55+
" convert to
56+
" vimproc#system {timeout} unit as millisecond.
5457
let output = vimproc#system(
5558
\ cmdline,
5659
\ s:Prelude.is_string(a:options.input) ? a:options.input : '',
57-
\ a:options.timeout,
60+
\ a:options.timeout * 1000,
5861
\)
5962
let status = vimproc#get_last_status()
6063
endif

test/System/Process/Vimproc.vimspec

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ Describe System.Process.Vimproc
2929
" Not sure but 'sleep' doesn't properly works in AppVeyor?
3030
" The code below worked on Windows 10 + PowerShell
3131
It DOES NOT throws an exception when {options.timeout} is specified
32-
let options.timeout = 100
33-
let args = s:cmd + ['sleep', '10']
32+
" timeout 1 second = 1000 millisoconds
33+
let options.timeout = 1
34+
" sleep command 100 seconds wait
35+
let args = s:cmd + ['sleep', '100']
3436
let result = Process.execute(args, options)
3537
" While the execution time reachs the timeout, the success is 0.
3638
Assert Equals(result.success, 0)
37-
Assert Equals(result.status, 15)
39+
Assert Equals(result.status, 15)
3840
End
3941
endif
4042

@@ -157,8 +159,10 @@ Describe System.Process.Vimproc
157159
Context [Unix]
158160
Describe .execute({args}[, {options}])
159161
It DOES NOT throws an exception when {options.timeout} is specified
160-
let options.timeout = 100
161-
let args = ['sleep', '10']
162+
" timeout 1 second = 1000 millisoconds
163+
let options.timeout = 1
164+
" sleep command 100 seconds wait
165+
let args = ['sleep', '100']
162166
let result = Process.execute(args, options)
163167
" While the execution time reachs the timeout, the success is 0.
164168
Assert Equals(result.success, 0)

0 commit comments

Comments
 (0)