Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds unit testing.

  • Loading branch information...
commit 4a6e31b781552bbff656097fd3a48673555363d0 1 parent 42492fd
@SaltwaterC authored
View
3  Makefile
@@ -3,3 +3,6 @@ all:
publish: all
/usr/bin/env npm publish
+
+test:
+ tools/test.sh
View
9 tests/broken-xml.js
@@ -0,0 +1,9 @@
+var parser = require('../');
+
+var fs = require('fs');
+var assert = require('assert');
+
+parser(fs.readFileSync('data/broken.xml').toString(), function (err, res) {
+ assert.ok(err instanceof Error);
+ assert.equal(err.code, 4);
+});
View
1  tests/data/broken.xml
@@ -0,0 +1 @@
+This is a broken XML file.
View
34 tools/test.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+NODE_BIN='/usr/bin/env node'
+FAIL=0
+TOTAL=0
+
+cd tests
+
+for TEST in `dir -d ./*.js`
+do
+ if [ -f $TEST ]
+ then
+ echo "Running test: "`basename $TEST`
+ $NODE_BIN $TEST > /dev/null
+ EXIT_CODE=$?
+ if [ $EXIT_CODE -ne 0 ]
+ then
+ FAIL=$(($FAIL+1))
+ fi
+ TOTAL=$(($TOTAL+1))
+ fi
+done
+
+echo ""
+echo "Failed tests: $FAIL"
+echo "Total tests: $TOTAL"
+echo ""
+
+if [ $FAIL -eq 0 ]
+then
+ exit 0
+else
+ exit 1
+fi
Please sign in to comment.
Something went wrong with that request. Please try again.