diff options
Diffstat (limited to 'test/lua/test-pandoc-utils.lua')
-rw-r--r-- | test/lua/test-pandoc-utils.lua | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua index c732d2f85..21f937edb 100644 --- a/test/lua/test-pandoc-utils.lua +++ b/test/lua/test-pandoc-utils.lua @@ -32,25 +32,33 @@ end function warn (...) io.stderr:write(...) end +function os_is_windows () + return package.config:sub(1,1) == '\\' +end + function test_pipe () - if not file_exists('/bin/sed') then - warn 'Did not find /bin/sed, skipping test' - return true + if os_is_windows() then + local pipe_result = pandoc.pipe('find', {'hi'}, 'hi') + return pipe_result:match("%a+") == 'hi' + else + local pipe_result = pandoc.pipe('tr', {'a', 'b'}, 'abc') + return pipe_result:match("%a+") == 'bbc' end - local pipe_result = pandoc.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc') - return pipe_result == 'bbc' end function test_failing_pipe () - if not file_exists('/bin/false') then - warn 'Did not find /bin/false, skipping test' - return true + if os_is_windows() then + local res, err = pcall(pandoc.pipe, 'find', {'/a'}, 'hi') + return not res and + err.command == 'find' and + err.error_code ~= 0 + else + local res, err = pcall(pandoc.pipe, 'false', {}, 'abc') + return not res and + err.command == 'false' and + err.error_code == 1 and + err.output == '' end - local res, err = pcall(pandoc.pipe, '/bin/false', {}, 'abc') - return not res and - err.command == '/bin/false' and - err.error_code == 1 and - err.output == '' end -- Read |