@@ -32,25 +32,34 @@ end
33function warn (...) io.stderr:write(...) end
33function warn (...) io.stderr:write(...) end
35+function os_is_windows ()
36+ return package.config:sub(1,1) == '\\'
35function test_pipe ()
39function test_pipe ()
36− if not file_exists('/bin/sed') then
40+ if os_is_windows() then
37− warn 'Did not find /bin/sed, skipping test'
41+ local pipe_result = pandoc.pipe('echo', {}, 'hi')
38− return true
42+ return pipe_result == 'hi\n'
44+ local pipe_result = pandoc.pipe('sed', {'-e', 's/a/b/'}, 'abc')
45+ return pipe_result == 'bbc\n'
40− local pipe_result = pandoc.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc')
41− return pipe_result == 'bbc'
44function test_failing_pipe ()
49function test_failing_pipe ()
45− if not file_exists('/bin/false') then
50+ if os_is_windows() then
46− warn 'Did not find /bin/false, skipping test'
51+ local res, err = pcall(pandoc.pipe, 'cd', {}, 'NoNExistEnt')
53+ err.command == 'cd' and
54+ err.error_code == 1 and
57+ local res, err = pcall(pandoc.pipe, 'false', {}, 'abc')
47− return true
58+ return not res and
59+ err.command == 'false' and
60+ err.error_code == 1 and
49− local res, err = pcall(pandoc.pipe, '/bin/false', {}, 'abc')
51− err.command == '/bin/false' and
52− err.error_code == 1 and