From 459a6ff05882e5249f02172b61f2bddc4b598e39 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 22 Oct 2016 20:40:06 +0200 Subject: test: system(): Avoid indeterminism. --- test/functional/eval/system_spec.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'test/functional/eval/system_spec.lua') diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua index b8f1f87f30..6393477260 100644 --- a/test/functional/eval/system_spec.lua +++ b/test/functional/eval/system_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) -local eq, clear, eval, feed, nvim = - helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim +local eq, clear, eval, execute, feed, nvim = + helpers.eq, helpers.clear, helpers.eval, helpers.execute, helpers.feed, + helpers.nvim local Screen = require('test.functional.ui.screen') @@ -117,8 +118,12 @@ describe('system()', function() eq("echoed", eval('system("echo -n echoed")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("echo -n echoed &")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("echo -n echoed &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) @@ -128,8 +133,12 @@ describe('system()', function() eq("input", eval('system("cat -", "input")')) end) it('to backgrounded command does not crash', function() - -- This is indeterminate, just exercise the codepath. - eval('system("cat - &", "input")') + -- This is indeterminate, just exercise the codepath. May get E5677. + execute('call system("cat - &")') + local v_errnum = string.match(eval("v:errmsg"), "^E%d*:") + if v_errnum then + eq("E5677:", v_errnum) + end eq(2, eval("1+1")) -- Still alive? end) end) -- cgit