Source: nodejs Version: 4.0.0~dfsg-2 Severity: wishlist Tags: patch
Attached is a patch to add a couple simple autopkgtests to nodejs.
diff -urpN nodejs-4.0.0~dfsg.orig/debian/control nodejs-4.0.0~dfsg/debian/control --- nodejs-4.0.0~dfsg.orig/debian/control 2015-09-09 08:10:12.000000000 -0600 +++ nodejs-4.0.0~dfsg/debian/control 2015-10-22 18:06:56.136009351 -0600 @@ -25,6 +25,7 @@ Standards-Version: 3.9.6 Homepage: http://nodejs.org/ Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/nodejs.git Vcs-Git: git://anonscm.debian.org/collab-maint/nodejs.git +Testsuite: autopkgtest Package: nodejs-dev Section: devel diff -urpN nodejs-4.0.0~dfsg.orig/debian/tests/control nodejs-4.0.0~dfsg/debian/tests/control --- nodejs-4.0.0~dfsg.orig/debian/tests/control 1969-12-31 17:00:00.000000000 -0700 +++ nodejs-4.0.0~dfsg/debian/tests/control 2015-10-22 18:21:37.044234074 -0600 @@ -0,0 +1,6 @@ +Tests: helloworld +Depends: nodejs, wget +Restrictions: isolation-container + +Test-Command: nodejs -v +Depends: nodejs diff -urpN nodejs-4.0.0~dfsg.orig/debian/tests/helloworld nodejs-4.0.0~dfsg/debian/tests/helloworld --- nodejs-4.0.0~dfsg.orig/debian/tests/helloworld 1969-12-31 17:00:00.000000000 -0700 +++ nodejs-4.0.0~dfsg/debian/tests/helloworld 2015-10-22 18:30:21.857426281 -0600 @@ -0,0 +1,47 @@ +#!/bin/sh + +set -e + +TIMEOUT=60 # in seconds +PORT=1337 + +js=$(mktemp) +cleanup() { + rm -f $js +} +trap cleanup EXIT + +# "hello world" example from: https://nodejs.org/en/about/ +cat > $js <<EOF +var http = require('http'); + +http.createServer(function (req, res) { + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end('Hello World\n'); +}).listen(${PORT}, "127.0.0.1"); + +console.log('Server running at http://127.0.0.1:${PORT}/'); +EOF + +nodejs $js & +nodepid=$! + +pass=0 +while [ -d /proc/$nodepid ]; do + pass=$((pass + 1)) + sleep 1 + + if wget -q http://127.0.0.1:${PORT}/ -O - | grep 'Hello World'; then + kill $nodepid + exit 0 + fi + if [ $pass -eq $TIMEOUT ]; then + echo "ERROR: nodejs failed to become ready in $TIMEOUT seconds" >&2 + kill $nodepid + exit 1 + fi +done + +echo "ERROR: nodejs exited unexpectedly" >&2 + +exit 1
_______________________________________________ Pkg-javascript-devel mailing list Pkg-javascript-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-javascript-devel