Skip to content
Browse files

doctest runner for Node (also fix name and version)

  • Loading branch information...
1 parent 018f776 commit 2a1b524320d0fa15ada88fe86fd18009eb4ffd97 @shamrin shamrin committed Apr 11, 2013
Showing with 25 additions and 2 deletions.
  1. +20 −0 bin/doctest
  2. +5 −2 package.json
View
20 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);
+}
View
7 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": {

0 comments on commit 2a1b524

Please sign in to comment.
Something went wrong with that request. Please try again.