Browse files

rewrite of meta-modular

  • Loading branch information...
0 parents commit de9eff2c6db11e07745c9244346ff22f1b9c4f25 @dominictarr committed Mar 29, 2011
42 app.js
@@ -0,0 +1,42 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express');
+
+var app = module.exports = express.createServer();
+
+// Configuration
+
+app.configure(function(){
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ app.use(express.errorHandler());
+});
+
+// Routes
+
+app.get('/', function(req, res){
+ res.render('index', {
+ title: 'Express'
+ });
+});
+
+// Only listen on $ node app.js
+
+if (!module.parent) {
+ app.listen(3000);
+ console.log("Express server listening on port %d", app.address().port);
+}
271 model/index.js
@@ -0,0 +1,271 @@
+var cradle = require('cradle')
+ , ctrl = require('ctrlflow')
+ , Trial = require('./trial')
+ , curry = require('curry')
+ /*
+
+ options
+ name
+ host
+ port
+ clobber
+
+ save
+ list of items to save, starting the database (i.e, views)
+ */
+
+exports.connection = function (opts){
+
+ opts = 'string' === typeof opts ? {name: opts} : opts
+
+ if(!opts.name)
+ throw new Error("need a database name")
+
+ var c =
+ new(cradle.Connection)(opts.host || 'http://localhost', opts.port || 5984, {
+ cache: true,
+ raw: false
+ });
+
+ return c.database(opts.name)
+}
+
+exports.views = [
+ { _id: '_design/platforms'
+ , views: {
+ 'new': {
+ map: function(doc) {
+ if(doc.type == 'platform' && !doc.rolledout)
+ emit(doc._id, doc);
+ }
+ },
+ 'all': {
+ map: function(doc) {
+ if(doc.type == 'platform' && doc.rolledout)
+ emit(doc._id, doc);
+ }
+ }
+ }
+ },
+ { _id: '_design/tests'
+ , views: {
+ 'new': {
+ map: function(doc) {
+ if(doc.type == 'test' && !doc.rolledout)
+ emit(doc._id, doc);
+ }
+ },
+ 'all': {
+ map: function(doc) {
+ if(doc.type == 'test' && doc.rolledout)
+ emit(doc._id, doc);
+ }
+ }
+ }
+ },
+ { _id: '_design/trials'
+ , views: {
+ init: {
+ map: function(doc) {
+ if('trial' === doc.type && 'init' === doc.status)
+ emit(null, doc);
+ }
+ },
+ results: {
+ map: function(doc) {
+ if('trial' === doc.type && 'completed' === doc.status){
+ var status = doc.report ? doc.report.status : doc.status
+ emit(status,
+ { filename: doc.filename
+ , platform: doc.platform + '-' + doc.version
+ , status: status} );
+ }
+ }
+ }
+ }
+ },
+ { _id: '_design/packages'
+ , views: {
+ all: {
+ map: function(doc) {
+ if('package' === doc.type)
+ emit(doc.name, doc);
+ }
+
+ },
+ trials: {
+ map: function(doc) {
+ if('trial' === doc.type && doc.report && doc.report.meta && doc.report.meta.simpleDeps){
+ doc.report.meta.simpleDeps.forEach(function (pack){
+ emit(pack, {
+ test: doc.test
+ , filename: doc.filename
+ , status: doc.report.status
+ , platform: doc.platform + '-' + doc.version
+ })
+ })
+ }
+ }
+ },
+ tests: {
+ map: function(doc) {
+ var emitted = false
+ if('trial' === doc.type && doc.report && doc.report.meta && doc.report.meta.depends){
+ doc.report.meta.depends.reverse().forEach(function (dep){
+ if(dep.isTest && !emitted){
+ emit(dep.package.name + '@' + dep.package.version,{
+ test: doc.test
+ , filename: doc.filename
+ , platform: doc.platform + '-' + doc.version
+ })
+ emitted = true
+ }
+ })
+ }
+ },
+ reduce: function (key,values){
+ var seen = {}
+ , found = []
+ values.forEach(function (v,k){
+ if(!seen[v.test]){
+ seen[v.test] = true
+ found.push({filename:v.filename, test:v.test})
+ }
+ })
+ return found
+ }
+ }
+ }
+ }
+]
+exports.initialize = function (db,cb){
+ ctrl.seq([
+ curry(db.create,db)
+ , curry([exports.views],db.save,db)
+ , function (){process.nextTick(cb)}
+ ]).onError(cb).go()
+// db.create(cb)
+}
+exports.clean = function (db,cb){
+ db.destroy(function (e){
+ exports.initialize (db,cb)
+ })
+}
+
+exports.rollout = function (db,done){
+ var g = ctrl.group()
+ done = [].pop.call(arguments)
+
+ db.view('platforms/new',g())
+ db.view('platforms/all',g())
+ db.view('tests/new',g())
+ db.view('tests/all',g())
+
+ function ex (data){
+ console.log(data)
+ return data.rows.map(function (e){
+ e.value.rolledout = true
+ return e.value
+ })
+ }
+
+ g.done(function (err,data){
+ var platforms = {
+ new:ex(data[0][1])
+ , all:ex(data[1][1])
+ }
+ , tests = {
+ new:ex(data[2][1])
+ , all:ex(data[3][1])
+ }
+ var trials =
+ Trial.generate(tests.new,platforms.all)
+ .concat(Trial.generate(tests.all,platforms.new))
+ .concat(Trial.generate(tests.new,platforms.new))
+ var g = ctrl.group()
+
+ db.save(trials,function (){
+ db.save(platforms.new,g())
+ db.save(tests.new,g())
+ })
+
+ g.done(function (err,res){
+ done(err,trials.length)
+ })
+ })
+ }
+
+
+/*module.exports =
+function init(_obj){
+ var obj =
+ { models: {
+ trials: [
+ { _id: '_design/views'
+ , views: {
+ init: {
+ map: function(doc) {
+ if(doc.status == 'init')
+ emit(null, doc);
+ }
+ },
+ results: {
+ map: function(doc) {
+ if(doc.status != 'init'){
+ var status = doc.report ? doc.report.status : doc.status
+ emit(status,
+ { filename: doc.filename
+ , platform: doc.platform + '-' + doc.version
+ , status: status} );
+ }
+ }
+ }
+ }
+ }
+ ],
+ modules: [
+ { _id: '_design/platforms'
+ , views: {
+ 'new': {
+ map: function(doc) {
+ if(doc.type == 'platform' && !doc.rolledout)
+ emit(doc._id, doc);
+ }
+ },
+ 'all': {
+ map: function(doc) {
+ if(doc.type == 'platform' && doc.rolledout)
+ emit(doc._id, doc);
+ }
+ }
+ }
+ },
+ { _id: '_design/tests'
+ , views: {
+ 'new': {
+ map: function(doc) {
+ if(doc.type == 'test' && !doc.rolledout)
+ emit(doc._id, doc);
+ }
+ },
+ 'all': {
+ map: function(doc) {
+ if(doc.type == 'test' && doc.rolledout)
+ emit(doc._id, doc);
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+
+ obj.host = _obj.host
+ obj.port = _obj.port
+ obj.prefix = _obj.prefix || ''
+
+ var model = odm(obj)
+
+
+ return model
+}*/
15 model/platform.js
@@ -0,0 +1,15 @@
+
+var platform = require('meta-test/platform')
+
+exports.all = function (){
+ return platform.list.map(function (e){
+ var body =
+ { _id: 'node-' + e
+ , platform: 'node'
+ , version: e
+ , command: platform.command(e)
+ , type: 'platform'
+ }
+ return body
+ })
+}
19 model/test.js
@@ -0,0 +1,19 @@
+
+module.exports = Test
+
+var hash = require('../utils').hash
+
+function Test (filename, adapter){
+ if(!(this instanceof Test)) return new Test(filename,adapter)
+
+ var m = /^.+\.(\w+)\.\w+$/(filename)
+
+ if(!adapter && !m && !m[1])
+ throw new Error("test: " + filename + " did not specify a adapter (/testfile.[adapter].js) or call Test(filename,adapter)")
+
+ this.filename = filename
+ this.adapter = adapter || m[1]
+ this._id = hash(filename)
+ this.type = 'test'
+}
+
31 model/trial.js
@@ -0,0 +1,31 @@
+
+exports = module.exports = Trial
+
+var hash = require('../utils').hash
+ , matrix = require('matrix')({
+ cell: Trial
+ })
+
+function Trial (test, platform){
+
+ if(!(this instanceof Trial)) return new Trial (test, platform)
+
+ this.command = platform.command
+ this.version = platform.version
+ this.platform = platform.platform
+ this.filename = test.filename
+ this.adapter = test.adapter
+ this.status = 'init'
+ this._id = hash(JSON.stringify({filename: test.filename, platform: platform._id}))
+ this.test = test._id
+ this.type = 'trial'
+
+}
+
+Trial.generate = function (tests,platforms){
+
+ return matrix.product(tests,platforms)
+
+}
+
+
70 package-inspector.js
@@ -0,0 +1,70 @@
+//package-inspector.js
+
+var async = require('async')
+ , fs = require('fs')
+ , path = require('path')
+
+var find = exports.find = function (filename,cb){
+ var files = filename.split('/')
+ var found = false
+ async.whilst(
+ function test(){
+ return !found && files.length
+ },
+ function doit(next){
+ files.pop()
+ var tryPackage = [].concat(files).concat('package.json').join('/')
+
+ fs.stat(tryPackage, function (err,stat){
+ if(!err)
+ found = tryPackage
+ next()
+ })
+ },
+ function done(err){
+ if(found)
+ fs.readFile(found,function (err,data){
+ var json
+ try{
+ json = JSON.parse('' + data)
+ } catch (err2){
+ cb(err || err2)
+ }
+ cb(err,json,found)
+ })
+ else cb(err || new Error('no package.json relative to:' + filename + ' was found'))
+ })
+ //find the package.json for filename
+ //first, remove
+}
+
+
+exports.processDeps = function (deps,cb){
+ var simple = []
+ var packages = {}
+ async.forEach(deps,
+ function (e,next){
+ find(e.filename,function (err,pack,filename){
+
+ var dir = path.dirname(filename)
+ var local = e.filename.replace(dir,'')
+
+ console.log(local)
+
+ e.package = {
+ name: pack.name
+ , version: pack.version
+ }
+ e.isTest = !!/^\/?tests?|specs?\/.*?/(local)
+
+ var at = pack.name + '@' + pack.version
+ if(!packages[at])
+ packages[at] = pack
+
+ next(err)
+ })
+ },
+ function (err){
+ cb(err,deps,packages)
+ })
+}
15 package.json
@@ -0,0 +1,15 @@
+{
+ "name": "meta-modular",
+ "description": "test management sytem for nodejs",
+ "version": "0.0.0",
+ "repository": {
+ "url": ""
+ },
+ "author": "Dominic Tarr <dominic.tarr@gmail.com>",
+ "directories": {
+ "lib": "."
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ }
+}
8 public/stylesheets/style.css
@@ -0,0 +1,8 @@
+body {
+ padding: 50px;
+ font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+a {
+ color: #00B7FF;
+}
122 runner.js
@@ -0,0 +1,122 @@
+
+var EventEmitter = require ('events').EventEmitter
+ , metatest = require('meta-test/runner')
+ , _ = require('underscore')
+ , pi = require('./package-inspector')
+ , ctrl = require('ctrlflow')
+
+module.exports = Runner
+
+Runner.prototype = new EventEmitter
+function Runner (db){
+ var self = this
+ , timeout
+ self.running = false
+
+ self.start = function (){
+ console.log("START")
+
+ self.running = true
+
+ self.loop()
+ }
+
+ self.stop = function (){
+ self.running = false
+ clearTimeout(timeout)
+ }
+
+ self.run = function (doc,done){
+ doc.status = 'started'
+/*
+ ctrl.seq([
+ function (next){//register that the test has started.
+ console.log("!")
+ db.save(doc,next)
+
+ }, function (err,__doc){//start test
+
+ var next = [].pop.call(arguments)
+ if(err)
+ throw err
+ doc._rev = _doc._rev
+
+ self.emit('started',null,doc)
+ metatest.run(doc,next)
+
+ }, function (err,report,next){//process test results
+
+ var next = [].pop.call(arguments)
+ doc.report = report
+ doc.status = 'completed'
+ pi.processDeps(doc.report.meta.depends,next)
+
+ }, function (err,deps,packages){//save test results
+
+ var next = [].pop.call(arguments)
+
+ db.save(_.values(packages).map(function (e){
+ e._id = e.name + '@' + e.version
+ e.type = 'package'
+ return e
+ }),console.log)
+
+ doc.report.meta.simpleDeps = Object.keys(packages)
+ db.save(doc,next)
+
+ }, function (err){//
+ var next = [].pop.call(arguments)
+ self.emit('completed',null,doc)
+ return process.nextTick(done)
+
+ }]).onError(function (){setTimeout(done,100)}).go()
+ //*/
+
+ db.save(doc,function (err,_doc){
+ if(err)//if another runner has started this already.
+ return timeout = setTimeout(done,100)
+
+ doc._rev = _doc._rev
+
+ self.emit('started',null,doc)
+
+ metatest.run(doc,function (err,report){
+ doc.report = report
+ doc.status = 'completed'
+ pi.processDeps(doc.report.meta.depends,function (err,deps,packages){
+
+ db.save(_.values(packages).map(function (e){
+ e._id = e.name + '@' + e.version
+ e.type = 'package'
+ return e
+ }),console.log)
+
+ doc.report.meta.simpleDeps = Object.keys(packages)
+
+ db.save(doc,function (err){
+ self.emit('completed',null,doc)
+ return process.nextTick(done)
+ })
+ })
+ })
+ })
+ //*/
+ }
+
+ self.loop = function (){
+ db.view('trials/init', {limit: 1}, function (err,data){
+ if(!self.running)
+ return
+
+ if(!data.length){
+ self.emit('drain')
+ timeout = setTimeout(self.loop,1e3)
+ }
+ else {
+
+ var doc = data[0].value
+ self.run(doc,self.loop)
+ }
+ })
+ }
+}
21 test/app.asynct.js
@@ -0,0 +1,21 @@
+
+// Run $ expresso
+
+/**
+ * Module dependencies.
+ */
+
+var app = require('../app')
+ , assert = require('assert');
+
+
+module.exports = {
+ 'GET /': function(){
+ assert.response(app,
+ { url: '/' },
+ { status: 200, headers: { 'Content-Type': 'text/html; charset=utf-8' }},
+ function(res){
+ assert.includes(res.body, '<title>Express</title>');
+ });
+ }
+};
2 test/examples/error.node.js
@@ -0,0 +1,2 @@
+console.log('error')
+throw new Error('INTENSIONAL ERROR')
3 test/examples/fail.node.js
@@ -0,0 +1,3 @@
+console.log('fail')
+
+require('assert').ok(false,'INTENSIONAL FAIL')
4 test/examples/fail.synct.js
@@ -0,0 +1,4 @@
+console.log('error')
+exports ['test'] = function (){
+ require('assert').ok(false,'INTENSIONAL FAIL')
+}
1 test/examples/pass.node.js
@@ -0,0 +1 @@
+console.log('pass')
115 test/model.asynct.js
@@ -0,0 +1,115 @@
+
+
+var model = require('../model')
+ , it = require('it-is')
+ , Platform = require('../model/platform')
+ , Test = require('../model/test')
+ , db = model.connection('test1')
+ , ctrl = require('ctrlflow')
+ , curry = require('curry')
+ , mm = 'mm'
+ , tests = [
+ new Test(mm + '/test/examples/simple.node.js')
+ , new Test(mm + '/test/examples/simple2.node.js')
+ , new Test(mm + '/test/examples/simple3.node.js')
+ ]
+ , platforms = Platform.all().filter(function (e){
+ return -1 != ['v0.2.6','v0.3.2','v0.4.2'].indexOf(e.version)
+ })
+
+/*
+ initialize database:
+
+ load views, save platforms,
+
+ for the test, save
+
+*/
+
+exports.__setup = function (test){
+
+ model.clean(db,test.done)
+}
+
+exports['inialize -> exists'] = function (test){
+
+ db.exists(function (err,exists){
+ it(err).ifError()
+ it(exists).ok()
+ test.done()
+ })
+}
+
+exports['save platforms'] = function (test){
+ var plats = platforms
+ ctrl.seq([
+ curry([plats],db.save,db),
+ function (err,saved,next){
+ it(err).ifError()
+ db.view('platforms/new',next)
+ },
+ function newPlatform(err,data,next){
+ it(err).equal(null)
+ it(data).property('total_rows',plats.length)
+ it(data.rows.map(function (e){
+ return e.value
+ })).has(plats)
+ test.done()
+ }
+ ]).go()
+}
+
+function compare (x,y,sorter){
+
+ function sort(x,y){
+ return x[sorter] < y[sorter]
+ ? 1
+ : (x[sorter] > y[sorter]
+ ? -1
+ : 0 )
+ }
+
+ it(x.sort(sort)).has(y.sort(sort))
+
+}
+
+exports['save tests'] = function (test){
+ ctrl.seq([
+ curry([tests],db.save,db),
+ function (err,saved,next){
+ it(err).ifError()
+ db.view('tests/new',next)
+ },
+ function (err,data,next){
+ it(err).equal(null)
+ it(data).property('total_rows',tests.length)
+
+ var items = data.rows.map(function (e){
+ return e.value
+ })
+ compare(items,tests,'filename')
+ test.done()
+ }
+ ]).go()
+}
+
+exports ['rollout!'] = function (test){
+ ctrl.seq([
+ curry([db], model.rollout)
+ , function (err,count,next){
+ db.view('trials/init', next)
+ }
+ , function (err,data){
+ it(err).equal(null)
+
+ console.log(data)
+
+ it(data).property('total_rows',tests.length * platforms.length)
+ test.done()
+ }]).onError(test.error).go()
+}
+
+/*
+can't run tests because these are
+
+*/
36 test/model.platform.synct.js
@@ -0,0 +1,36 @@
+
+var Platform= require ('../model/platform')
+ , it = require('it-is')
+ , hash = require('../utils').hash
+
+ , platformAPI = function (e){
+ it(e._id).equal(e.platform + '-' + e.version)
+ it(e).has({
+ command: it.typeof('string')
+ , type: 'platform'
+ })
+ }
+
+exports ['check platforms'] = function (){
+
+ var p = Platform.all()
+
+ console.log(p)
+
+ it(p).every(platformAPI)
+}
+
+/*
+exports ['create a new test & detect adapter'] = function (){
+
+ var t = new Test('/path/test.vows.js')
+
+ it(t).has({
+ adapter: 'vows'
+ , filename: '/path/test.vows.js'
+ , _id: it.equal(hash('/path/test.vows.js'))
+ , type: 'test'
+ })
+
+}
+*/
29 test/model.test.synct.js
@@ -0,0 +1,29 @@
+
+var Test = require ('../model/test')
+ , it = require('it-is')
+ , hash = require('../utils').hash
+
+exports ['create a new test'] = function (){
+
+ var t = new Test('/path/test.js','node')
+
+ it(t).has({
+ adapter: 'node'
+ , filename: '/path/test.js'
+ , _id: it.equal(hash('/path/test.js'))
+ , type: 'test'
+ })
+}
+
+exports ['create a new test & detect adapter'] = function (){
+
+ var t = new Test('/path/test.vows.js')
+
+ it(t).has({
+ adapter: 'vows'
+ , filename: '/path/test.vows.js'
+ , _id: it.equal(hash('/path/test.vows.js'))
+ , type: 'test'
+ })
+
+}
79 test/model.trial.synct.js
@@ -0,0 +1,79 @@
+
+var Trial = require ('../model/trial')
+ , Test = require('../model/test')
+ , Platform = require('../model/platform')
+ , it = require('it-is')
+ , hash = require('../utils').hash
+
+ , platformAPI = function (e){
+ it(e._id).equal(e.platform + '-' + e.version)
+ it(e).has({
+ command: it.typeof('string')
+ , type: 'platform'
+ })
+ }
+
+ var trialAPI = function (e,test,platform){
+
+
+ it(e).has({
+ filename: it.typeof('string')
+ , adapter: it.matches(/node|expresso|asynct|synct|vows|nodeunit/)
+ , platform: it.typeof('string')
+ , command: it.typeof('string')
+ , version: it.typeof('string')
+ , status: it.matches(/init|complete/)
+ , type: 'trial'
+ })
+
+ if(test){
+
+ it(e).has({
+ filename: test.filename
+ , adapter: test.adapter
+ , test: test._id
+ })
+
+ }
+
+ if(platform){
+
+ it(e).has({
+ platform: platform.platform
+ , command: platform.command
+ , version: platform.version
+ })
+
+ }
+
+ if(platform && test){
+
+ it(e).property('_id',hash(JSON.stringify({filename: test.filename, platform: platform._id})))
+
+ }
+
+}
+exports ['create a trial'] = function (){
+
+ var test = new Test('/path/test.expresso.js')
+ , plat = Platform.all()[0]
+ , r = new Trial (test,plat)
+
+ trialAPI(r,test,plat)
+}
+
+exports ['generate trials for every version'] = function (){
+
+ var tests = [
+ new Test('/path/test.expresso.js')
+ , new Test('/path/test.vows.js')
+ , new Test('/path/test.asynct.js')
+ ]
+ , platforms = Platform.all()
+
+ it(Trial.generate(tests,platforms))
+ .property('length', 3 * platforms.length)
+ .every(trialAPI)
+
+}
+
71 test/package-inspector.asynct.js
@@ -0,0 +1,71 @@
+
+var pi = require('../package-inspector')
+ , join = require('path').join
+ , read = require('fs').readFileSync
+ , it = require('it-is')
+
+exports ['find package.json'] = function (test){
+ var _filename = join(__dirname,'../package.json')
+ var _pack = JSON.parse(read(_filename))
+
+ pi.find(__filename,function (err,pack,filename){
+ it(err).equal(null)
+ console.log(_pack)
+ it(filename).deepEqual(_filename)
+ it(pack).deepEqual(_pack)
+ test.done()
+ })
+}
+var exampleDeps =
+[ { filename: '/home/dominic/.node_libraries/.npm/async/0.1.8/package/lib/async.js',
+ resolves: {} },
+ { filename: '/home/dominic/.node_libraries/.npm/async/0.1.8/package/index.js',
+ resolves: { './lib/async': '/home/dominic/.node_libraries/.npm/async/0.1.8/package/lib/async.js' } },
+ { filename: '/home/dominic/dev/mm/package-inspector.js',
+ resolves: { async: '/home/dominic/.node_libraries/.npm/async/0.1.8/package/index.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/render/0.0.2/package/render.js',
+ resolves: { traverser: '/home/dominic/.node_libraries/.npm/traverser/0.0.1/package/index.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/assert.js',
+ resolves:
+ { traverser: '/home/dominic/.node_libraries/.npm/traverser/0.0.1/package/index.js',
+ render: '/home/dominic/.node_libraries/.npm/render/0.0.2/package/render.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/renderer.js',
+ resolves:
+ { render: '/home/dominic/.node_libraries/.npm/render/0.0.2/package/render.js',
+ trees: '/home/dominic/.node_libraries/.npm/trees/0.0.2/package/trees.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/styles.js',
+ resolves: { render: '/home/dominic/.node_libraries/.npm/render/0.0.2/package/render.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/it-is.js',
+ resolves:
+ { './assert': '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/assert.js',
+ './renderer': '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/renderer.js',
+ render: '/home/dominic/.node_libraries/.npm/render/0.0.2/package/render.js',
+ './styles': '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/styles.js' } },
+ { filename: '/home/dominic/dev/mm/test/package-inspector.asynct.js',
+ resolves:
+ { '../package-inspector': '/home/dominic/dev/mm/package-inspector.js',
+ 'it-is': '/home/dominic/.node_libraries/.npm/it-is/0.0.1/package/it-is.js' } },
+ { filename: '/home/dominic/.node_libraries/.npm/meta-test/0.0.3/package/loader.js',
+ resolves: { '/home/dominic/dev/mm/test/package-inspector.asynct.js': '/home/dominic/dev/mm/test/package-inspector.asynct.js' } } ]
+
+
+exports['add package info to depends'] = function (test){
+
+ pi.processDeps(exampleDeps,function (err,deps,simple){
+ it(err).equal(null)
+ it(exampleDeps).every(function (e){
+ it(e).has({
+ package: {
+ name: it.typeof('string')
+ , version: it.typeof('string')
+ }
+ , isTest: !!/\/tests?|specs?\//(e.filename)
+ })
+ })
+ console.log(simple)
+
+ console.log(exampleDeps)
+ test.done()
+ })
+
+}
107 test/runner.asynct.js
@@ -0,0 +1,107 @@
+
+
+var model = require('../model')
+ , it = require('it-is')
+ , Platform = require('../model/platform')
+ , Test = require('../model/test')
+ , db = model.connection('test1')
+ , ctrl = require('ctrlflow')
+ , curry = require('curry')
+ , Runner = require('../runner')
+ , mm = 'mm'
+ , tests = [
+ new Test(mm + '/test/examples/error.node.js')
+ , new Test(mm + '/test/examples/fail.node.js')
+ , new Test(mm + '/test/examples/pass.node.js')
+ ]
+ , platforms = Platform.all().filter(function (e){
+ return -1 != ['v0.2.6','v0.3.2','v0.4.2'].indexOf(e.version)
+ })
+
+
+exports.__setup = function (test){
+
+ ctrl.seq([
+ curry([db],model.clean)
+ , curry([platforms.concat(tests)],db.save,db)
+ , curry([db], model.rollout)
+ , test.done
+ ]).go()
+
+}
+
+
+exports ['run tests'] = function (test){
+
+ var runner = new Runner(db)
+
+ runner.on('completed',function (err,item){
+ console.log(item)
+ var test = /examples\/(\w+)\.node\.js/(item.filename)[1]
+ var map = {
+ pass: 'success'
+ , fail: 'failure'
+ , error: 'error'
+ }
+
+ it(item).has({
+ report: {status: map[test]}
+ })
+ })
+
+ runner.on('drain',function (){
+ test.done()
+ runner.stop()
+ })
+ runner.start()
+
+}
+
+exports ['check test results'] = function (test){
+
+ db.view('trials/results', function (err,data){
+ it(err).equal(null)
+ it(data.rows).every(function (e){
+ it(e.value).has({
+ filename: it.typeof('string')
+ , platform: it.typeof('string')
+ , status: it.matches(/success|failure|error/)
+ })
+
+ })
+
+ it(data).property('total_rows',tests.length * platforms.length)
+
+ test.done()
+ })
+}
+
+
+exports ['check test depends'] = function (test){
+
+ db.view('trials/results', {include_docs: true}, function (err,data){
+ it(err).equal(null)
+ it(data.rows).every(function (e){
+ it(e.doc).has({report: {meta: {depends: it.ok()}}})
+
+ var depends = e.doc.report.meta.depends
+
+ it(depends).every(
+ it.has({
+ filename : it.typeof('string')
+ , resolves : it.typeof('object')
+ , package:
+ { name : it.typeof('string')
+ , version: it.typeof('string') }
+ })
+ )
+ })
+
+ it(data).property('total_rows',tests.length * platforms.length)
+
+ test.done()
+ })
+}
+
+//*/
+
10 utils.js
@@ -0,0 +1,10 @@
+//utils.js
+
+var crypto = require('crypto')
+
+exports.hash = function (input){
+
+ var h = crypto.createHash('md5')
+ h.update(input)
+ return h.digest('hex')
+}
2 views/index.jade
@@ -0,0 +1,2 @@
+h1= title
+p Welcome to #{title}
6 views/layout.jade
@@ -0,0 +1,6 @@
+!!!
+html
+ head
+ title= title
+ link(rel='stylesheet', href='/stylesheets/style.css')
+ body!= body

0 comments on commit de9eff2

Please sign in to comment.