Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
test: fix tests after merge
Browse files Browse the repository at this point in the history
Updated the following tests:
test-cli-syntax - conditionalized error message check
test-repl-sigint-nested-eval - disabled on ChakraCore
test-querystring-escape  - conditionalized error message check
test-url-parse-invalid-input - conditionalized error message check
test-util-inspect - updated engine specific string
addons-napi/test_buffer/test - skip GC check
test-debugger-repeat-last - disabled since inspector support is missing

The first two issues are because of unimplemented features in ChakraShim.
We can fix this after the merge

PR-URL: #211
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
  • Loading branch information
digitalinfinity committed Apr 18, 2017
1 parent 361c4bb commit 481ca0e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
23 changes: 17 additions & 6 deletions test/addons-napi/test_buffer/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ assert.strictEqual(binding.newBuffer().toString(), binding.theText,
'buffer returned by newBuffer() has wrong contents');
assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText,
'buffer returned by newExternalBuffer() has wrong contents');
console.log('gc1');
global.gc();
assert.strictEqual(binding.getDeleterCallCount(), 1, 'deleter was not called');

// Don't rely on Chakra's GC to behave the same as v8's.
if (process.jsEngine !== 'chakracore') {
console.log('gc1');
global.gc();
assert.strictEqual(binding.getDeleterCallCount(), 1,
'deleter was not called');
}

assert.strictEqual(binding.copyBuffer().toString(), binding.theText,
'buffer returned by copyBuffer() has wrong contents');

Expand All @@ -20,6 +26,11 @@ assert.strictEqual(binding.bufferHasInstance(buffer), true,
'buffer type checking fails');
assert.strictEqual(binding.bufferInfo(buffer), true, 'buffer data is accurate');
buffer = null;
global.gc();
console.log('gc2');
assert.strictEqual(binding.getDeleterCallCount(), 2, 'deleter was not called');

// Don't rely on Chakra's GC to behave the same as v8's.
if (process.jsEngine !== 'chakracore') {
global.gc();
console.log('gc2');
assert.strictEqual(binding.getDeleterCallCount(), 2,
'deleter was not called');
}
2 changes: 2 additions & 0 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test-async-wrap-check-providers : PASS,FLAKY
test-buffer-fill : PASS,FLAKY
test-crypto-dh : SKIP
test-cluster-inspector-debug-port : SKIP
test-debugger-repeat-last: SKIP
test-domain-no-error-handler-abort-on-uncaught-0 : SKIP
test-domain-no-error-handler-abort-on-uncaught-1 : SKIP
test-domain-no-error-handler-abort-on-uncaught-2 : SKIP
Expand All @@ -56,6 +57,7 @@ test-repl : SKIP
test-repl-mode : SKIP
test-repl-tab-complete : SKIP
test-repl-timeout-throw : SKIP
test-repl-sigint-nested-eval : SKIP
test-stream-base-no-abort : SKIP
test-string-decoder : SKIP
test-timers-blocking-callback : SKIP
Expand Down
16 changes: 13 additions & 3 deletions test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ const syntaxArgs = [
assert.strictEqual(c.stdout, '', 'stdout produced');

// stderr should include the filename
assert(c.stderr.startsWith(file), "stderr doesn't start with the filename");
// TODO(digitalinfinity): Remove this check
// Node-ChakraCore currently doesn't populate TryCatch.Message
if (process.jsEngine === 'v8') {
assert(c.stderr.startsWith(file),
"stderr doesn't start with the filename");
}

// stderr should have a syntax error message
const match = c.stderr.match(common.engineSpecificMessage({
Expand Down Expand Up @@ -109,13 +114,18 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, {encoding: 'utf8', input: stdin});

// stderr should include '[stdin]' as the filename
assert(c.stderr.startsWith('[stdin]'), "stderr doesn't start with [stdin]");
if (process.jsEngine === 'v8') {
assert(c.stderr.startsWith('[stdin]'), "stderr doesn't start with [stdin]");
}

// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');

// stderr should have a syntax error message
const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m);
const match = c.stderr.match(common.engineSpecificMessage({
v8: /^SyntaxError: Unexpected identifier$/m,
chakracore: /^SyntaxError: Expected ';'$/m})
);
assert(match, 'stderr incorrect');

assert.strictEqual(c.status, 1, 'code === ' + c.status);
Expand Down
15 changes: 12 additions & 3 deletions test/parallel/test-querystring-escape.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');

const qs = require('querystring');
Expand All @@ -23,10 +23,19 @@ assert.strictEqual(

// toString is not callable, must throw an error
assert.throws(() => qs.escape({toString: 5}),
/^TypeError: Cannot convert object to primitive value$/);
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert object to primitive value$/,
chakracore: /^TypeError: String expected$/
}));

// should use valueOf instead of non-callable toString
assert.strictEqual(qs.escape({toString: 5, valueOf: () => 'test'}), 'test');

const chakraSymbolTypeError =
/^TypeError: Object doesn't support property or method 'ToString'$/;

assert.throws(() => qs.escape(Symbol('test')),
/^TypeError: Cannot convert a Symbol value to a string$/);
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakraSymbolTypeError
}));
10 changes: 8 additions & 2 deletions test/parallel/test-url-parse-invalid-input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const url = require('url');

Expand All @@ -17,4 +17,10 @@ const url = require('url');
assert.throws(function() { url.parse(val); }, TypeError);
});

assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/);
const engineSpecificMalformedUrlError =
common.engineSpecificMessage({
v8: /^URIError: URI malformed$/,
chakracore: /^URIError: The URI to be decoded is not a valid encoding$/
});

assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, engineSpecificMalformedUrlError);
2 changes: 1 addition & 1 deletion test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ if (typeof Symbol !== 'undefined') {
assert.strictEqual(util.inspect(new Promise()),
common.engineSpecificMessage({
v8: '{ bar: 42 }',
chakracore: 'Object { \'<unknown>\', bar: 42 }'
chakracore: 'Object { undefined, bar: 42 }'
}));
global.Promise = oldPromise;
}
Expand Down

0 comments on commit 481ca0e

Please sign in to comment.