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