[Pkg-javascript-commits] [sockjs-client] 61/434: Tests moved to a separate directory

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 288da4a668c99f165f7fb6c360f3681516c5be8d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue Aug 9 15:28:30 2011 +0100

    Tests moved to a separate directory
---
 .gitignore                                         |  2 +-
 bin/simple_http_server.js                          | 39 ++++++++++++++++------
 run.sh                                             |  6 ++--
 config.js.example => tests/config.js.example       |  0
 example-cursors.html => tests/example-cursors.html |  2 +-
 index.html => tests/index.html                     |  0
 tests/{ => lib}/.placeholder                       |  0
 smoke-reconnect.html => tests/smoke-reconnect.html |  2 +-
 .../smoke-throughput.html                          |  0
 {static => tests/static}/jquery.min.js             |  0
 {static => tests/static}/qunit.css                 |  0
 {static => tests/static}/qunit.min.js              |  0
 tests-qunit.html => tests/tests-qunit.html         |  6 ++--
 13 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore
index 30c72ea..2c02b79 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,4 @@ node_modules
 sockjs.min.js
 sockjs.pretty.js
 sockjs.js
-tests/*.js
+tests/lib/*.js
diff --git a/bin/simple_http_server.js b/bin/simple_http_server.js
index 349fa1d..e599772 100644
--- a/bin/simple_http_server.js
+++ b/bin/simple_http_server.js
@@ -4,10 +4,7 @@ var fs = require('fs');
 var path = require('path');
 var compress = require('compress');
 var crypto = require('crypto');
-
-
-var port = 8000;
-var host = "0.0.0.0";
+var optparse = require('optparse');
 
 var mimetypes = {
     html: 'text/html',
@@ -28,8 +25,6 @@ var md5_hex = function (data) {
 
 var compressable_ct = ['text', 'application'];
 
-var cacheable = true;
-
 var req_fin = function(statusCode, req, res, content, encoding) {
     var gz = '';
     if (!encoding) encoding = 'utf-8';
@@ -51,7 +46,7 @@ var req_fin = function(statusCode, req, res, content, encoding) {
         res.setHeader('Vary', 'Accept-Encoding');
     }
 
-    if (cacheable) {
+    if (options.cacheable) {
         var cache_for = 365 * 24 * 60 * 60; // one year.
         // See: http://code.google.com/speed/page-speed/docs/caching.html
         res.setHeader('Cache-Control', 'public, max-age=' + cache_for);
@@ -92,7 +87,8 @@ var fs_decorator = function(req, res, cb) {
     };
 };
 var handler = function(req, res) {
-    var filename = url.parse(req.url).pathname.slice(1) || 'index.html';
+    var filename = options.topdir + '/';
+    filename += url.parse(req.url).pathname.slice(1) || 'index.html';
     var cb1, cb2;
     cb1 = function(stats) {
         var last_modified = stats.mtime.toGMTString();
@@ -100,7 +96,9 @@ var handler = function(req, res) {
             req_fin(304, req, res);
             return;
         }
-        // res.setHeader('Last-Modified', last_modified);
+        if (!options.cacheable) {
+            res.setHeader('Last-Modified', last_modified);
+        }
         fs.readFile(filename, fs_decorator(req, res, cb2));
     };
     cb2 = function (content) {
@@ -118,7 +116,26 @@ var handler = function(req, res) {
     fs.stat(filename, fs_decorator(req, res, cb1));
 };
 
-console.log(" [*] Listening on", host + ':' + port);
+var switches = [
+    ['-p', '--port PORT', 'Port to listen on (default: 8080)'],
+    ['-h', '--host HOST', 'Ip address to bind to (default: 0.0.0.0)'],
+    ['-d', '--dir DIR', 'Directory from which to serve files (default: .)']
+];
+
+var options = {port:8000, host:'0.0.0.0', topdir:'.', cacheable:false};
+var parser = new optparse.OptionParser(switches)
+parser.on('port', function(_,v) {
+              options.port = Number(v);
+          });
+parser.on('host', function (_,v) {
+              options.host = v;
+          });
+parser.on('dir', function (_,v) {
+              options.topdir = v;
+          });
+parser.parse(process.ARGV.slice(2));
+
+console.log(" [*] Listening on", options.host + ':' + options.port, ' serving directory:', options.topdir);
 var server = http.createServer();
 server.addListener('request', handler);
-server.listen(port, host);
+server.listen(options.port, options.host);
diff --git a/run.sh b/run.sh
index e6713e1..2d6e8b7 100755
--- a/run.sh
+++ b/run.sh
@@ -6,11 +6,11 @@ fi
 
 while [ 1 ]; do
     echo " [*] Generating javascript"
-    coffee -o tests/ -c --bare tests-src/*.coffee && \
-        coffee bin/render.coffee lib/all.js > sockjs.js && \
+    coffee -o tests/lib/ -c --bare tests-src/*.coffee && \
+        coffee bin/render.coffee lib/all.js > tests/lib/sockjs.js && \
     while [ 1 ]; do
         echo " [*] Running http server"
-        node bin/simple_http_server.js &
+        node bin/simple_http_server.js --dir tests &
         SRVPID=$!
         echo $SRVPID > .pidfile.pid
 
diff --git a/config.js.example b/tests/config.js.example
similarity index 100%
rename from config.js.example
rename to tests/config.js.example
diff --git a/example-cursors.html b/tests/example-cursors.html
similarity index 97%
rename from example-cursors.html
rename to tests/example-cursors.html
index 92612ce..0b5bf87 100644
--- a/example-cursors.html
+++ b/tests/example-cursors.html
@@ -6,7 +6,7 @@
 
   <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
 
-  <script type="text/javascript" src="sockjs.js"></script>
+  <script type="text/javascript" src="lib/sockjs.js"></script>
   <script type="text/javascript" src="static/jquery.min.js"></script>
 
   <script type="text/javascript" src="config.js"></script>
diff --git a/index.html b/tests/index.html
similarity index 100%
rename from index.html
rename to tests/index.html
diff --git a/tests/.placeholder b/tests/lib/.placeholder
similarity index 100%
rename from tests/.placeholder
rename to tests/lib/.placeholder
diff --git a/smoke-reconnect.html b/tests/smoke-reconnect.html
similarity index 97%
rename from smoke-reconnect.html
rename to tests/smoke-reconnect.html
index b07f4b5..efe5ea5 100644
--- a/smoke-reconnect.html
+++ b/tests/smoke-reconnect.html
@@ -6,7 +6,7 @@
 
   <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
 
-  <script type="text/javascript" src="sockjs.js"></script>
+  <script type="text/javascript" src="lib/sockjs.js"></script>
   <script type="text/javascript" src="static/jquery.min.js"></script>
 
   <script type="text/javascript" src="config.js"></script>
diff --git a/smoke-throughput.html b/tests/smoke-throughput.html
similarity index 100%
rename from smoke-throughput.html
rename to tests/smoke-throughput.html
diff --git a/static/jquery.min.js b/tests/static/jquery.min.js
similarity index 100%
rename from static/jquery.min.js
rename to tests/static/jquery.min.js
diff --git a/static/qunit.css b/tests/static/qunit.css
similarity index 100%
rename from static/qunit.css
rename to tests/static/qunit.css
diff --git a/static/qunit.min.js b/tests/static/qunit.min.js
similarity index 100%
rename from static/qunit.min.js
rename to tests/static/qunit.min.js
diff --git a/tests-qunit.html b/tests/tests-qunit.html
similarity index 87%
rename from tests-qunit.html
rename to tests/tests-qunit.html
index da1e3af..48899fa 100644
--- a/tests-qunit.html
+++ b/tests/tests-qunit.html
@@ -6,7 +6,7 @@
 
   <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
 
-  <script type="text/javascript" src="sockjs.js"></script>
+  <script type="text/javascript" src="lib/sockjs.js"></script>
 
   <script type="text/javascript" src="static/jquery.min.js"></script>
 
@@ -14,8 +14,8 @@
   <script type="text/javascript" src="static/qunit.min.js"></script>
 
   <script type="text/javascript" src="config.js"></script>
-  <script type="text/javascript" src="tests/test-factory.js"></script>
-  <script type="text/javascript" src="tests/test-run.js"></script>
+  <script type="text/javascript" src="lib/test-factory.js"></script>
+  <script type="text/javascript" src="lib/test-run.js"></script>
 </head>
 <body>
   <p>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list