Skip to content
This repository has been archived by the owner on Aug 16, 2020. It is now read-only.

Commit

Permalink
doctest runner for Node (also fix name and version)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamrin committed Apr 11, 2013
1 parent 018f776 commit 2a1b524
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
20 changes: 20 additions & 0 deletions bin/doctest
@@ -0,0 +1,20 @@
#!/usr/bin/env node

var path = require('path');
var fs = require('fs');
var root = path.join(path.dirname(fs.realpathSync(__filename)), '..');

var doctest = require(root + '/doctest');

var runner = new doctest.Runner({Reporter: doctest.ConsoleReporter});
var parser = new doctest.TextParser.fromFile(runner, process.argv[2]);
parser.parse();
runner.run();
var reporter = runner.reporter;
console.log('Successes:', reporter.successes);
console.log('Failures:', reporter.failures);
if ((! reporter.successes) || reporter.failures) {
// Set exit code to number of failures (if any). It gives a nice failures
// summary when running under make. E.g.: `make: *** [doctest] Error 2`
process.exit(reporter.failures || 1);
}
7 changes: 5 additions & 2 deletions package.json
@@ -1,7 +1,10 @@
{
"name": "doctest",
"version": "0.3",
"name": "doctestjs",
"version": "0.3.0",
"main": "doctest",
"bin": {
"doctest": "./bin/doctest"
},
"description": "Example-based testing framework",
"keywords": [],
"author": {
Expand Down

0 comments on commit 2a1b524

Please sign in to comment.