Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Robinson
committed
Apr 8, 2010
1 parent
f52daaa
commit 881c8a1
Showing
9 changed files
with
239 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,73 @@ | ||
|
||
var BCOMM = require("bcomm"); | ||
|
||
var UTIL = require("util"); | ||
var OS = require("os"); | ||
var SYSTEM = require("system"); | ||
|
||
var BCOMM = require("bcomm"); | ||
var stream = require("term").stream; | ||
var readline = require("readline").readline; | ||
|
||
var parser = exports.parser = new (require("args").Parser)(); | ||
parser.help("run a test"); | ||
|
||
parser.option('-r', 'runners') | ||
parser.option("-r", "runnerIDs") | ||
.push() | ||
.help("select a runner (multiple allowed)"); | ||
|
||
parser.option('-e', 'eval') | ||
parser.option("-e", "eval") | ||
.set() | ||
.help("select a runner (multiple allowed)"); | ||
|
||
parser.option('-n', 'noAutoComplete') | ||
parser.option("-n", "noAutoComplete") | ||
.set(true) | ||
.help("disable auto-completion of task"); | ||
|
||
parser.option("-t", "--timeout", "timeout") | ||
.natural() | ||
.def(5) | ||
.help("timeout period, in seconds, or 0 for no timeout (default 5)"); | ||
|
||
parser.helpful(); | ||
|
||
parser.action(function (options) { | ||
if (options.eval) { | ||
exports.evaluate(options.eval, options.runners, options); | ||
exports.evaluate(options.eval, options.runnerIDs, options); | ||
} else { | ||
while (true) { | ||
exports.evaluate(readline("> "), options.runners, options); | ||
exports.evaluate(readline("> "), options.runnerIDs, options); | ||
} | ||
} | ||
}); | ||
|
||
exports.evaluate = function(command, runners, options) { | ||
var taskIDs = BCOMM.request("eval", { | ||
command : command, | ||
runners : runners, | ||
noAutoComplete : options.noAutoComplete | ||
exports.evaluate = function(command, runnerIDs, options) { | ||
var taskIDs = BCOMM.request("task-send", { | ||
runnerIDs : runnerIDs, | ||
task : { | ||
type : "eval", | ||
command : command, | ||
noAutoComplete : options.noAutoComplete | ||
} | ||
}); | ||
|
||
|
||
var start = new Date(); | ||
|
||
while (taskIDs.length > 0) { | ||
var responses = BCOMM.request("task-responses", { taskIDs : taskIDs }); | ||
|
||
responses.forEach(function(response) { | ||
BCOMM.printResponse(response); | ||
BCOMM.printResponse(response); | ||
if (response.complete) | ||
taskIDs = taskIDs.filter(function(taskID) { return taskID !== response.taskID }); | ||
}); | ||
|
||
|
||
var elapsed = new Date() - start; | ||
if (taskIDs.length > 0 && options.timeout > 0 && elapsed > options.timeout * 1000) { | ||
stream.print("\0red(Warning: tasks " + taskIDs.join(", ") + " timed out\0)"); | ||
break; | ||
} | ||
|
||
if (taskIDs.length > 0) | ||
OS.sleep(1.0); | ||
OS.sleep(0.5); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.