fleshing out testHarness
This commit is contained in:
parent
8d6bf8073f
commit
0189a44ee3
10 changed files with 251 additions and 7 deletions
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = false;
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry = 1000;
|
ipc.config.retry = 1000;
|
||||||
|
|
||||||
ipc.connectTo(
|
ipc.connectTo(
|
||||||
|
@ -20,7 +20,7 @@ ipc.connectTo(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'app.message',
|
'app.message',
|
||||||
{
|
{
|
||||||
//id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'
|
message : 'hello'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
22
node_modules/event-pubsub/package.json
generated
vendored
22
node_modules/event-pubsub/package.json
generated
vendored
|
@ -28,12 +28,24 @@
|
||||||
"url": "https://github.com/RIAEvangelist/event-pubsub/issues"
|
"url": "https://github.com/RIAEvangelist/event-pubsub/issues"
|
||||||
},
|
},
|
||||||
"homepage": "http://riaevangelist.github.io/event-pubsub/",
|
"homepage": "http://riaevangelist.github.io/event-pubsub/",
|
||||||
"readme": "Event PubSub\n============\n\nPubsub events for Node and the browser allowing event scoping and multiple scopes. \nEasy for any developer level. No frills, just high speed pubsub events!\n\n[Pretty GitHub.io site](http://riaevangelist.github.io/event-pubsub/) \n\n[![alt event-pubsub npm details](https://nodei.co/npm/event-pubsub.png?stars=true \"event-pubsub npm package details\")](https://npmjs.org/package/event-pubsub)\n\n**EXAMPLE FILES** \n\n1. [Node Pubsub Event Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/node) \n2. [Browser Pubsub Event Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/browser)\n\n**Node Install** \n``npm install event-pubsub``\n\n**Browser Install** \n*see browser examples above or below*\n\n---\n### Basic Example\n---\n***NOTE - the only diffeence between node and browser code is how the ``events`` variable is created*** \n* node ``var events = new require('../../event-pubsub.js')();``\n* browser ``var events = new window.pubsub();``\n\n#### Node\n\n var events = new require('../../event-pubsub.js')();\n\n events.on(\n 'hello',\n function(data){\n console.log('hello event recieved ', data);\n }\n );\n \n events.on(\n '*',\n function(type){\n console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments);\n }\n );\n \n events.on(\n 'removeEvents',\n function(){\n events.off('*');\n console.log('Removed all events');\n }\n );\n \n /************************************\\\n * trigger events for testing\n * **********************************/\n events.trigger(\n 'hello',\n 'world'\n );\n \n events.trigger(\n 'removeEvents'\n );\n \n\n#### Browser\n##### HTML\n\n <!DOCTYPE html>\n <html>\n <head>\n <title>PubSub Example</title>\n <script src='../../event-pubsub-browser.js'></script>\n <script src='yourAmazingCode.js'></script>\n </head>\n <body>\n ...\n </body>\n </html>\n\n##### Inside Your Amazing Code\n\n var events = new window.pubsub();\n\n events.on(\n 'hello',\n function(data){\n console.log('hello event recieved ', data);\n }\n );\n \n events.on(\n '*',\n function(type){\n console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments);\n }\n );\n \n events.on(\n 'removeEvents',\n function(){\n events.off('*');\n console.log('Removed all events');\n }\n );\n \n /************************************\\\n * trigger events for testing\n * **********************************/\n events.trigger(\n 'hello',\n 'world'\n );\n \n events.trigger(\n 'removeEvents'\n );\n",
|
|
||||||
"readmeFilename": "README.md",
|
|
||||||
"_id": "event-pubsub@1.0.3",
|
"_id": "event-pubsub@1.0.3",
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "c81c49b101cdb4892d8fa2631b443184db2de6aa"
|
"shasum": "c81c49b101cdb4892d8fa2631b443184db2de6aa",
|
||||||
|
"tarball": "http://registry.npmjs.org/event-pubsub/-/event-pubsub-1.0.3.tgz"
|
||||||
},
|
},
|
||||||
"_from": "event-pubsub@1.0.3",
|
"_from": "event-pubsub@~1.0.3",
|
||||||
"_resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-1.0.3.tgz"
|
"_npmVersion": "1.4.3",
|
||||||
|
"_npmUser": {
|
||||||
|
"name": "riaevangelist",
|
||||||
|
"email": "brandon@diginow.it"
|
||||||
|
},
|
||||||
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"name": "riaevangelist",
|
||||||
|
"email": "brandon@diginow.it"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_shasum": "c81c49b101cdb4892d8fa2631b443184db2de6aa",
|
||||||
|
"_resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-1.0.3.tgz",
|
||||||
|
"readme": "ERROR: No README data found!"
|
||||||
}
|
}
|
||||||
|
|
38
node_modules/node-cmd/README.md
generated
vendored
Normal file
38
node_modules/node-cmd/README.md
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#node-cmd
|
||||||
|
-
|
||||||
|
*Node.js commandline/terminal interface.*
|
||||||
|
|
||||||
|
Simple commandline or terminal interface to allow you to run cli or bash style commands as if you were in the terminal.
|
||||||
|
|
||||||
|
Run commands asynchronously, and if needed can get the output as a string.
|
||||||
|
|
||||||
|
#Methods
|
||||||
|
-
|
||||||
|
|
||||||
|
|method | arguments | functionality |
|
||||||
|
|-------|-----------|---------------|
|
||||||
|
|run | command | runs a command asynchronously|
|
||||||
|
|get | command,callback | runs a command asynchronously, when the command is complete all of the stdout will be passed to the callback|
|
||||||
|
|
||||||
|
|
||||||
|
#Examples
|
||||||
|
-
|
||||||
|
|
||||||
|
var cmd=require('node-cmd');
|
||||||
|
|
||||||
|
cmd.get(
|
||||||
|
'pwd',
|
||||||
|
function(data){
|
||||||
|
console.log('the current working dir is : ',data)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
cmd.run('touch example.created.file');
|
||||||
|
|
||||||
|
cmd.get(
|
||||||
|
'ls',
|
||||||
|
function(data){
|
||||||
|
console.log('the current dir contains these files :\n\n',data)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
31
node_modules/node-cmd/cmd.js
generated
vendored
Normal file
31
node_modules/node-cmd/cmd.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
var sys = require('sys'),
|
||||||
|
exec = require('child_process').exec;
|
||||||
|
|
||||||
|
var commandline={
|
||||||
|
get:getString,
|
||||||
|
run:runCommand
|
||||||
|
};
|
||||||
|
|
||||||
|
function runCommand(command){
|
||||||
|
exec(
|
||||||
|
command
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getString(command,callback){
|
||||||
|
exec(
|
||||||
|
command,
|
||||||
|
(
|
||||||
|
function(){
|
||||||
|
return function(err,data,stderr){
|
||||||
|
if(!callback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
callback(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)(callback)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports=commandline;
|
17
node_modules/node-cmd/example/basic.js
generated
vendored
Normal file
17
node_modules/node-cmd/example/basic.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
var cmd=require('../cmd.js');
|
||||||
|
|
||||||
|
cmd.get(
|
||||||
|
'pwd',
|
||||||
|
function(data){
|
||||||
|
console.log('the current working dir is : ',data)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
cmd.run('touch example.created.file');
|
||||||
|
|
||||||
|
cmd.get(
|
||||||
|
'ls',
|
||||||
|
function(data){
|
||||||
|
console.log('the current dir contains these files :\n\n',data)
|
||||||
|
}
|
||||||
|
);
|
0
node_modules/node-cmd/example/example.created.file
generated
vendored
Normal file
0
node_modules/node-cmd/example/example.created.file
generated
vendored
Normal file
38
node_modules/node-cmd/package.json
generated
vendored
Normal file
38
node_modules/node-cmd/package.json
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"name": "node-cmd",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"description": "Simple commandline/terminal interface to allow you to run cli or bash style commands as if you were in the terminal.",
|
||||||
|
"main": "cmd.js",
|
||||||
|
"directories": {
|
||||||
|
"example": "example"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/RIAEvangelist/node-cmd.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"commandline",
|
||||||
|
"terminal",
|
||||||
|
"cmd",
|
||||||
|
"cli",
|
||||||
|
"bash",
|
||||||
|
"script"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Brandon Nozaki Miller"
|
||||||
|
},
|
||||||
|
"license": "DBAD",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/RIAEvangelist/node-cmd/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/RIAEvangelist/node-cmd",
|
||||||
|
"readme": "#node-cmd\n-\n*Node.js commandline/terminal interface.* \n\nSimple commandline or terminal interface to allow you to run cli or bash style commands as if you were in the terminal.\n\nRun commands asynchronously, and if needed can get the output as a string.\n\n#Methods\n-\n\n|method | arguments | functionality |\n|-------|-----------|---------------|\n|run | command | runs a command asynchronously|\n|get | command,callback | runs a command asynchronously, when the command is complete all of the stdout will be passed to the callback|\n\n\n#Examples\n-\n\n var cmd=require('node-cmd');\n \n cmd.get(\n 'pwd',\n function(data){\n console.log('the current working dir is : ',data)\n }\n );\n \n cmd.run('touch example.created.file');\n \n cmd.get(\n 'ls',\n function(data){\n console.log('the current dir contains these files :\\n\\n',data)\n }\n );\n\n",
|
||||||
|
"readmeFilename": "README.md",
|
||||||
|
"gitHead": "a003426996e8594af31a6486cfb7d28d0a547bc9",
|
||||||
|
"_id": "node-cmd@1.0.2",
|
||||||
|
"_shasum": "89cdb50181476cdd127763d5c8514499fe3c038d",
|
||||||
|
"_from": "node-cmd@"
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
var ipc = require('../node-ipc'),
|
||||||
|
cmd = require('node-cmd'),
|
||||||
|
fs = require('fs'),
|
||||||
|
events= require('event-pubsub')(),
|
||||||
|
tests = {};
|
||||||
|
|
||||||
|
ipc.config.id = 'testHarness';
|
||||||
|
|
||||||
|
events.on(
|
||||||
|
'startFailed',
|
||||||
|
function(test){
|
||||||
|
ipc.log(test.warn," failed to start ".error)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ipc.serve(
|
||||||
|
function(){
|
||||||
|
ipc.server.on(
|
||||||
|
'pass',
|
||||||
|
function(data,socket){
|
||||||
|
ipc.log(socket.id.good);
|
||||||
|
socket
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ipc.server.on(
|
||||||
|
'fail',
|
||||||
|
function(err,socket){
|
||||||
|
ipc.log(socket.id.warn,err);
|
||||||
|
socket
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ipc.server.on(
|
||||||
|
'start',
|
||||||
|
function(data,socket){
|
||||||
|
ipc.log(socket.id.notice, 'started'.debug);
|
||||||
|
events.trigger(
|
||||||
|
'started-test-'+socket.id,
|
||||||
|
socket.id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
ipc.log('TestHarness started.'.debug, 'Loading Tests.'.notice);
|
||||||
|
|
||||||
|
fs.readdir(
|
||||||
|
'tests',
|
||||||
|
function(err,tests){
|
||||||
|
if(err){
|
||||||
|
ipc.log('You must execute the testHarness from the testHarness directory')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(var i =0; i<tests.length; i++){
|
||||||
|
tests[tests[i]]={
|
||||||
|
started : false,
|
||||||
|
pass : false,
|
||||||
|
fail : true,
|
||||||
|
delay : setTimeout(
|
||||||
|
(
|
||||||
|
function(test){
|
||||||
|
return function(){
|
||||||
|
events.trigger(
|
||||||
|
'startFailed',
|
||||||
|
test
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)(tests[i]),
|
||||||
|
1000
|
||||||
|
)
|
||||||
|
};
|
||||||
|
runTests(tests[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ipc.server.define.listen['pass']='This event should be called when a test has passed';
|
||||||
|
ipc.server.define.listen['fail']='This event should be called when a test has failed, it accepts an argument for error conditions';
|
||||||
|
|
||||||
|
ipc.server.start();
|
||||||
|
|
||||||
|
function runTests(dir){
|
||||||
|
fs.readdir(
|
||||||
|
'tests/'+dir,
|
||||||
|
function(err,tests){
|
||||||
|
if(err){
|
||||||
|
ipc.log('You must execute the testHarness from the testHarness directory')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(var i =0; i<tests.length; i++){
|
||||||
|
events.on(
|
||||||
|
'started-test-'+tests[i],
|
||||||
|
function(id){
|
||||||
|
tests[id].started=true;
|
||||||
|
clearTimeout(
|
||||||
|
tests[id].delay
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
cmd.run('node '+tests[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
0
testHarness/tests/unix-socket-tests/client.js
Normal file
0
testHarness/tests/unix-socket-tests/client.js
Normal file
0
testHarness/tests/unix-socket-tests/server.js
Normal file
0
testHarness/tests/unix-socket-tests/server.js
Normal file
Loading…
Reference in a new issue