summaryrefslogtreecommitdiff
path: root/js/bin/HttpServer.js
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-12-21 11:36:06 +0100
committerBenoit Foucher <benoit@zeroc.com>2016-12-21 11:36:06 +0100
commit973701c846a588d6e683b8b6b94a164dd41e92d6 (patch)
tree5b5415a35f9c42f10370632f5f79c706d9bc4a3a /js/bin/HttpServer.js
parentAdd getEngineName & getEngineVersion methods to IceSSL C++ Plugin (diff)
downloadice-973701c846a588d6e683b8b6b94a164dd41e92d6.tar.bz2
ice-973701c846a588d6e683b8b6b94a164dd41e92d6.tar.xz
ice-973701c846a588d6e683b8b6b94a164dd41e92d6.zip
Supported for automated browser testing
Diffstat (limited to 'js/bin/HttpServer.js')
-rw-r--r--js/bin/HttpServer.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/js/bin/HttpServer.js b/js/bin/HttpServer.js
index 0f1cfef2ab5..400577fef5a 100644
--- a/js/bin/HttpServer.js
+++ b/js/bin/HttpServer.js
@@ -44,6 +44,7 @@ function Init()
var TestSuites = JSON.parse(TestData.TestSuites);
TestData.tests = Object.keys(TestSuites);
var template = hogan.compile(fs.readFileSync(path.join(__dirname, "..", "test", "Common", "index.html"), "utf8"));
+ var controller = hogan.compile(fs.readFileSync(path.join(__dirname, "..", "test", "Common", "controller.html"), "utf8"));
var libraryMaps = libraries.map(
function(f)
{
@@ -58,6 +59,7 @@ function Init()
HttpServer.prototype.processRequest = function(req, res)
{
var match = req.url.pathname.match("^\/test/(.*)/index\.html");
+ var matchController = req.url.pathname.match("^\/test/(.*)/controller\.html");
if(match)
{
var es5 = match[1].indexOf("es5/") !== -1;
@@ -163,13 +165,47 @@ function Init()
}
}
}
+ else if(matchController)
+ {
+ var es5 = matchController[1].indexOf("es5/") !== -1;
+ var m = es5 ? matchController[1].replace("es5/", "") : matchController[1];
+ var testpath = path.resolve(path.join(this._basePath, "test", matchController[1]))
+ var scripts = es5 ? [
+ "/lib/es5/Ice.js",
+ "/test/es5/Common/Controller.js",
+ "/test/es5/Common/ControllerI.js",
+ ] : [
+ "/lib/Ice.js",
+ "/test/Common/Controller.js",
+ "/test/Common/ControllerI.js",
+ ];
+ var testSuite = TestSuites[m];
+ if(testSuite)
+ {
+ scripts = scripts.concat(TestSuites[m].files)
+ }
+ else
+ {
+ scripts = scripts.concat(fs.readdirSync(testpath).filter(function(f) { return path.extname(f) === ".js"; }))
+ }
+ res.writeHead(200, {"Content-Type": "text/html"});
+ res.end(controller.render({ "scripts" : scripts }))
+ console.log("HTTP/200 (Ok) " + req.method + " " + req.url.pathname);
+ }
else
{
var iceLib = libraries.indexOf(req.url.pathname) !== -1;
var iceLibMap = libraryMaps.indexOf(req.url.pathname) !== -1;
- var basePath = (process.env.USE_BIN_DIST == "yes" && (iceLib || iceLibMap)) ?
- path.resolve(path.join(require.resolve("ice"), "..", "..")) : this._basePath;
+ var basePath;
+ if(process.env.USE_BIN_DIST == "yes" && (iceLib || iceLibMap))
+ {
+ basePath = path.resolve(path.join(require.resolve("ice"), "..", ".."));
+ }
+ else
+ {
+ basePath = this._basePath;
+ }
var filePath = path.resolve(path.join(basePath, req.url.pathname));
if(filePath.indexOf("es5/") !== -1 && path.extname(filePath) != "js")