diff --git a/debug.js b/debug.js new file mode 100755 index 000000000..3561aa850 --- /dev/null +++ b/debug.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node +'use strict'; + +var onExit = require('signal-exit'); +var serializeValue = require('./lib/serialize-value'); +var chalk = require('chalk'); + +process.send = function (data) { + console.log(chalk.magenta(JSON.stringify(serializeValue(data), null, 4))); +}; + +onExit(function () { + process.emit('ava-cleanup', true); +}); + +require('./lib/babel'); diff --git a/maintaining.md b/maintaining.md index dc1778a61..a8c84b642 100644 --- a/maintaining.md +++ b/maintaining.md @@ -1,5 +1,26 @@ # Maintaining +## IPC Debugging + +AVA makes heavy use of forked processes and Node [IPC](https://nodejs.org/api/process.html#process_process_send_message_sendhandle_callback). + This can create some difficulty tracking down bugs that occur in a different process from your test code. + The script `debug.js` will launch a single test fixture without forking the process and will log the IPC messages + that would normally be sent parent process. + +```sh +$ debug.js test/fixture/async-await.js +.... +{ + "name": "test", + "data": { + "duration": 5, + "title": "async function", + "error": {}, + "type": "test" + } +} +.... +``` ## Release process