From 6bb9274855236473226bdb2999b4143d78a37bcc Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Fri, 22 Jan 2021 12:06:36 -0500 Subject: Compile, run, and build command functions can also return environment tables. --- test/test.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/test.lua b/test/test.lua index 25aff22a..5a0fae05 100644 --- a/test/test.lua +++ b/test/test.lua @@ -3130,6 +3130,25 @@ function test_run_goto_internal_lua_error() buffer:close() end +function test_run_commands_function() + local filename = os.tmpname() + io.open_file(filename) + textadept.run.run_commands.text = function() + return [[lua -e 'print(os.getenv("FOO"))']], '/tmp', {FOO = 'bar'} + end + textadept.run.run() + assert_equal(#_BUFFERS, 3) -- including [Test Output] + assert_equal(buffer._type, _L['[Message Buffer]']) + ui.update() -- process output + assert(buffer:get_text():find('> cd /tmp'), 'cwd not set properly') + assert(buffer:get_text():find('bar'), 'env not set properly') + if #_VIEWS > 1 then view:unsplit() end + buffer:close() + buffer:close() + textadept.run.run_commands.text = nil -- reset + os.remove(filename) +end + -- TODO: test textadept.run.run_in_background function test_session_save() -- cgit v1.2.3