Skip to content

Commit ae8c267

Browse files
committed
Print MaxListenersExceeded warnings as TAP comments.
1 parent c3e91f9 commit ae8c267

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

tests/check-listener-leaks.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ var common = require('./common');
2323
var assert = require('assert');
2424
var events = require('../');
2525

26+
// Redirect warning output to tape.
27+
var consoleWarn = console.warn;
28+
console.warn = common.test.comment;
29+
30+
common.test.on('end', function () {
31+
console.warn = consoleWarn;
32+
});
33+
2634
// default
2735
{
2836
var e = new events.EventEmitter();

tests/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
var test = require('tape');
22

33
require('./legacy-compat');
4+
var common = require('./common');
45

56
// we do this to easily wrap each file in a mocha test
67
// and also have browserify be able to statically analyze this file
78
var orig_require = require;
89
var require = function(file) {
910
test(file, function(t) {
11+
// Store the tape object so tests can access it.
12+
t.on('end', function () { delete common.test; });
13+
common.test = t;
14+
1015
try { orig_require(file); } catch (err) { t.fail(err); }
1116
t.end();
1217
});

0 commit comments

Comments
 (0)