Permalink
Browse files

Switched npm test from the bash script to a node script so that it is…

… cross-platform.

Also now based off a static list of files so failing tests can be kept in the tests folder while being worked on.
  • Loading branch information...
1 parent 9b2bbf0 commit c94b200258fa48697e386121a3e114ab7bed2ecf @csainty csainty committed Feb 20, 2012
Showing with 23 additions and 21 deletions.
  1. +1 −1 package.json
  2. +18 −10 tests/run.js
  3. +0 −6 tests/run.sh
  4. +4 −4 tests/test-qs.js
View
@@ -11,5 +11,5 @@
{ "url" : "http://github.com/mikeal/request/issues" }
, "engines" : ["node >= 0.3.6"]
, "main" : "./main"
-, "scripts": { "test": "bash tests/run.sh" }
+, "scripts": { "test": "node tests/run.js" }
}
View
@@ -1,21 +1,29 @@
-var fs = require('fs')
- , spawn = require('child_process').spawn
- , tests = []
+var spawn = require('child_process').spawn
, exitCode = 0
;
-
-fs.readdirSync('tests').forEach(function (file) {
- if (! /test-/.test(file)) return
- tests.push('tests/' + file)
-})
+var tests = [
+ 'test-body.js'
+ , 'test-cookie.js'
+ , 'test-cookiejar.js'
+ , 'test-errors.js'
+ , 'test-headers.js'
+ , 'test-httpModule.js'
+ , 'test-https.js'
+ , 'test-oauth.js'
+ , 'test-pipes.js'
+ , 'test-proxy.js'
+ , 'test-qs.js'
+ , 'test-redirect.js'
+ , 'test-timeout.js'
+]
var next = function () {
if (tests.length === 0) process.exit(exitCode);
- var file = tests.pop()
+ var file = tests.shift()
console.log(file)
- var proc = spawn('node', [ file ])
+ var proc = spawn('node', [ 'tests/' + file ])
proc.stdout.pipe(process.stdout)
proc.stderr.pipe(process.stderr)
proc.on('exit', function (code) {
View
@@ -1,6 +0,0 @@
-FAILS=0
-for i in tests/test-*.js; do
- echo $i
- node $i || let FAILS++
-done
-exit $FAILS
View
@@ -4,25 +4,25 @@ var request = request = require('../main.js')
// Test adding a querystring
-var req1 = request.get({ uri: 'http://localhost', qs: { q : 'search' }})
+var req1 = request.get({ uri: 'http://www.google.com', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?q=search', req1.path)
}, 1)
// Test replacing a querystring value
-var req2 = request.get({ uri: 'http://localhost?q=abc', qs: { q : 'search' }})
+var req2 = request.get({ uri: 'http://www.google.com?q=abc', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?q=search', req2.path)
}, 1)
// Test appending a querystring value to the ones present in the uri
-var req3 = request.get({ uri: 'http://localhost?x=y', qs: { q : 'search' }})
+var req3 = request.get({ uri: 'http://www.google.com?x=y', qs: { q : 'search' }})
setTimeout(function() {
assert.equal('/?x=y&q=search', req3.path)
}, 1)
// Test leaving a querystring alone
-var req4 = request.get({ uri: 'http://localhost?x=y'})
+var req4 = request.get({ uri: 'http://www.google.com?x=y'})
setTimeout(function() {
assert.equal('/?x=y', req4.path)
}, 1)

0 comments on commit c94b200

Please sign in to comment.