[ZeroBrane Studio] Re: Running tests with ZB

  • From: Paul K <paul@xxxxxxxxxxxxx>
  • To: "zerobrane@xxxxxxxxxxxxx" <zerobrane@xxxxxxxxxxxxx>
  • Date: Fri, 29 May 2015 10:03:18 -0700

Hi Artem,

But maybe instead of running external program via 'CommandLineRun' i can use
current lua interpreter used in ZB, like one used in Console window?

Either way should work; I prefer running as a separate process, simply
because if you run it in the IDE, os.exit() in one of the tests, will
close the IDE; you will be isolated from any issues in the tests if
you run the test process separately.

ZBS provides "ide:ExecuteCommand(command, workdir, stringcallback,
endcallback)" method that is a bit more user-friendly than
CommandLineRun. For example, you can run something like this from the
local console (assuming you have "git" present and set the project
directory to ZBS/src):

ide:ExecuteCommand("git --no-pager blame main.lua", "", function(s)
DisplayShell(s) end, function() DisplayShell("done") end)

You can also use DisplayOutput instead of DisplayShell if you want to
see the results in the Output window. Note two things: (1) the command
is executed asyncronously (and you can run several commands in
parallel); and (2) what you read back are not strings, but simply
chunks of your output, so take that into account when processing the
results.

Paul.

Other related posts: