Source

hpaco / runtest

Full commit
#!/usr/bin/env php
<?php

$hpaco_binary = '../cabal-dev/bin/hpaco';
$json_data = '';
$template = '';
$end_of_json = false;

foreach (file('php://stdin') as $line) {
    if ($end_of_json) {
        $template .= $line;
    }
    elseif ($line == "\n") {
        $end_of_json = true;
    }
    else {
        $json_data .= $line;
    }
}

$hpaco_command = $hpaco_binary . " --php-func <<EOT\n" . $template . "EOT\n";

chdir(dirname(__FILE__) . "/tests");
exec($hpaco_command, $output, $retval);

if ($retval) {
    exit($retval);
}

$src = '?>' . implode("\n", $output);
eval($src);

$data = json_decode($json_data, true);

runTemplate($data);