Skip to content

Commit

Permalink
test: replace internals with public API
Browse files Browse the repository at this point in the history
Remove instances where `--expose-internals` is used to gain access to
buffer.kStringMaxLength. The property is availalble without a flag. It
is undocumented but the same as the documented
`buffer.constants.MAX_STRING_LENGTH` so use that. (We even have a test
that confirms that they are the same value.)

PR-URL: #25309
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Jan 5, 2019
1 parent 2014eba commit 379260e
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 27 deletions.
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -12,7 +10,7 @@ const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,7 @@
// Flags: --expose-gc --expose-internals
// Flags: --expose-gc
'use strict';

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -12,7 +11,7 @@ const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -12,7 +10,7 @@ const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -12,7 +10,7 @@ const assert = require('assert');

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../../common');
const { internalBinding } = require('internal/test/binding');
const skipMessage = 'intensive toString tests due to memory confinements';
if (!common.enoughTestMem)
common.skip(skipMessage);
Expand All @@ -11,7 +9,7 @@ const binding = require(`./build/${common.buildType}/binding`);

// v8 fails silently if string length > v8::String::kMaxLength
// v8::String::kMaxLength defined in v8.h
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;

let buf;
try {
Expand Down
4 changes: 1 addition & 3 deletions test/sequential/test-fs-readfile-tostring-fail.js
@@ -1,8 +1,6 @@
'use strict';
// Flags: --expose-internals

const common = require('../common');
const { internalBinding } = require('internal/test/binding');

if (!common.enoughTestMem)
common.skip('intensive toString tests due to memory confinements');
Expand All @@ -11,7 +9,7 @@ const assert = require('assert');
const fs = require('fs');
const path = require('path');
const cp = require('child_process');
const kStringMaxLength = internalBinding('buffer').kStringMaxLength;
const kStringMaxLength = require('buffer').constants.MAX_STRING_LENGTH;
if (common.isAIX && (Number(cp.execSync('ulimit -f')) * 512) < kStringMaxLength)
common.skip('intensive toString tests due to file size confinements');

Expand Down

0 comments on commit 379260e

Please sign in to comment.