Skip to content

Instantly share code, notes, and snippets.

@gerhardberger
Created January 27, 2016 12:28
Show Gist options
  • Save gerhardberger/5530d5f98445276709aa to your computer and use it in GitHub Desktop.
Save gerhardberger/5530d5f98445276709aa to your computer and use it in GitHub Desktop.
child process testing
'use strict'
const minwhere = require('minwhere')
const test = require('tapes')
const exit = require('exit')
const cache = minwhere.resourceCache
test('Overall cache test', t => {
cache.on('ready', () => {
let url = `${__dirname}/../resources/labda.mesh`
t.pass('ready')
cache.add(url, err => {
if (err) {
t.error(err, 'added')
exit.fail()
return
}
t.pass('added')
cache.setup([ url ], err => {
if (err) {
t.error(err, 'setup')
exit.fail()
return
}
t.pass('setup')
t.end()
exit.ok()
})
})
})
})
'use strict'
const test = require('tapes')
const run = require('../../tools/utils/runner')()
test('Native', t => {
run(`${__dirname}/hello.js`, next => next())
run(`${__dirname}/objects.js`, next => t.end())
})
'use strict'
const spawn = require('child_process').spawn
const path = require('path')
module.exports = function () {
let runs = []
var first = true
return (url, cb) => {
runs.push(() => {
let mw = spawn('minwhere',[ url, '-t' ])
mw.stdout.on('data', data => console.log(data.toString()))
mw.on('close', code => cb(() => runs.shift()()))
})
if (first) {
first = false
runs.shift()()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment