build: improve platform portability

parent 91f9b666
*.markdown
*.md
.git*
Makefile
benchmarks/
docs/
examples/
install.sh
support/
test/
.DS_Store
coverage.html
.travis.yml
TESTS = test/*.js
REPORTER = dot
DOX = ./node_modules/.bin/dox
SRC = $(shell find lib/*.js lib/middleware/*.js)
HTML = $(SRC:.js=.html)
test:
@NODE_ENV=test ./node_modules/.bin/mocha \
--reporter $(REPORTER) \
--timeout 600 \
--bail \
$(TESTS)
docs: $(HTML)
@mv $(HTML) docs
test-cov: lib-cov
@CONNECT_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
lib-cov:
@jscoverage lib $@
%.html: %.js
$(DOX) < $< | node support/docs > $@
docclean:
rm -f $(HTML)
site: docclean docs
rm -fr /tmp/docs \
&& cp -fr docs /tmp/docs \
&& git checkout gh-pages \
&& cp -fr /tmp/docs/* . \
&& echo "done"
benchmark:
@./support/bench
.PHONY: test-cov site docs test docclean benchmark
\ No newline at end of file
......@@ -56,7 +56,7 @@ first:
then:
$ make test
$ npm test
## Contributors
......
module.exports = process.env.CONNECT_COV
? require('./lib-cov/connect')
: require('./lib/connect');
\ No newline at end of file
module.exports = require('./lib/connect');
......@@ -53,6 +53,6 @@
"node": ">= 0.8.0"
},
"scripts": {
"test": "make"
"test": "mocha --reporter spec"
}
}
var connect = require('..')
, app = connect();
app.use(function(req, res, next){
if ('/hello' == req.url) {
res.setHeader('Content-Length', 5);
res.end('Hello');
} else {
next();
}
});
var n = 9;
while (n--) {
app.use(function(req, res, next){
next();
});
}
app.use(function(req, res, next){
if ('/10' == req.url) {
res.setHeader('Content-Length', 5);
res.end('Hello');
} else {
next();
}
});
// NOTE: you would never really have this many
// but it helps show the dispatcher perf
var n = 29;
while (n--) {
app.use(function(req, res, next){
next();
});
}
app.use(function(req, res, next){
if ('/40' == req.url) {
res.setHeader('Content-Length', 5);
res.end('Hello');
} else {
next();
}
});
app.listen(8000);
\ No newline at end of file
#!/usr/bin/env bash
node ./support/app &
pid=$!
bench() {
ab -n 5000 -c 50 -k -q http://127.0.0.1:8000$1 \
| grep "Requests per" \
| cut -d ' ' -f 7 \
| xargs echo "$2:"
}
sleep .5
bench /hello "Hello World"
bench /10 "10 Middleware"
bench /40 "40 Middleware"
kill -9 $pid
\ No newline at end of file
var connect = require('../');
process.env.NODE_ENV = 'test';
var connect = require('../')
describe('app.listen()', function(){
it('should wrap in an http.Server', function(done){
......
process.env.NODE_ENV = 'test';
var connect = require('../')
, http = require('http');
var http = require('http');
describe('app.use()', function(){
var app;
......
var connect = require('../');
process.env.NODE_ENV = 'test';
var connect = require('../')
describe('app', function(){
it('should inherit from event emitter', function(done){
......
process.env.NODE_ENV = 'test';
/**
* Module dependencies.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment