Skip to content

Commit 9a26b69

Browse files
committed
test: move long-running test to sequential
test-buffer-creation-regression is flaky on some SmartOS hosts in CI, timing out. Move to sequential so it does not compete with other tests for resources. Reduce three test cases to just the one needed to identify the regression.
1 parent 25dfb8e commit 9a26b69

File tree

2 files changed

+36
-41
lines changed

2 files changed

+36
-41
lines changed

test/parallel/test-buffer-creation-regression.js

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
6+
function test(arrayBuffer, offset, length) {
7+
const uint8Array = new Uint8Array(arrayBuffer, offset, length);
8+
for (let i = 0; i < length; i += 1) {
9+
uint8Array[i] = 1;
10+
}
11+
12+
const buffer = Buffer.from(arrayBuffer, offset, length);
13+
for (let i = 0; i < length; i += 1) {
14+
assert.strictEqual(buffer[i], 1);
15+
}
16+
}
17+
18+
const acceptableOOMErrors = [
19+
'Array buffer allocation failed',
20+
'Invalid array buffer length'
21+
];
22+
23+
const size = 8589934592; /* 1 << 33 */
24+
const offset = 4294967296; /* 1 << 32 */
25+
const length = 1000;
26+
let arrayBuffer;
27+
28+
try {
29+
arrayBuffer = new ArrayBuffer(size);
30+
} catch (e) {
31+
if (e instanceof RangeError && acceptableOOMErrors.includes(e.message))
32+
return common.skip(`Unable to allocate ${size} bytes for ArrayBuffer`);
33+
throw e;
34+
}
35+
36+
test(arrayBuffer, offset, length);

0 commit comments

Comments
 (0)