I have a Codeigniter project that uses Codeception for acceptance testing. I have a 'tools' controller setup in Codeigniter, which I use to store command line methods that perform various utility functions.
In this case, I'm creating a utility method that sets up the testing environment, switches databases, builds / runs the tests, etc.
I'm using the PHP function shell_exec()
to run the codception commands. They're working, however when shell_exec()
issues the `php codecept.phar run' command, it's not providing verbose output. It waits until all the tests are done (which takes a long time) and then spits out all the output at the end.
Is there a way to have shell_exec() print the output as it receives it?
example code:
public function run_tests()
{
$this->load->database('testing');
echo shell_exec("cd ..; php codecept.phar build");
echo shell_exec("cd ..; php codecept.phar run");
}
Use passthru
, which streams the output of a command directly to the response stream.