From 0189a44ee375c0d052806eb563fc2f59e6345c7d Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Tue, 2 Sep 2014 23:25:35 -0700 Subject: [PATCH] fleshing out testHarness --- example/unixSocket/basic/hello-client.js | 4 +- node_modules/event-pubsub/package.json | 22 +++- node_modules/node-cmd/README.md | 38 ++++++ node_modules/node-cmd/cmd.js | 31 +++++ node_modules/node-cmd/example/basic.js | 17 +++ .../node-cmd/example/example.created.file | 0 node_modules/node-cmd/package.json | 38 ++++++ testHarness/test.js | 108 ++++++++++++++++++ testHarness/tests/unix-socket-tests/client.js | 0 testHarness/tests/unix-socket-tests/server.js | 0 10 files changed, 251 insertions(+), 7 deletions(-) create mode 100644 node_modules/node-cmd/README.md create mode 100644 node_modules/node-cmd/cmd.js create mode 100644 node_modules/node-cmd/example/basic.js create mode 100644 node_modules/node-cmd/example/example.created.file create mode 100644 node_modules/node-cmd/package.json create mode 100644 testHarness/tests/unix-socket-tests/client.js create mode 100644 testHarness/tests/unix-socket-tests/server.js diff --git a/example/unixSocket/basic/hello-client.js b/example/unixSocket/basic/hello-client.js index e5b12ca..cfdb4ef 100644 --- a/example/unixSocket/basic/hello-client.js +++ b/example/unixSocket/basic/hello-client.js @@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc'); * * *************************************/ -ipc.config.id = false; +ipc.config.id = 'hello'; ipc.config.retry = 1000; ipc.connectTo( @@ -20,7 +20,7 @@ ipc.connectTo( ipc.of.world.emit( 'app.message', { - //id : ipc.config.id, + id : ipc.config.id, message : 'hello' } ) diff --git a/node_modules/event-pubsub/package.json b/node_modules/event-pubsub/package.json index 87516dc..7b04093 100644 --- a/node_modules/event-pubsub/package.json +++ b/node_modules/event-pubsub/package.json @@ -28,12 +28,24 @@ "url": "https://github.com/RIAEvangelist/event-pubsub/issues" }, "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 \n \n \n PubSub Example\n \n \n \n \n ...\n \n \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", "dist": { - "shasum": "c81c49b101cdb4892d8fa2631b443184db2de6aa" + "shasum": "c81c49b101cdb4892d8fa2631b443184db2de6aa", + "tarball": "http://registry.npmjs.org/event-pubsub/-/event-pubsub-1.0.3.tgz" }, - "_from": "event-pubsub@1.0.3", - "_resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-1.0.3.tgz" + "_from": "event-pubsub@~1.0.3", + "_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!" } diff --git a/node_modules/node-cmd/README.md b/node_modules/node-cmd/README.md new file mode 100644 index 0000000..572ac6b --- /dev/null +++ b/node_modules/node-cmd/README.md @@ -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) + } + ); + diff --git a/node_modules/node-cmd/cmd.js b/node_modules/node-cmd/cmd.js new file mode 100644 index 0000000..e1507eb --- /dev/null +++ b/node_modules/node-cmd/cmd.js @@ -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; \ No newline at end of file diff --git a/node_modules/node-cmd/example/basic.js b/node_modules/node-cmd/example/basic.js new file mode 100644 index 0000000..0381f3e --- /dev/null +++ b/node_modules/node-cmd/example/basic.js @@ -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) + } +); \ No newline at end of file diff --git a/node_modules/node-cmd/example/example.created.file b/node_modules/node-cmd/example/example.created.file new file mode 100644 index 0000000..e69de29 diff --git a/node_modules/node-cmd/package.json b/node_modules/node-cmd/package.json new file mode 100644 index 0000000..1f2213d --- /dev/null +++ b/node_modules/node-cmd/package.json @@ -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@" +} diff --git a/testHarness/test.js b/testHarness/test.js index e69de29..296e51b 100644 --- a/testHarness/test.js +++ b/testHarness/test.js @@ -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