diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-04 11:54:11 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-04 11:54:11 +0100 | 
| commit | af828f22575c8591a176bd9d85ee07f87ba8b911 (patch) | |
| tree | c4692cf380b69e8d3b6065d1f8d2855b6e4a50dd /test/helpers.lua | |
| parent | c56411ed87fe560149b68e67f63916f829affd1b (diff) | |
| parent | 937b6fac8fecb701895b2c4151a864861aaf03f4 (diff) | |
| download | rneovim-af828f22575c8591a176bd9d85ee07f87ba8b911.tar.gz rneovim-af828f22575c8591a176bd9d85ee07f87ba8b911.tar.bz2 rneovim-af828f22575c8591a176bd9d85ee07f87ba8b911.zip  | |
Merge #5864 from ZyX-I/fix-5857
unittest: Allow multiple indirect includes
Diffstat (limited to 'test/helpers.lua')
| -rw-r--r-- | test/helpers.lua | 40 | 
1 files changed, 40 insertions, 0 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 4c50c7644f..0bc62da5d7 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -52,9 +52,49 @@ local function check_logs()    assert(0 == runtime_errors)  end +-- Tries to get platform name from $SYSTEM_NAME, uname; fallback is "Windows". +local uname = (function() +  local platform = nil +  return (function() +    if platform then +      return platform +    end + +    platform = os.getenv("SYSTEM_NAME") +    if platform then +      return platform +    end + +    local status, f = pcall(io.popen, "uname -s") +    if status then +      platform = f:read("*l") +    else +      platform = 'Windows' +    end +    return platform +  end) +end)() + +local function tmpname() +  local fname = os.tmpname() +  if uname() == 'Windows' and fname:sub(1, 2) == '\\s' then +    -- In Windows tmpname() returns a filename starting with +    -- special sequence \s, prepend $TEMP path +    local tmpdir = os.getenv('TEMP') +    return tmpdir..fname +  elseif fname:match('^/tmp') and uname() == 'Darwin' then +    -- In OS X /tmp links to /private/tmp +    return '/private'..fname +  else +    return fname +  end +end +  return {    eq = eq,    neq = neq,    ok = ok,    check_logs = check_logs, +  uname = uname, +  tmpname = tmpname,  }  | 
