For Programmers: Free Programming Magazines  


Home > Archive > PHP PEAR Questions and Answers > November 2004 > significant change to how run-tests works - is it OK?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author significant change to how run-tests works - is it OK?
Greg Beaver

2004-11-27, 8:55 am

Hi,

I just encountered one problem with run-tests - it uses backticks to
execute tests, like so:

$out = `$cmd`;

This is great for almost all situations. Unfortunately, in very rare
cases, it is also necessary to test for return values. For instance,
the shell-test command returns 1 or 0 - this is the only way to test its
output (by design).

Fortunately, by changing the code above to:

ob_start();
system($cmd, $return_value);
$out = ob_get_contents();
ob_end_clean();

it's possible to retrieve the return value and test based on it.
Otherwise, I will have to somehow run a test-within-a-test, which would
suck.

My question is: are there any situations that anyone knows of where
system() just doesn't measure up to the flexibility of shell_exec()?

Greg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com