-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes a persistently troublesome failing test by splitting it out into multiple parallel tests. Reviewed By: Evan Lucas <evanlucas@me.com> Reviewed By: Trevor Norris <trev.norris@gmail.com> Reviewed By: James M Snell <jasnell@gmail.com> PR-URL: #3287
- Loading branch information
Showing
5 changed files
with
119 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
// v8 fails silently if string length > v8::String::kMaxLength | ||
// v8::String::kMaxLength defined in v8.h | ||
const kStringMaxLength = process.binding('buffer').kStringMaxLength; | ||
|
||
try { | ||
new Buffer(kStringMaxLength * 3); | ||
} catch(e) { | ||
assert.equal(e.message, 'Invalid array buffer length'); | ||
console.log( | ||
'1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
return; | ||
} | ||
|
||
const buf = new Buffer(kStringMaxLength); | ||
|
||
const maxString = buf.toString('binary'); | ||
assert.equal(maxString.length, kStringMaxLength); |
52 changes: 52 additions & 0 deletions
52
test/parallel/test-stringbytes-external-exceed-max-by-1.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
// v8 fails silently if string length > v8::String::kMaxLength | ||
// v8::String::kMaxLength defined in v8.h | ||
const kStringMaxLength = process.binding('buffer').kStringMaxLength; | ||
|
||
try { | ||
new Buffer(kStringMaxLength * 3); | ||
} catch(e) { | ||
assert.equal(e.message, 'Invalid array buffer length'); | ||
console.log( | ||
'1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
return; | ||
} | ||
|
||
const buf1 = new Buffer(kStringMaxLength + 1); | ||
|
||
assert.throws(function() { | ||
buf1.toString(); | ||
}, /toString failed|Invalid array buffer length/); | ||
|
||
assert.throws(function() { | ||
buf1.toString('ascii'); | ||
}, /toString failed/); | ||
|
||
assert.throws(function() { | ||
buf1.toString('utf8'); | ||
}, /toString failed/); | ||
|
||
assert.throws(function() { | ||
buf1.toString('binary'); | ||
}, /toString failed/); | ||
|
||
assert.throws(function() { | ||
buf1.toString('base64'); | ||
}, /toString failed/); | ||
|
||
assert.throws(function() { | ||
buf1.toString('hex'); | ||
}, /toString failed/); | ||
|
||
var maxString = buf1.toString('binary', 1); | ||
assert.equal(maxString.length, kStringMaxLength); | ||
maxString = undefined; | ||
|
||
maxString = buf1.toString('binary', 0, kStringMaxLength); | ||
assert.equal(maxString.length, kStringMaxLength); | ||
// Free the memory early instead of at the end of the next assignment | ||
maxString = undefined; |
22 changes: 22 additions & 0 deletions
22
test/parallel/test-stringbytes-external-exceed-max-by-2.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
// v8 fails silently if string length > v8::String::kMaxLength | ||
// v8::String::kMaxLength defined in v8.h | ||
const kStringMaxLength = process.binding('buffer').kStringMaxLength; | ||
|
||
try { | ||
new Buffer(kStringMaxLength * 3); | ||
} catch(e) { | ||
assert.equal(e.message, 'Invalid array buffer length'); | ||
console.log( | ||
'1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
return; | ||
} | ||
|
||
const buf2 = new Buffer(kStringMaxLength + 2); | ||
|
||
const maxString = buf2.toString('utf16le'); | ||
assert.equal(maxString.length, (kStringMaxLength + 2) / 2); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
// v8 fails silently if string length > v8::String::kMaxLength | ||
// v8::String::kMaxLength defined in v8.h | ||
const kStringMaxLength = process.binding('buffer').kStringMaxLength; | ||
|
||
try { | ||
new Buffer(kStringMaxLength * 3); | ||
} catch(e) { | ||
assert.equal(e.message, 'Invalid array buffer length'); | ||
console.log( | ||
'1..0 # Skipped: intensive toString tests due to memory confinements'); | ||
return; | ||
} | ||
|
||
const buf0 = new Buffer(kStringMaxLength * 2 + 2); | ||
|
||
assert.throws(function() { | ||
buf0.toString('utf16le'); | ||
}, /toString failed/); |
This file contains 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