5 * Small utilities for wrapping tests to put output into fbmake.
7 * See hphp/hhvm/fbmake_test_ext_wrapper.php.
10 // Output is in the format expected by JsonTestRunner.
12 fwrite(STDERR
, json_encode($val, JSON_UNESCAPED_SLASHES
) . "\n");
15 // Currently running test, and the results of each test.
19 function finish($status) {
23 say(array('op' => 'test_done',
26 'status' => $status));
27 array_push($results, array('name' => $current,
28 'status' => $status));
32 function start($test) {
36 say(array('op' => 'start',
40 function test_is_running() {
41 return $GLOBALS['current'] != '';
44 function loop_tests($cmd, $line_func) {
47 $ftest = popen($cmd, 'r');
49 echo "Couldn't run test script\n";
52 while (!feof($ftest)) {
53 $line = fgets($ftest);
56 if (!fclose($ftest)) {
58 if ($current !== '') {
66 say(array('op' => 'all_done',
67 'results' => $results));
71 chdir(__DIR__
.'/../../../');
72 $cmd = "./hphp/tools/run_test_binary.sh " .
73 "'$argv[1]' '$argv[2]' '$argv[3]' '$argv[4]' ".
76 loop_tests($cmd, function ($line) {
77 if (preg_match('/^(Test[a-zA-Z]*)\.\.\.\.\.\.$/', $line, $m)) {
79 } else if (preg_match('/^Test[a-zA-Z]* (OK|\#\#\#\#\#\>\>\> FAILED)/',
82 finish($m[1] == 'OK' ?
'passed' : 'failed');