git.iko.soy/typeable/pandoc
on master help sign in
test-pandoc-utils.lua: remove problems with missing `/bin/false`.
e6d8592John MacFarlane
test/lua/test-pandoc-utils.lua+22−13
@@ -32,25 +32,34 @@ end
32
32
33function warn (...) io.stderr:write(...) end
33function warn (...) io.stderr:write(...) end
34
34
35+function os_is_windows ()
36+ return package.config:sub(1,1) == '\\'
37+end
38+
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'
43+ else
44+ local pipe_result = pandoc.pipe('sed', {'-e', 's/a/b/'}, 'abc')
45+ return pipe_result == 'bbc\n'
39 end
46 end
40− local pipe_result = pandoc.pipe('/bin/sed', {'-e', 's/a/b/'}, 'abc')
41− return pipe_result == 'bbc'
42end
47end
43
48
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')
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')
47− return true
58+ return not res and
59+ err.command == 'false' and
60+ err.error_code == 1 and
61+ err.output == ''
48 end
62 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 == ''
54end
63end
55
64
56-- Read
65-- Read