Skip to content

Commit

Permalink
Improve "Starting" log message: make it copy'n'pastable (neomake#1871)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored Feb 24, 2018
1 parent 653bb1b commit a59a144
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
10 changes: 7 additions & 3 deletions autoload/neomake.vim
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,15 @@ function! s:MakeJob(make_id, options) abort
endif

call neomake#utils#hook('NeomakeJobInit', {'jobinfo': jobinfo})
if s:async
call neomake#utils#LoudMessage(printf('Starting async job: %s.', string(jobinfo.argv)), jobinfo)

let start_msg = s:async ? 'Starting async job' : 'Starting'
if type(jobinfo.argv) == type('')
let start_msg .= ' [string]: '.jobinfo.argv
else
call neomake#utils#LoudMessage(printf('Starting: %s.', jobinfo.argv), jobinfo)
let start_msg .= ': '.join(map(copy(jobinfo.argv), 'neomake#utils#shellescape(v:val)'))
endif
call neomake#utils#LoudMessage(start_msg.'.', jobinfo)

if empty(cd_back_cmd)
call neomake#utils#DebugMessage('cwd: '.cwd.'.', jobinfo)
else
Expand Down
4 changes: 2 additions & 2 deletions tests/hooks.vader
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Execute (NeomakeJobInit can make processes nicer):
call neomake#Make(0, [maker])
NeomakeTestsWaitForFinishedJobs
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['nice', '-n18', '".&shell."', '-c', 'cat /proc/$$/stat | cut -f19 -d\\ '].", 2
AssertNeomakeMessage printf("Starting async job: nice -n18 %s -c 'cat /proc/$$/stat | cut -f19 -d\\ '.", &shell), 2
else
AssertNeomakeMessage "Starting: nice -n 18 ".&shell." -c 'cat /proc/$$/stat | cut -f19 -d\\ '.", 2
AssertNeomakeMessage printf("Starting [string]: nice -n 18 %s -c 'cat /proc/$$/stat | cut -f19 -d\\ '.", &shell)
endif

let niceness = getqflist()[0].text
Expand Down
12 changes: 6 additions & 6 deletions tests/integration.vader
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ Execute (Neomake picks up custom maker correctly):

Neomake lint
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['echo', '".fname."', '--foo', 'bar']."
AssertNeomakeMessage printf("Starting async job: echo %s --foo bar.", fname)
NeomakeTestsWaitForFinishedJobs
else
AssertNeomakeMessage printf('Starting: echo %s --foo bar.', fname)
AssertNeomakeMessage printf('Starting [string]: echo %s --foo bar.', fname)
endif
bwipe

Expand Down Expand Up @@ -604,9 +604,9 @@ Execute (Neomake#Make: error with failing job via jobstart/argv):
NeomakeTestsWaitForFinishedJobs

if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['doesnotexist']."
AssertNeomakeMessage "Starting async job: doesnotexist."
else
AssertNeomakeMessage "Starting: doesnotexist."
AssertNeomakeMessage "Starting [string]: doesnotexist."
endif

if has('nvim-0.1.8')
Expand Down Expand Up @@ -643,9 +643,9 @@ Execute (Neomake#Make: error with failing job via jobstart/argv + true):
NeomakeTestsWaitForFinishedJobs

if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['doesnotexist']."
AssertNeomakeMessage "Starting async job: doesnotexist."
else
AssertNeomakeMessage "Starting: doesnotexist."
AssertNeomakeMessage "Starting [string]: doesnotexist."
endif

if has('nvim-0.1.8')
Expand Down
2 changes: 1 addition & 1 deletion tests/processing.vader
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ Execute (Already running job gets restarted in case of exception):
AssertNeomakeMessage printf('Cancelling already running job (%d.%d) for the same maker.',
\ make_id, jobinfo.id), 2, {'make_id': make_id+1}
AssertNeomakeMessage 'Job exited already.', 3, jobinfo
AssertNeomakeMessage "Starting async job: ['printf', 'foo']."
AssertNeomakeMessage "Starting async job: printf foo."

" Needs careful cleanup after exception.
NeomakeTestsWaitForMessage 'Cleaning jobinfo.'
Expand Down
4 changes: 2 additions & 2 deletions tests/serialize.vader
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Execute (Neomake#Make cancels previous jobs):
AssertEqual neomake#GetStatus().last_make_id, make_id + 1, 'two make instance'

" Restarted job should use new make_id.
AssertNeomakeMessage "Starting async job: ['".&shell."', '-c', 'echo error; false'].",
AssertNeomakeMessage printf("Starting async job: %s -c 'echo error; false'.", &shell),
\ 2, {'id': second_jobs[1], 'make_id': make_id+1, 'bufnr': bufnr}
endif

Expand Down Expand Up @@ -211,7 +211,7 @@ Execute (Neomake#Make cancels previous jobs (serialized)):
AssertEqual neomake#GetStatus().last_make_id, make_id + 1, 'two make instance'

" Restarted job should use new make_id.
AssertNeomakeMessage "Starting async job: ['".&shell."', '-c', 'echo error; false'].",
AssertNeomakeMessage printf("Starting async job: %s -c 'echo error; false'.", &shell),
\ 2, {'id': second_jobs[0].id, 'make_id': make_id+1, 'bufnr': bufnr}
endif

Expand Down
24 changes: 12 additions & 12 deletions tests/stdin.vader
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Execute (stdin maker):
call neomake#Make(1, [maker])
AssertNeomakeMessage "Using buffer's directory for cwd with uses_stdin.", 3
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['cat', '-'].", 2
AssertNeomakeMessage "Starting async job: cat -.", 2
NeomakeTestsWaitForFinishedJobs
endif
AssertNeomakeMessage 'cwd: .', 3
Expand All @@ -28,10 +28,10 @@ Execute (stdin maker (args as string)):
call neomake#Make(1, [maker])
if neomake#has_async_support()
if has('nvim')
AssertNeomakeMessage "Starting async job: 'cat \\-'.", 2
AssertNeomakeMessage "Starting async job [string]: cat \\-.", 2
else
let shell_argv = "'".join(split(&shell) + split(&shellcmdflag), "', '")."'"
AssertNeomakeMessage "Starting async job: [".shell_argv.", 'cat \\-'].", 2
let shell_argv = join(split(&shell) + split(&shellcmdflag))
AssertNeomakeMessage 'Starting async job: '.shell_argv." 'cat \\-'.", 2
endif
NeomakeTestsWaitForFinishedJobs
endif
Expand All @@ -49,10 +49,10 @@ Execute (stdin maker (disabled tempfiles)):
call neomake#Make(1, [maker])
AssertNeomakeMessage 'Using stdin for unnamed buffer.'
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['cat', '-'].", 2
AssertNeomakeMessage "Starting async job: cat -.", 2
NeomakeTestsWaitForFinishedJobs
else
AssertNeomakeMessage 'Starting: cat -.', 2
AssertNeomakeMessage 'Starting [string]: cat -.', 2
endif
AssertNeomakeMessage '\mstdout: unnamed_maker: [''line1.*'
AssertEqual map(getloclist(0), 'v:val.text'), ['line1', 'line2']
Expand All @@ -68,10 +68,10 @@ Execute (stdin maker (project mode: append_file)):
normal! oline2
call neomake#Make(0, [maker])
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['cat', '-'].", 2
AssertNeomakeMessage "Starting async job: cat -.", 2
NeomakeTestsWaitForFinishedJobs
else
AssertNeomakeMessage 'Starting: cat -.', 2
AssertNeomakeMessage 'Starting [string]: cat -.', 2
endif
AssertNeomakeMessage '\mstdout: unnamed_maker: [''line1.*'
AssertEqual map(getqflist(), 'v:val.text'), ['line1', 'line2']
Expand All @@ -89,14 +89,14 @@ Execute (stdin maker (project mode: uses_filename)):
AssertNeomakeMessage 'Using stdin for unnamed buffer.'
if neomake#has_async_support()
if has('nvim')
AssertNeomakeMessage "Starting async job: 'cat $NEOMAKE_FILE'.", 2
AssertNeomakeMessage "Starting async job [string]: cat $NEOMAKE_FILE.", 2
else
let shell_argv = "'".join(split(&shell) + split(&shellcmdflag), "', '")."'"
AssertNeomakeMessage "Starting async job: [".shell_argv.", 'cat $NEOMAKE_FILE'].", 2
let shell_argv = join(split(&shell) + split(&shellcmdflag))
AssertNeomakeMessage 'Starting async job: '.shell_argv." 'cat $NEOMAKE_FILE'.", 2
endif
NeomakeTestsWaitForFinishedJobs
else
AssertNeomakeMessage 'Starting: cat $NEOMAKE_FILE.', 2
AssertNeomakeMessage 'Starting [string]: cat $NEOMAKE_FILE.', 2
endif
AssertNeomakeMessage '\mstdout: unnamed_maker: [''line1.*'
AssertEqual map(getqflist(), 'v:val.text'), ['line1', 'line2']
Expand Down
6 changes: 3 additions & 3 deletions tests/tempfiles.vader
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Execute (Maker can specify temporary file to use via fn):
Execute (Previously existing temporary dir is kept):
let tempname = tempname()
call mkdir(tempname, '', 0700)
let tempfile_name = tempname.'/injected/with/subdir'
let tempfile_name = tempname.'/injected/with/subdir and spaces'
let maker = {
\ 'exe': 'true',
\ 'tempfile_name': tempfile_name,
Expand All @@ -158,9 +158,9 @@ Execute (Previously existing temporary dir is kept):
AssertNeomakeMessage 'Using tempfile for unnamed buffer: "'.tempfile_name.'".', 3
NeomakeTestsWaitForFinishedJobs
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['true', '".tempfile_name."']."
AssertNeomakeMessage printf("Starting async job: true '%s'.", tempfile_name)
else
AssertNeomakeMessage printf('Starting: true %s.', fnameescape(tempfile_name))
AssertNeomakeMessage printf("Starting [string]: true '%s'.", tempfile_name)
endif
AssertNeomakeMessage 'Removing temporary file: "'.tempfile_name.'".'
Assert !filereadable(tempfile_name), 'tempfile has been removed'
Expand Down
4 changes: 2 additions & 2 deletions tests/verbosity.vader
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ Execute (neomake#Make uses &verbose):
let make_id = jobinfo.make_id
NeomakeTestsWaitForFinishedJobs
if neomake#has_async_support()
AssertNeomakeMessage "Starting async job: ['echo', '1'].", 2, {'id': jobinfo.id, 'make_id': make_id, 'bufnr': bufnr}
AssertNeomakeMessage "Starting async job: echo 1.", 2, {'id': jobinfo.id, 'make_id': make_id, 'bufnr': bufnr}
else
AssertNeomakeMessage "Starting: echo 1.", 2, {'id': jobinfo.id, 'make_id': make_id, 'bufnr': bufnr}
AssertNeomakeMessage "Starting [string]: echo 1.", 2, {'id': jobinfo.id, 'make_id': make_id, 'bufnr': bufnr}
endif

let g:neomake_verbose = 3
Expand Down

0 comments on commit a59a144

Please sign in to comment.