DIRECTORY
Commander, CommanderOps, Convert, IO, Rope, RunRegressions;
RunRegressionsInCommanderImpl: MONITOR
IMPORTS Commander, CommanderOps, IO, Rope
EXPORTS RunRegressions
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
test: TYPE ~ RECORD[
proc: PROC,
testName: ROPE];
cmds: LIST OF test ← NIL;
RegisterTest: PUBLIC PROC [callBackProc: PROC, testName: ROPE] ~ {
cmds ← CONS[[callBackProc, testName], cmds];
};
RunAllTests: ENTRY Commander.CommandProc ~ TRUSTED {
FOR p: LIST OF test ← cmds, p.rest WHILE p # NIL DO
RunTest[cmd, p.first];
ENDLOOP;
};
ListTests: ENTRY Commander.CommandProc ~ TRUSTED {
IO.PutRope[cmd.out,"Tests:\n"];
FOR p: LIST OF test ← cmds, p.rest WHILE p # NIL DO
IO.PutF1[cmd.out, "%g ", IO.rope[p.first.testName]];
ENDLOOP;
IO.PutRope[cmd.out,"\n"];
};
RunTest: PROC [cmd: Commander.Handle, p: test] ~ {
IO.PutF1[cmd.out, "Starting %g\n", IO.rope[p.testName]];
p.proc[];
IO.PutRope[cmd.out, "Done\n"];
};
RunATest: ENTRY Commander.CommandProc ~ TRUSTED {
name: ROPE;
IF CommanderOps.NumArgs[cmd] > 1 THEN {
name ← CommanderOps.ArgN[cmd, 1];
}
ELSE {
IO.PutRope[cmd.out, "expected name of test\n"];
RETURN;
};
FOR p: LIST OF test ← cmds, p.rest WHILE p # NIL DO
IF Rope.Equal[p.first.testName,name] THEN {
RunTest[cmd, p.first];
RETURN;
};
ENDLOOP;
IO.PutF1[cmd.out, "test %g not found\n", IO.rope[name]];
};
Commander.Register["RunAllRegressions", RunAllTests];
Commander.Register["RunARegression", RunATest];
Commander.Register["ListRegressions", ListTests];
END.