summaryrefslogtreecommitdiff
path: root/generate-status-object.php
blob: 9d19070e53657a349c2eb25c3866ed390c822d42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

if (empty($argv[1])) {
    file_put_contents("php://stderr", "No runner ID specified");
    exit(1);
}

define("WORK_DIR", __DIR__ . "/_runners/" . $argv[1] . "/results");

function get(string $name): ?string {
    $file = WORK_DIR . "/" . $name;
    if (!is_file($file))
        return null;
    return file_get_contents($file);
}

$data = [
    "compile" => [
        "status" => get("c.s"),
        "stdout" => get("c.0"),
        "stderr" => get("c.1"),
    ],
    "run" => [
        "status" => get("r.s"),
        "stdout" => get("r.0"),
        "stderr" => get("r.1"),
    ],
];

echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL;