Created
January 27, 2016 12:28
-
-
Save gerhardberger/5530d5f98445276709aa to your computer and use it in GitHub Desktop.
child process testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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() | |
}) | |
}) | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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()) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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