diff options
author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2022-12-02 05:36:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 12:36:31 +0800 |
commit | dcc686a208677a173430ace5e8a1ac73da9651d0 (patch) | |
tree | 0a9badcf875769e1e38a3c78b5eb8d1c4708256b /test/helpers.lua | |
parent | facfc88b4ca004cf1db9621ef334c0ccf0ba4965 (diff) | |
download | rneovim-dcc686a208677a173430ace5e8a1ac73da9651d0.tar.gz rneovim-dcc686a208677a173430ace5e8a1ac73da9651d0.tar.bz2 rneovim-dcc686a208677a173430ace5e8a1ac73da9651d0.zip |
test: use luv.os_uname for fast platform detection (#21157)
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index eef47563a0..3fe4322501 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -269,29 +269,10 @@ function module.check_logs() table.concat(runtime_errors, ', '))) end --- Gets (lowercase) OS name from CMake, uname, or manually check if on Windows -do - local platform = nil - function module.uname() - if platform then - return platform - end - - if os.getenv("SYSTEM_NAME") then -- From CMAKE_HOST_SYSTEM_NAME. - platform = string.lower(os.getenv("SYSTEM_NAME")) - return platform - end - - local status, f = pcall(module.popen_r, 'uname', '-s') - if status then - platform = string.lower(f:read("*l")) - f:close() - elseif package.config:sub(1,1) == '\\' then - platform = 'windows' - else - error('unknown platform') - end - return platform +function module.sysname() + local platform = luv.os_uname() + if platform and platform.sysname then + return platform.sysname:lower() end end @@ -303,11 +284,11 @@ function module.is_os(s) or s == 'bsd') then error('unknown platform: '..tostring(s)) end - return ((s == 'win' and module.uname() == 'windows') - or (s == 'mac' and module.uname() == 'darwin') - or (s == 'freebsd' and module.uname() == 'freebsd') - or (s == 'openbsd' and module.uname() == 'openbsd') - or (s == 'bsd' and string.find(module.uname(), 'bsd'))) + return ((s == 'win' and module.sysname():find('windows')) + or (s == 'mac' and module.sysname() == 'darwin') + or (s == 'freebsd' and module.sysname() == 'freebsd') + or (s == 'openbsd' and module.sysname() == 'openbsd') + or (s == 'bsd' and module.sysname():find('bsd'))) end local function tmpdir_get() |