diff options
author | ZyX <kp-pav@yandex.ru> | 2017-12-03 16:49:30 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-12-03 16:49:30 +0300 |
commit | c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57 (patch) | |
tree | b7e59c416d1435725c65f8952b6e55c70544d97e /test/unit/os | |
parent | 62108c3b0be46936c83f6d4c98b44ceb5e6f77fd (diff) | |
parent | 27a577586eace687c47e7398845178208cae524a (diff) | |
download | rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.tar.gz rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.tar.bz2 rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.zip |
Merge branch 'master' into s-dash-stdin
Diffstat (limited to 'test/unit/os')
-rw-r--r-- | test/unit/os/env_spec.lua | 63 | ||||
-rw-r--r-- | test/unit/os/fileio_spec.lua | 125 | ||||
-rw-r--r-- | test/unit/os/fs_spec.lua | 57 | ||||
-rw-r--r-- | test/unit/os/shell_spec.lua | 22 |
4 files changed, 181 insertions, 86 deletions
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua index 1ffed784ff..c54d5a9b77 100644 --- a/test/unit/os/env_spec.lua +++ b/test/unit/os/env_spec.lua @@ -13,7 +13,7 @@ require('lfs') local cimp = cimport('./src/nvim/os/os.h') -describe('env function', function() +describe('env.c', function() local function os_setenv(name, value, override) return cimp.os_setenv(to_cstr(name), to_cstr(value), override) end @@ -35,17 +35,17 @@ describe('env function', function() local OK = 0 itp('sets an env variable and returns OK', function() - local name = 'NEOVIM_UNIT_TEST_SETENV_1N' - local value = 'NEOVIM_UNIT_TEST_SETENV_1V' + local name = 'NVIM_UNIT_TEST_SETENV_1N' + local value = 'NVIM_UNIT_TEST_SETENV_1V' eq(nil, os.getenv(name)) eq(OK, (os_setenv(name, value, 1))) eq(value, os.getenv(name)) end) itp("dosn't overwrite an env variable if overwrite is 0", function() - local name = 'NEOVIM_UNIT_TEST_SETENV_2N' - local value = 'NEOVIM_UNIT_TEST_SETENV_2V' - local value_updated = 'NEOVIM_UNIT_TEST_SETENV_2V_UPDATED' + local name = 'NVIM_UNIT_TEST_SETENV_2N' + local value = 'NVIM_UNIT_TEST_SETENV_2V' + local value_updated = 'NVIM_UNIT_TEST_SETENV_2V_UPDATED' eq(OK, (os_setenv(name, value, 0))) eq(value, os.getenv(name)) eq(OK, (os_setenv(name, value_updated, 0))) @@ -67,18 +67,43 @@ describe('env function', function() end) end) + describe('os_shell_is_cmdexe', function() + itp('returns true for expected names', function() + eq(true, cimp.os_shell_is_cmdexe(to_cstr('cmd.exe'))) + eq(true, cimp.os_shell_is_cmdexe(to_cstr('cmd'))) + eq(true, cimp.os_shell_is_cmdexe(to_cstr('CMD.EXE'))) + eq(true, cimp.os_shell_is_cmdexe(to_cstr('CMD'))) + + os_setenv('COMSPEC', '/foo/bar/cmd.exe', 0) + eq(true, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC'))) + os_setenv('COMSPEC', [[C:\system32\cmd.exe]], 0) + eq(true, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC'))) + end) + itp('returns false for unexpected names', function() + eq(false, cimp.os_shell_is_cmdexe(to_cstr(''))) + eq(false, cimp.os_shell_is_cmdexe(to_cstr('powershell'))) + eq(false, cimp.os_shell_is_cmdexe(to_cstr(' cmd.exe '))) + eq(false, cimp.os_shell_is_cmdexe(to_cstr('cm'))) + eq(false, cimp.os_shell_is_cmdexe(to_cstr('md'))) + eq(false, cimp.os_shell_is_cmdexe(to_cstr('cmd.ex'))) + + os_setenv('COMSPEC', '/foo/bar/cmd', 0) + eq(false, cimp.os_shell_is_cmdexe(to_cstr('$COMSPEC'))) + end) + end) + describe('os_getenv', function() itp('reads an env variable', function() - local name = 'NEOVIM_UNIT_TEST_GETENV_1N' - local value = 'NEOVIM_UNIT_TEST_GETENV_1V' + local name = 'NVIM_UNIT_TEST_GETENV_1N' + local value = 'NVIM_UNIT_TEST_GETENV_1V' eq(NULL, os_getenv(name)) - -- need to use os_setenv, because lua dosn't have a setenv function + -- Use os_setenv because Lua dosen't have setenv. os_setenv(name, value, 1) eq(value, os_getenv(name)) end) itp('returns NULL if the env variable is not found', function() - local name = 'NEOVIM_UNIT_TEST_GETENV_NOTFOUND' + local name = 'NVIM_UNIT_TEST_GETENV_NOTFOUND' return eq(NULL, os_getenv(name)) end) end) @@ -97,8 +122,8 @@ describe('env function', function() describe('os_getenvname_at_index', function() itp('returns names of environment variables', function() - local test_name = 'NEOVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1N' - local test_value = 'NEOVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1V' + local test_name = 'NVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1N' + local test_value = 'NVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1V' os_setenv(test_name, test_value, 1) local i = 0 local names = { } @@ -160,16 +185,16 @@ describe('env function', function() describe('expand_env_esc', function() itp('expands environment variables', function() - local name = 'NEOVIM_UNIT_TEST_EXPAND_ENV_ESCN' - local value = 'NEOVIM_UNIT_TEST_EXPAND_ENV_ESCV' + local name = 'NVIM_UNIT_TEST_EXPAND_ENV_ESCN' + local value = 'NVIM_UNIT_TEST_EXPAND_ENV_ESCV' os_setenv(name, value, 1) -- TODO(bobtwinkles) This only tests Unix expansions. There should be a -- test for Windows as well - local input1 = to_cstr('$NEOVIM_UNIT_TEST_EXPAND_ENV_ESCN/test') - local input2 = to_cstr('${NEOVIM_UNIT_TEST_EXPAND_ENV_ESCN}/test') + local input1 = to_cstr('$NVIM_UNIT_TEST_EXPAND_ENV_ESCN/test') + local input2 = to_cstr('${NVIM_UNIT_TEST_EXPAND_ENV_ESCN}/test') local output_buff1 = cstr(255, '') local output_buff2 = cstr(255, '') - local output_expected = 'NEOVIM_UNIT_TEST_EXPAND_ENV_ESCV/test' + local output_expected = 'NVIM_UNIT_TEST_EXPAND_ENV_ESCV/test' cimp.expand_env_esc(input1, output_buff1, 255, false, true, NULL) cimp.expand_env_esc(input2, output_buff2, 255, false, true, NULL) eq(output_expected, ffi.string(output_buff1)) @@ -204,10 +229,10 @@ describe('env function', function() local src = to_cstr("~"..curuser.."/Vcs/django-rest-framework/rest_framework/renderers.py") local dst = cstr(256, "~"..curuser) - cimp.expand_env_esc(src, dst, 1024, false, false, NULL) + cimp.expand_env_esc(src, dst, 256, false, false, NULL) local len = string.len(ffi.string(dst)) assert.True(len > 56) - assert.True(len < 99) + assert.True(len < 256) end) itp('respects `dstlen` without expansion', function() diff --git a/test/unit/os/fileio_spec.lua b/test/unit/os/fileio_spec.lua index eaccdcb2a2..4d58a8934e 100644 --- a/test/unit/os/fileio_spec.lua +++ b/test/unit/os/fileio_spec.lua @@ -60,15 +60,15 @@ local function file_open_new(fname, flags, mode) return ret1[0], ret2 end -local function file_open_fd(fd, flags, mode) +local function file_open_fd(fd, flags) local ret2 = ffi.new('FileDescriptor') - local ret1 = m.file_open_fd(ret2, fd, flags, mode) + local ret1 = m.file_open_fd(ret2, fd, flags) return ret1, ret2 end -local function file_open_fd_new(fd, flags, mode) +local function file_open_fd_new(fd, flags) local ret1 = ffi.new('int[?]', 1, {0}) - local ret2 = ffi.gc(m.file_open_fd_new(ret1, fd, flags, mode), nil) + local ret2 = ffi.gc(m.file_open_fd_new(ret1, fd, flags), nil) return ret1[0], ret2 end @@ -76,6 +76,10 @@ local function file_write(fp, buf) return m.file_write(fp, buf, #buf) end +local function msgpack_file_write(fp, buf) + return m.msgpack_file_write(fp, buf, #buf) +end + local function file_read(fp, size) local buf = nil if size == nil then @@ -94,6 +98,10 @@ local function file_read(fp, size) return ret1, ret2 end +local function file_flush(fp) + return m.file_flush(fp) +end + local function file_fsync(fp) return m.file_fsync(fp) end @@ -105,18 +113,18 @@ end describe('file_open_fd', function() itp('can use file descriptor returned by os_open for reading', function() local fd = m.os_open(file1, m.kO_RDONLY, 0) - local err, fp = file_open_fd(fd, m.kFileReadOnly, 0) + local err, fp = file_open_fd(fd, m.kFileReadOnly) eq(0, err) eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can use file descriptor returned by os_open for writing', function() eq(nil, lfs.attributes(filec)) local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384) - local err, fp = file_open_fd(fd, m.kFileWriteOnly, 0) + local err, fp = file_open_fd(fd, m.kFileWriteOnly) eq(0, err) eq(4, file_write(fp, 'test')) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) eq(4, lfs.attributes(filec).size) eq('test', io.open(filec):read('*a')) end) @@ -125,18 +133,18 @@ end) describe('file_open_fd_new', function() itp('can use file descriptor returned by os_open for reading', function() local fd = m.os_open(file1, m.kO_RDONLY, 0) - local err, fp = file_open_fd_new(fd, m.kFileReadOnly, 0) + local err, fp = file_open_fd_new(fd, m.kFileReadOnly) eq(0, err) eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) - eq(0, m.file_free(fp)) + eq(0, m.file_free(fp, false)) end) itp('can use file descriptor returned by os_open for writing', function() eq(nil, lfs.attributes(filec)) local fd = m.os_open(filec, m.kO_WRONLY + m.kO_CREAT, 384) - local err, fp = file_open_fd_new(fd, m.kFileWriteOnly, 0) + local err, fp = file_open_fd_new(fd, m.kFileWriteOnly) eq(0, err) eq(4, file_write(fp, 'test')) - eq(0, m.file_free(fp)) + eq(0, m.file_free(fp, false)) eq(4, lfs.attributes(filec).size) eq('test', io.open(filec):read('*a')) end) @@ -148,7 +156,7 @@ describe('file_open', function() eq(0, err) local attrs = lfs.attributes(filec) eq('rwx------', attrs.permissions) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can create a rw------- file with kFileCreate', function() @@ -156,7 +164,7 @@ describe('file_open', function() eq(0, err) local attrs = lfs.attributes(filec) eq('rw-------', attrs.permissions) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can create a rwx------ file with kFileCreateOnly', function() @@ -164,7 +172,7 @@ describe('file_open', function() eq(0, err) local attrs = lfs.attributes(filec) eq('rwx------', attrs.permissions) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can create a rw------- file with kFileCreateOnly', function() @@ -172,7 +180,7 @@ describe('file_open', function() eq(0, err) local attrs = lfs.attributes(filec) eq('rw-------', attrs.permissions) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('fails to open an existing file with kFileCreateOnly', function() @@ -191,35 +199,35 @@ describe('file_open', function() local err, fp = file_open(file1, m.kFileCreate, 384) eq(0, err) eq(true, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can open an existing file read-only with zero', function() local err, fp = file_open(file1, 0, 384) eq(0, err) eq(false, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can open an existing file read-only with kFileReadOnly', function() local err, fp = file_open(file1, m.kFileReadOnly, 384) eq(0, err) eq(false, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can open an existing file read-only with kFileNoSymlink', function() local err, fp = file_open(file1, m.kFileNoSymlink, 384) eq(0, err) eq(false, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can truncate an existing file with kFileTruncate', function() local err, fp = file_open(file1, m.kFileTruncate, 384) eq(0, err) eq(true, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) local attrs = lfs.attributes(file1) eq(0, attrs.size) end) @@ -228,7 +236,7 @@ describe('file_open', function() local err, fp = file_open(file1, m.kFileWriteOnly, 384) eq(0, err) eq(true, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) local attrs = lfs.attributes(file1) eq(4096, attrs.size) end) @@ -245,7 +253,7 @@ describe('file_open', function() local err, fp = file_open(linkf, m.kFileTruncate, 384) eq(0, err) eq(true, fp.wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) local attrs = lfs.attributes(file1) eq(0, attrs.size) end) @@ -271,7 +279,7 @@ describe('file_open_new', function() local err, fp = file_open_new(file1, 0, 384) eq(0, err) eq(false, fp.wr) - eq(0, m.file_free(fp)) + eq(0, m.file_free(fp, false)) end) itp('fails to open an existing file with kFileCreateOnly', function() @@ -281,7 +289,29 @@ describe('file_open_new', function() end) end) --- file_close is called above, so it is not tested directly +describe('file_close', function() + itp('can flush writes to disk also with true argument', function() + local err, fp = file_open(filec, m.kFileCreateOnly, 384) + eq(0, err) + local wsize = file_write(fp, 'test') + eq(4, wsize) + eq(0, lfs.attributes(filec).size) + eq(0, m.file_close(fp, true)) + eq(wsize, lfs.attributes(filec).size) + end) +end) + +describe('file_free', function() + itp('can flush writes to disk also with true argument', function() + local err, fp = file_open_new(filec, m.kFileCreateOnly, 384) + eq(0, err) + local wsize = file_write(fp, 'test') + eq(4, wsize) + eq(0, lfs.attributes(filec).size) + eq(0, m.file_free(fp, true)) + eq(wsize, lfs.attributes(filec).size) + end) +end) describe('file_fsync', function() itp('can flush writes to disk', function() @@ -294,7 +324,22 @@ describe('file_fsync', function() eq(0, lfs.attributes(filec).size) eq(0, file_fsync(fp)) eq(wsize, lfs.attributes(filec).size) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) + end) +end) + +describe('file_flush', function() + itp('can flush writes to disk', function() + local err, fp = file_open(filec, m.kFileCreateOnly, 384) + eq(0, file_flush(fp)) + eq(0, err) + eq(0, lfs.attributes(filec).size) + local wsize = file_write(fp, 'test') + eq(4, wsize) + eq(0, lfs.attributes(filec).size) + eq(0, file_flush(fp)) + eq(wsize, lfs.attributes(filec).size) + eq(0, m.file_close(fp, false)) end) end) @@ -316,7 +361,7 @@ describe('file_read', function() eq({exp_err, exp_s}, {file_read(fp, size)}) shift = shift + size end - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can read the whole file at once', function() @@ -325,7 +370,7 @@ describe('file_read', function() eq(false, fp.wr) eq({#fcontents, fcontents}, {file_read(fp, #fcontents)}) eq({0, ('\0'):rep(#fcontents)}, {file_read(fp, #fcontents)}) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can read more then 1024 bytes after reading a small chunk', function() @@ -335,7 +380,7 @@ describe('file_read', function() eq({5, fcontents:sub(1, 5)}, {file_read(fp, 5)}) eq({#fcontents - 5, fcontents:sub(6) .. (('\0'):rep(5))}, {file_read(fp, #fcontents)}) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) itp('can read file by 768-byte-chunks', function() @@ -355,7 +400,7 @@ describe('file_read', function() eq({exp_err, exp_s}, {file_read(fp, size)}) shift = shift + size end - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) end) @@ -366,7 +411,7 @@ describe('file_write', function() eq(true, fp.wr) local wr = file_write(fp, fcontents) eq(#fcontents, wr) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) eq(wr, lfs.attributes(filec).size) eq(fcontents, io.open(filec):read('*a')) end) @@ -383,7 +428,7 @@ describe('file_write', function() eq(wr, #s) shift = shift + size end - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) eq(#fcontents, lfs.attributes(filec).size) eq(fcontents, io.open(filec):read('*a')) end) @@ -400,12 +445,24 @@ describe('file_write', function() eq(wr, #s) shift = shift + size end - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) eq(#fcontents, lfs.attributes(filec).size) eq(fcontents, io.open(filec):read('*a')) end) end) +describe('msgpack_file_write', function() + itp('can write the whole file at once', function() + local err, fp = file_open(filec, m.kFileCreateOnly, 384) + eq(0, err) + eq(true, fp.wr) + local wr = msgpack_file_write(fp, fcontents) + eq(0, wr) + eq(0, m.file_close(fp, false)) + eq(fcontents, io.open(filec):read('*a')) + end) +end) + describe('file_skip', function() itp('can skip 3 bytes', function() local err, fp = file_open(file1, 0, 384) @@ -415,6 +472,6 @@ describe('file_skip', function() local rd, s = file_read(fp, 3) eq(3, rd) eq(fcontents:sub(4, 6), s) - eq(0, m.file_close(fp)) + eq(0, m.file_close(fp, false)) end) end) diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 5f8be93aad..667dbeed77 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -35,7 +35,6 @@ for i = 0, 255 do end local fcontents = s:rep(16) -local buffer = "" local directory = nil local absolute_executable = nil local executable_name = nil @@ -65,7 +64,11 @@ local function os_getperm(filename) return tonumber(perm) end -describe('fs function', function() +describe('fs.c', function() + local function os_isdir(name) + return fs.os_isdir(to_cstr(name)) + end + before_each(function() lfs.mkdir('unit-test-directory'); @@ -91,32 +94,37 @@ describe('fs function', function() end) describe('os_dirname', function() - local length - - local function os_dirname(buf, len) - return fs.os_dirname(buf, len) - end - - before_each(function() - length = (string.len(lfs.currentdir())) + 1 - buffer = cstr(length, '') - end) - - itp('returns OK and writes current directory into the buffer if it is large\n enough', function() - eq(OK, (os_dirname(buffer, length))) - eq(lfs.currentdir(), (ffi.string(buffer))) + itp('returns OK and writes current directory to the buffer', function() + local length = string.len(lfs.currentdir()) + 1 + local buf = cstr(length, '') + eq(OK, fs.os_dirname(buf, length)) + eq(lfs.currentdir(), ffi.string(buf)) end) - -- What kind of other failing cases are possible? itp('returns FAIL if the buffer is too small', function() - local buf = cstr((length - 1), '') - eq(FAIL, (os_dirname(buf, (length - 1)))) + local length = string.len(lfs.currentdir()) + 1 + local buf = cstr(length - 1, '') + eq(FAIL, fs.os_dirname(buf, length - 1)) end) end) - local function os_isdir(name) - return fs.os_isdir((to_cstr(name))) - end + describe('os_chdir', function() + itp('fails with path="~"', function() + eq(false, os_isdir('~')) -- sanity check: no literal "~" directory. + local length = 4096 + local expected_cwd = cstr(length, '') + local cwd = cstr(length, '') + eq(OK, fs.os_dirname(expected_cwd, length)) + + -- os_chdir returns 0 for success, not OK (1). + neq(0, fs.os_chdir('~')) -- fail + neq(0, fs.os_chdir('~/')) -- fail + + eq(OK, fs.os_dirname(cwd, length)) + -- CWD did not change. + eq(ffi.string(expected_cwd), ffi.string(cwd)) + end) + end) describe('os_isdir', function() itp('returns false if an empty string is given', function() @@ -870,6 +878,11 @@ describe('fs function', function() end describe('os_fileinfo', function() + itp('returns false if path=NULL', function() + local file_info = file_info_new() + assert.is_false((fs.os_fileinfo(nil, file_info))) + end) + itp('returns false if given a non-existing file', function() local file_info = file_info_new() assert.is_false((fs.os_fileinfo('/non-existent', file_info))) diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua index e883301cfb..37274502de 100644 --- a/test/unit/os/shell_spec.lua +++ b/test/unit/os/shell_spec.lua @@ -15,7 +15,7 @@ local NULL = ffi.cast('void *', 0) describe('shell functions', function() before_each(function() -- os_system() can't work when the p_sh and p_shcf variables are unset - cimported.p_sh = to_cstr('/bin/bash') + cimported.p_sh = to_cstr('/bin/sh') cimported.p_shcf = to_cstr('-c') cimported.p_sxq = to_cstr('') cimported.p_sxe = to_cstr('') @@ -53,14 +53,14 @@ describe('shell functions', function() describe('os_system', function() itp('can echo some output (shell builtin)', function() - local cmd, text = 'echo -n', 'some text' + local cmd, text = 'printf "%s "', 'some text ' local status, output = os_system(cmd .. ' ' .. text) eq(text, output) eq(0, status) end) itp('can deal with empty output', function() - local cmd = 'echo -n' + local cmd = 'printf ""' local status, output = os_system(cmd) eq('', output) eq(0, status) @@ -81,19 +81,19 @@ describe('shell functions', function() describe('shell_build_argv', function() itp('works with NULL arguments', function() - eq({'/bin/bash'}, shell_build_argv(nil, nil)) + eq({'/bin/sh'}, shell_build_argv(nil, nil)) end) itp('works with cmd', function() - eq({'/bin/bash', '-c', 'abc def'}, shell_build_argv('abc def', nil)) + eq({'/bin/sh', '-c', 'abc def'}, shell_build_argv('abc def', nil)) end) itp('works with extra_args', function() - eq({'/bin/bash', 'ghi jkl'}, shell_build_argv(nil, 'ghi jkl')) + eq({'/bin/sh', 'ghi jkl'}, shell_build_argv(nil, 'ghi jkl')) end) itp('works with cmd and extra_args', function() - eq({'/bin/bash', 'ghi jkl', '-c', 'abc def'}, shell_build_argv('abc def', 'ghi jkl')) + eq({'/bin/sh', 'ghi jkl', '-c', 'abc def'}, shell_build_argv('abc def', 'ghi jkl')) end) itp('splits and unquotes &shell and &shellcmdflag', function() @@ -112,7 +112,7 @@ describe('shell functions', function() local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo &|<>()@^'), nil)) - eq(ffi.string(argv[0]), '/bin/bash') + eq(ffi.string(argv[0]), '/bin/sh') eq(ffi.string(argv[1]), '-c') eq(ffi.string(argv[2]), '(echo ^&^|^<^>^(^)^@^^)') eq(nil, argv[3]) @@ -124,7 +124,7 @@ describe('shell functions', function() local argv = ffi.cast('char**', cimported.shell_build_argv( to_cstr('echo -n some text'), nil)) - eq(ffi.string(argv[0]), '/bin/bash') + eq(ffi.string(argv[0]), '/bin/sh') eq(ffi.string(argv[1]), '-c') eq(ffi.string(argv[2]), '"(echo -n some text)"') eq(nil, argv[3]) @@ -136,7 +136,7 @@ describe('shell functions', function() local argv = ffi.cast('char**', cimported.shell_build_argv( to_cstr('echo -n some text'), nil)) - eq(ffi.string(argv[0]), '/bin/bash') + eq(ffi.string(argv[0]), '/bin/sh') eq(ffi.string(argv[1]), '-c') eq(ffi.string(argv[2]), '"echo -n some text"') eq(nil, argv[3]) @@ -145,7 +145,7 @@ describe('shell functions', function() itp('with empty shellxquote/shellxescape', function() local argv = ffi.cast('char**', cimported.shell_build_argv( to_cstr('echo -n some text'), nil)) - eq(ffi.string(argv[0]), '/bin/bash') + eq(ffi.string(argv[0]), '/bin/sh') eq(ffi.string(argv[1]), '-c') eq(ffi.string(argv[2]), 'echo -n some text') eq(nil, argv[3]) |