summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-04-03 22:24:30 +0100
committerw0rp <devw0rp@gmail.com>2017-04-03 22:24:30 +0100
commit85d86620f7459fd7caf14e4b8be2880006b36881 (patch)
tree569329ec9fad2677762d46d8e7f7918b5e1d190d /autoload
parent10d8b4bfd70562ebc48b7b1a72644dfe0292e9ab (diff)
downloadale-85d86620f7459fd7caf14e4b8be2880006b36881.zip
Cover basic GCC functionality with tests
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/engine.vim50
1 files changed, 39 insertions, 11 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 3eaf6e49..b5ea156f 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -95,6 +95,12 @@ function! s:KillHandler(timer) abort
endfunction
function! ale#engine#ClearJob(job) abort
+ if get(g:, 'ale_run_synchronously') == 1
+ call remove(s:job_info_map, a:job)
+
+ return
+ endif
+
let l:job_id = s:GetJobID(a:job)
if has('nvim')
@@ -515,7 +521,26 @@ function! s:RunJob(options) abort
let l:read_buffer = 0
endif
- if has('nvim')
+ if !has('nvim')
+ " The command will be executed in a subshell. This fixes a number of
+ " issues, including reading the PATH variables correctly, %PATHEXT%
+ " expansion on Windows, etc.
+ "
+ " NeoVim handles this issue automatically if the command is a String.
+ let l:command = has('win32')
+ \ ? 'cmd /c ' . l:command
+ \ : split(&shell) + split(&shellcmdflag) + [l:command]
+ endif
+
+ if get(g:, 'ale_run_synchronously') == 1
+ " Find a unique Job value to use, which will be the same as the ID for
+ " running commands synchronously. This is only for test code.
+ let l:job = len(s:job_info_map) + 1
+
+ while has_key(s:job_info_map, l:job)
+ let l:job += 1
+ endwhile
+ elseif has('nvim')
if l:output_stream ==# 'stderr'
" Read from stderr instead of stdout.
let l:job = jobstart(l:command, {
@@ -559,15 +584,6 @@ function! s:RunJob(options) abort
let l:job_options.out_cb = function('s:GatherOutputVim')
endif
- " The command will be executed in a subshell. This fixes a number of
- " issues, including reading the PATH variables correctly, %PATHEXT%
- " expansion on Windows, etc.
- "
- " NeoVim handles this issue automatically if the command is a String.
- let l:command = has('win32')
- \ ? 'cmd /c ' . l:command
- \ : split(&shell) + split(&shellcmdflag) + [l:command]
-
" Vim 8 will read the stdin from the file's buffer.
let l:job = job_start(l:command, l:job_options)
endif
@@ -576,7 +592,9 @@ function! s:RunJob(options) abort
let l:job_id = 0
" Only proceed if the job is being run.
- if has('nvim') || (l:job !=# 'no process' && job_status(l:job) ==# 'run')
+ if has('nvim')
+ \ || get(g:, 'ale_run_synchronously') == 1
+ \ || (l:job !=# 'no process' && job_status(l:job) ==# 'run')
" Add the job to the list of jobs, so we can track them.
call add(g:ale_buffer_info[l:buffer].job_list, l:job)
@@ -596,6 +614,16 @@ function! s:RunJob(options) abort
else
let g:ale_buffer_info[l:buffer].history = []
endif
+
+ if get(g:, 'ale_run_synchronously') == 1
+ " Run a command synchronously if this test option is set.
+ let s:job_info_map[l:job_id].output = systemlist(
+ \ type(l:command) == type([])
+ \ ? join(l:command[0:1]) . ' ' . shellescape(l:command[2])
+ \ : l:command
+ \)
+ call s:HandleExit(l:job)
+ endif
endfunction
" Determine which commands to run for a link in a command chain, or