|
@@ -6,15 +6,11 @@ import std.experimental.logger;
|
6
|
6
|
import std.process;
|
7
|
7
|
import std.stdio : File;
|
8
|
8
|
|
9
|
|
-File devnullWrite, devnullRead;
|
10
|
|
-
|
11
|
9
|
static this()
|
12
|
10
|
{
|
13
|
11
|
import std.file : getcwd;
|
14
|
12
|
import std.path : absolutePath, buildPath;
|
15
|
13
|
dataDir = buildPath(getcwd, "projects").absolutePath;
|
16
|
|
- devnullWrite = File("/dev/null", "w");
|
17
|
|
- devnullRead = File("/dev/null", "r");
|
18
|
14
|
}
|
19
|
15
|
|
20
|
16
|
void cd(string dir)
|
|
@@ -38,16 +34,22 @@ ProcessResult run(string[] args...)
|
38
|
34
|
|
39
|
35
|
ProcessResult run(Duration maxTime, string[] args...)
|
40
|
36
|
{
|
41
|
|
- import std.path : buildPath;
|
42
|
|
- import std.file : readText;
|
43
|
|
-
|
44
|
37
|
infof("running: %s", args);
|
45
|
38
|
ProcessResult result;
|
46
|
|
- auto start = Clock.currTime;
|
47
|
|
- auto deadline = start + maxTime;
|
|
39
|
+
|
|
40
|
+ import std.path : buildPath;
|
48
|
41
|
auto stderrPath = buildPath(procDir, ".stderr");
|
49
|
42
|
auto childStderr = File(stderrPath, "w");
|
50
|
|
- auto pid = spawnProcess(args, File("/dev/null", "r"), File("/dev/null", "w"), childStderr, env, Config.none, procDir);
|
|
43
|
+ auto start = Clock.currTime;
|
|
44
|
+ auto deadline = start + maxTime;
|
|
45
|
+ auto pid = spawnProcess(
|
|
46
|
+ args,
|
|
47
|
+ // stdin / stdout / stderr
|
|
48
|
+ File("/dev/null", "r"), File("/dev/null", "w"), childStderr,
|
|
49
|
+ env,
|
|
50
|
+ Config.none,
|
|
51
|
+ procDir);
|
|
52
|
+
|
51
|
53
|
SysTime end;
|
52
|
54
|
while (true)
|
53
|
55
|
{
|
|
@@ -67,7 +69,8 @@ ProcessResult run(Duration maxTime, string[] args...)
|
67
|
69
|
import core.thread : Thread;
|
68
|
70
|
Thread.sleep(500.msecs);
|
69
|
71
|
}
|
70
|
|
- result.stderr = readText(stderrPath);
|
|
72
|
+ import std.file : read;
|
|
73
|
+ result.stderr = cast(const(ubyte)[])read(stderrPath);
|
71
|
74
|
result.runningTime = end - start;
|
72
|
75
|
return result;
|
73
|
76
|
}
|
|
@@ -86,5 +89,6 @@ struct ProcessResult
|
86
|
89
|
int status;
|
87
|
90
|
Duration runningTime;
|
88
|
91
|
bool timedOut;
|
89
|
|
- string stderr;
|
|
92
|
+ //
|
|
93
|
+ const(ubyte)[] stderr;
|
90
|
94
|
}
|