cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drk...@apache.org
Subject git commit: adding new test runner
Date Fri, 24 Jan 2014 21:20:17 GMT
Updated Branches:
  refs/heads/master f9589fd34 -> bd0c9ff84


adding new test runner


Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/bd0c9ff8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/bd0c9ff8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/bd0c9ff8

Branch: refs/heads/master
Commit: bd0c9ff8421590d10b1c17dd45d75143cd5d40be
Parents: f9589fd
Author: David Kemp <drkemp@google.com>
Authored: Fri Jan 24 16:19:28 2014 -0500
Committer: David Kemp <drkemp@google.com>
Committed: Fri Jan 24 16:19:28 2014 -0500

----------------------------------------------------------------------
 runner/package.json  | 22 +++++++++++++++
 runner/runchrome.sh  |  5 ++++
 runner/testrunner.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/bd0c9ff8/runner/package.json
----------------------------------------------------------------------
diff --git a/runner/package.json b/runner/package.json
new file mode 100644
index 0000000..661eef6
--- /dev/null
+++ b/runner/package.json
@@ -0,0 +1,22 @@
+{
+  "name": "testrunner",
+  "version": "0.0.1",
+  "description": "continuous integration setup for Apache Cordova",
+  "author": "David Kemp <drkemp@chromium.org>",
+  "main": "testrunner.js",
+  "scripts": {
+    "start": "node testrunner.js"
+  },
+  "dependencies": {
+    "shelljs": "",
+    "path": "",
+    "http": "",
+    "optimist": ""
+  },
+  "engines": {
+    "node": ">=0.8.x"
+  },
+  "contributors":[
+    {"name":"David Kemp","email":"drkemp@chromium.org"}
+  ]
+}

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/bd0c9ff8/runner/runchrome.sh
----------------------------------------------------------------------
diff --git a/runner/runchrome.sh b/runner/runchrome.sh
new file mode 100755
index 0000000..29333ec
--- /dev/null
+++ b/runner/runchrome.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+# loads and runs the chrome-apps test
+#
+/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --load-and-launch-app=$1 
--no-startup-window
+

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/bd0c9ff8/runner/testrunner.js
----------------------------------------------------------------------
diff --git a/runner/testrunner.js b/runner/testrunner.js
new file mode 100644
index 0000000..7316145
--- /dev/null
+++ b/runner/testrunner.js
@@ -0,0 +1,71 @@
+var http = require('http');
+var path = require ('path');
+var shell = require('shelljs');
+var fs = require('fs');
+var cp = require('child_process');
+var argv = require('optimist').argv;
+var url=require('url');
+
+var logport =0;
+var logurl='http://127.0.0.1';
+var testprocess;
+
+var testpath = process.cwd();
+if(argv.path) testpath=argv.path;
+
+var cmdpath = "./runtest.sh";
+if(argv.cmd) argv.cmd;
+
+function writejson(port,cfgpath){
+  var cfgobj = {logurl:"http://127.0.0.1:"+port};
+  if(!fs.existsSync(cfgpath)) fs.mkdirSync(cfgpath);
+  fs.writeFileSync(path.join(cfgpath,'medic.json'), JSON.stringify(cfgobj));
+}
+
+function startTest(){
+  console.log("starting test "+cmdpath);
+  testprocess=cp.spawn(cmdpath);
+  if(testprocess){
+    console.log("started test: "+testprocess.pid);
+  } else {
+    console.log("failed to start test in "+testpath);
+  }
+}
+
+function endTest(){
+  console.log("ending test.");
+  server.close();
+  if(testprocess){
+    process.kill(testprocess);
+    console.log("killed test.");
+  } else {
+    console.log("cant kill test.");
+  }
+//  process.exit(0);
+}
+
+var server = http.createServer(function (req, res) {
+  if(req.method==="POST") {
+    var route=url.parse(req.url).pathname;
+    var body = '';
+    req.setEncoding('utf8');
+    req.on('data',function(chunk){body += chunk;});
+    req.on('end',function(){
+      console.log(body);
+      if(route == '/result'){
+        endTest();
+      }
+    });    
+    res.writeHead(200, {'Content-Type': 'text/plain', 'Access-Control-Allow-Origin':'*'});
+    res.end('Got that\n');
+  }
+});
+server.listen(logport, '127.0.0.1',511,function(){
+  logport = server.address().port;
+  console.log('Server running at '+logurl+':'+logport);
+  writejson(logport,testpath);
+  startTest();
+});
+
+
+


Mime
View raw message