aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-05-08 11:07:57 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-05-08 11:07:57 -0700
commite6d85927ea69325e79fa4fd5cee0882e9ad3303f (patch)
treec0463e5829075139b8bbf0683d0521a2036efefb /test
parent40603dd4cd80f633239d1f48da3c3c834412b02e (diff)
downloadpandoc-e6d85927ea69325e79fa4fd5cee0882e9ad3303f.tar.gz
test-pandoc-utils.lua: remove problems with missing `/bin/false`.
Previously it was assumed that the system would have `/bin/false` and `/bin/sed`, and these tests were skipped otherwise. On MacOS, these utilities are located in `/usr/bin`. Fixed by just using `sed` and `false` -- these should always be in the path. Removed the "skipping" behavior, replaced with a check for Windows. On Windowns, we use `echo` and `cd`, which should always exist. Not yet checked on Windows.
Diffstat (limited to 'test')
-rw-r--r--test/lua/test-pandoc-utils.lua35
1 files changed, 22 insertions, 13 deletions
diff --git a/test/lua/test-pandoc-utils.lua b/test/lua/test-pandoc-utils.lua
index c732d2f85..000be1f7a 100644
--- a/test/lua/test-pandoc-utils.lua
+++ b/test/lua/test-pandoc-utils.lua
@@ -32,25 +32,34 @@ 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('echo', {}, 'hi')
+ return pipe_result == 'hi\n'
+ else
+ local pipe_result = pandoc.pipe('sed', {'-e', 's/a/b/'}, 'abc')
+ return pipe_result == 'bbc\n'
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, 'cd', {}, 'NoNExistEnt')
+ return not res and
+ err.command == 'cd' and
+ err.error_code == 1 and
+ err.output == ''
+ 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