tinytest: drop results for a run when requested by client, not onComplete.

Should be useful for a non-browser-based test runner.
This commit is contained in:
David Glasser
2012-12-12 12:54:48 -08:00
parent 69459b8c70
commit cd250f0945
2 changed files with 12 additions and 6 deletions

View File

@@ -35,13 +35,15 @@ Meteor._runTestsEverywhere = function (onReport, onComplete) {
}
});
Meteor.subscribe(Meteor._ServerTestResultsSubscription, runId);
var handle = Meteor.subscribe(Meteor._ServerTestResultsSubscription, runId);
Meteor.call('tinytest/run', runId, function (error, result) {
if (error)
// XXX better report error
throw new Error("Test server returned an error");
remoteComplete = true;
handle.stop();
Meteor.call('tinytest/clearResults', runId);
maybeDone();
});
};

View File

@@ -48,17 +48,21 @@
};
var onComplete = function() {
_.each(handlesForRun[runId], function (handle) {
handle.stop();
});
delete handlesForRun[runId];
delete reportsForRun[runId];
future.ret();
};
Meteor._runTests(onReport, onComplete);
future.wait();
},
'tinytest/clearResults': function (runId) {
_.each(handlesForRun[runId], function (handle) {
// XXX this doesn't actually notify the client that it has been
// unsubscribed.
handle.stop();
});
delete handlesForRun[runId];
delete reportsForRun[runId];
}
});
}());