-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spawner.js
40 lines (36 loc) · 1.05 KB
/
Spawner.js
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
31
32
33
34
35
36
37
38
39
40
const Child=require('child_process');
function RunCommand(Command) {
return new Promise(Resolve=>{
let Output='';
let Process=Child.exec(Command,{timeout:60000},(...Pipes)=>{
for(let Pipe of Pipes)
if(Pipe)
Output+=Pipe;
});
Process.on('close',()=>{
Resolve(Output);
});
});
}
process.on("message",async(message)=>{
let Tests=message.Tests;
let Entry=message.Entry;
let Promises=[];
let Completed=0,Spawned=0;
Entry.tests=[];
for(let Test of Tests) {
let Result=await RunCommand(Entry.interpreter+' Entries/'+Entry.file+' "'+Test.input.replace(/\n/g,'" "')+'" <<< \''+Test.input+'\'');
Entry.tests.push({
input:Test.input,
expected:Test.output,
output:Result
});
Completed++;
if(Completed%11==0)
process.send({Completed});
}
process.send({Completed});
process.send(Entry);
setTimeout(()=>process.exit(0),100);
});
process.send("ready");