2010-07-15 20:47:25 +02:00
|
|
|
common = require("../common");
|
2010-10-07 05:05:23 +02:00
|
|
|
assert = common.assert;
|
2009-11-01 15:34:46 +01:00
|
|
|
|
|
|
|
var http = require('http');
|
2010-10-11 23:04:09 +02:00
|
|
|
var util = require('util');
|
2010-01-05 06:07:50 +01:00
|
|
|
var url = require("url");
|
2009-11-01 15:34:46 +01:00
|
|
|
var modulesLoaded = 0;
|
|
|
|
|
|
|
|
var server = http.createServer(function(req, res) {
|
|
|
|
var body = 'exports.httpPath = function() {'+
|
2010-01-05 06:07:50 +01:00
|
|
|
'return '+JSON.stringify(url.parse(req.url).pathname)+';'+
|
2009-11-01 15:34:46 +01:00
|
|
|
'};';
|
|
|
|
|
2010-02-25 21:54:48 +01:00
|
|
|
res.writeHead(200, {'Content-Type': 'text/javascript'});
|
2010-02-17 07:16:29 +01:00
|
|
|
res.write(body);
|
2010-04-08 19:44:22 +02:00
|
|
|
res.end();
|
2009-11-01 15:34:46 +01:00
|
|
|
});
|
2010-07-15 20:47:25 +02:00
|
|
|
server.listen(common.PORT);
|
2009-11-01 15:34:46 +01:00
|
|
|
|
2010-02-19 18:37:20 +01:00
|
|
|
assert.throws(function () {
|
2010-07-15 20:47:25 +02:00
|
|
|
var httpModule = require('http://localhost:'+common.PORT+'/moduleA.js');
|
2010-02-19 18:37:20 +01:00
|
|
|
assert.equal('/moduleA.js', httpModule.httpPath());
|
|
|
|
modulesLoaded++;
|
|
|
|
});
|
2009-11-01 15:34:46 +01:00
|
|
|
|
|
|
|
var nodeBinary = process.ARGV[0];
|
2010-07-15 20:47:25 +02:00
|
|
|
var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+common.PORT+'/moduleB.js';
|
2009-11-01 15:34:46 +01:00
|
|
|
|
2010-10-11 23:04:09 +02:00
|
|
|
util.exec(cmd, function (err, stdout, stderr) {
|
2010-02-20 01:55:46 +01:00
|
|
|
if (err) throw err;
|
2010-06-24 02:40:51 +02:00
|
|
|
console.log('success!');
|
2010-02-20 01:55:46 +01:00
|
|
|
modulesLoaded++;
|
|
|
|
server.close();
|
|
|
|
});
|
2009-11-01 15:34:46 +01:00
|
|
|
|
|
|
|
process.addListener('exit', function() {
|
2010-02-19 18:37:20 +01:00
|
|
|
assert.equal(1, modulesLoaded);
|
2009-11-07 15:08:46 +01:00
|
|
|
});
|