Include: include/setup.vader

Execute (NEOMAKE_FILE with tempfile):
  let maker = {
  \ 'exe': 'cat',
  \ 'args': '$NEOMAKE_FILE',
  \ 'append_file': 1,
  \ 'errorformat': '%m'}
  new
  normal! iline1
  let b:neomake_tempfile_enabled = 1

  call neomake#Make(1, [maker])
  AssertEqual $NEOMAKE_FILE, ''
  if has('patch-8.0.0902') && has('patch-8.0.1832')
    Assert !exists('$NEOMAKE_FILE')
  endif
  NeomakeTestsWaitForFinishedJobs

  AssertEqual map(getloclist(0), 'v:val.text'), ['line1', 'line1']
  bwipe!

Execute (NEOMAKE_FILE with tempfile gets restored):
  let maker = {
  \ 'exe': 'cat',
  \ 'args': '$NEOMAKE_FILE',
  \ 'append_file': 1,
  \ 'errorformat': '%m'}
  new
  normal! iline1
  let b:neomake_tempfile_enabled = 1

  Save $NEOMAKE_FILE
  let $NEOMAKE_FILE = 'orig'
  call neomake#Make(1, [maker])
  AssertEqual $NEOMAKE_FILE, 'orig'
  NeomakeTestsWaitForFinishedJobs

  AssertEqual map(getloclist(0), 'v:val.text'), ['line1', 'line1']
  bwipe!

Execute (NEOMAKE_FILE with tempfile gets only used with append_file):
  let maker = {
  \ 'exe': 'echo',
  \ 'args': 'NEOMAKE_FILE:$NEOMAKE_FILE',
  \ 'append_file': 0,
  \ 'errorformat': '%m'}
  new
  let b:neomake_tempfile_enabled = 1

  call neomake#Make(1, [maker])
  NeomakeTestsWaitForFinishedJobs

  AssertEqual map(getloclist(0), 'v:val.text'), ['NEOMAKE_FILE:']
  bwipe!

Execute (NEOMAKE_FILE with real file):
  let maker = {
  \ 'exe': 'echo',
  \ 'args': 'NEOMAKE_FILE:$NEOMAKE_FILE',
  \ 'append_file': 1,
  \ 'errorformat': '%m'}
  new
  edit tests/fixtures/a\ filename\ with\ spaces
  let fname = expand('%')
  let b:neomake_tempfile_enabled = 0

  call neomake#Make(1, [maker])
  NeomakeTestsWaitForFinishedJobs

  AssertEqual map(getloclist(0), 'v:val.text'), [
  \ 'NEOMAKE_FILE:'.fname.' '.fname]
  bwipe!
