~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to test/functional/helpers.lua

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
require('coxpcall')
2
 
local ffi = require('ffi')
3
2
local lfs = require('lfs')
4
3
local assert = require('luassert')
5
4
local Loop = require('nvim.loop')
133
132
  return request('vim_eval', expr)
134
133
end
135
134
 
 
135
local os_name = (function()
 
136
  local name = nil
 
137
  return (function()
 
138
    if not name then
 
139
      if nvim_eval('has("win32")') == 1 then
 
140
        name = 'windows'
 
141
      elseif nvim_eval('has("macunix")') == 1 then
 
142
        name = 'osx'
 
143
      else
 
144
        name = 'unix'
 
145
      end
 
146
    end
 
147
    return name
 
148
  end)
 
149
end)()
 
150
 
136
151
local function nvim_call(name, ...)
137
152
  return request('vim_call_function', name, {...})
138
153
end
247
262
 
248
263
local function source(code)
249
264
  local tmpname = os.tmpname()
250
 
  if ffi.os == 'OSX' and string.match(tmpname, '^/tmp') then
 
265
  if os_name() == 'osx' and string.match(tmpname, '^/tmp') then
251
266
   tmpname = '/private'..tmpname
252
267
  end
253
268
  write_file(tmpname, code)
305
320
  -- previously sent keys are processed(vim_eval is a deferred function, and
306
321
  -- only processed after all input)
307
322
  wait()
308
 
  return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n')
 
323
  return table.concat(curbuf('get_lines', 0, -1, true), '\n')
309
324
end
310
325
 
311
326
local function curwin(method, ...)
328
343
  return eq(dedent(contents), curbuf_contents())
329
344
end
330
345
 
331
 
local function os_is_windows()
332
 
  return nvim_eval('has("win32")') == 1
333
 
end
334
 
 
335
346
local function rmdir(path)
336
347
  if lfs.attributes(path, 'mode') ~= 'directory' then
337
348
    return nil
338
349
  end
339
350
  for file in lfs.dir(path) do
340
 
    if file == '.' or file == '..' then
341
 
      goto continue
342
 
    end
343
 
    local ret, err = os.remove(path..'/'..file)
344
 
    if not ret then
345
 
      error('os.remove: '..err)
346
 
      return nil
347
 
    end
348
 
    ::continue::
 
351
    if file ~= '.' and file ~= '..' then
 
352
      local ret, err = os.remove(path..'/'..file)
 
353
      if not ret then
 
354
        error('os.remove: '..err)
 
355
        return nil
 
356
      end
 
357
    end
349
358
  end
350
359
  local ret, err = os.remove(path)
351
360
  if not ret then
434
443
  wait = wait,
435
444
  set_session = set_session,
436
445
  write_file = write_file,
437
 
  os_is_windows = os_is_windows,
 
446
  os_name = os_name,
438
447
  rmdir = rmdir,
439
448
  mkdir = lfs.mkdir,
440
449
  exc_exec = exc_exec,