Skip to content

Commit

Permalink
add passthrough env variable to allow testing of native streams, also…
Browse files Browse the repository at this point in the history
… adds coverage
  • Loading branch information
calvinmetcalf committed Apr 13, 2016
1 parent f6ada39 commit a16228b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
.zuul.yml
.nyc_output
coverage
3 changes: 3 additions & 0 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module.exports['common.js'] = [

// for streams2 on node 0.11
// and dtrace in 0.10
// and coverage in all
, [
/^( for \(var x in global\) \{|function leakedGlobals\(\) \{)$/m
, ' /*<replacement>*/\n'
Expand All @@ -92,6 +93,8 @@ module.exports['common.js'] = [
+ ' knownGlobals.push(DTRACE_NET_SOCKET_READ);\n'
+ ' if (typeof DTRACE_NET_SOCKET_WRITE == \'function\')\n'
+ ' knownGlobals.push(DTRACE_NET_SOCKET_WRITE);\n'
+ ' if (global.__coverage__)\n'
+ ' knownGlobals.push(__coverage__);\n'
+ ' /*</replacement>*/\n\n$1'
]

Expand Down
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"inline-process-browser": "~2.0.1",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"string_decoder": "~0.10.x",
"unreachable-branch-transform": "~0.5.0",
"util-deprecate": "~1.0.1"
},
"devDependencies": {
"tap": "~0.2.6",
"nyc": "^6.4.0",
"tap": "~0.7.1",
"tape": "~4.5.1",
"zuul": "~3.9.0"
},
"scripts": {
"test": "tap test/parallel/*.js test/ours/*.js",
"browser": "npm run write-zuul && zuul -- test/browser.js",
"write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml"
"write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml",
"local": "zuul --local -- test/browser.js",
"cover": "nyc npm test",
"report": "nyc report --reporter=lcov"
},
"repository": {
"type": "git",
Expand All @@ -33,5 +39,14 @@
"browser": {
"util": false
},
"nyc": {
"include": ["lib/**.js"]
},
"browserify": {
"transform": [
"inline-process-browser",
"unreachable-branch-transform"
]
},
"license": "MIT"
}
6 changes: 6 additions & 0 deletions readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');

// inline-process-browser and unreachable-branch-transform make sure this is
// removed in browserify builds
if (!process.browser && process.env.READABLE_STREAM === 'disable') {
module.exports = require('stream');
}
1 change: 1 addition & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ if (global.Symbol) {
if (typeof constructor == 'function') knownGlobals.push(constructor);
if (typeof DTRACE_NET_SOCKET_READ == 'function') knownGlobals.push(DTRACE_NET_SOCKET_READ);
if (typeof DTRACE_NET_SOCKET_WRITE == 'function') knownGlobals.push(DTRACE_NET_SOCKET_WRITE);
if (global.__coverage__) knownGlobals.push(__coverage__);
/*</replacement>*/

function leakedGlobals() {
Expand Down

2 comments on commit a16228b

@Fishrock123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calvinmetcalf is this portable to 1.x, in case people are still using that?

Edit: I guess 1.x's API is not like the current node api?

@calvinmetcalf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup 1.1.x and 1.0.0

Please sign in to comment.