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

Commit

Permalink
test: fixing test failures
Browse files Browse the repository at this point in the history
A couple of tests had incorrect baselines,
test-tty-get-color-depth incorrectly tried to get the color of
stdin, and test-fs-write used a new v8-specific flag.

To solve that last case, I added a list of banned flags to
the python script that runs tests, which will cause it to ignore
those flags if they are requested by a script.
  • Loading branch information
MSLaguana committed Feb 8, 2018
1 parent ec2fb56 commit d657866
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 69 deletions.
2 changes: 1 addition & 1 deletion test/message/error_exit.chakracore.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Exiting with code=1
assert.js:*
throw new errors.AssertionError(obj);
throw new AssertionError(obj);
^

AssertionError [ERR_ASSERTION]: 1 strictEqual 2
Expand Down
19 changes: 19 additions & 0 deletions test/message/if-error-has-good-stack.chakracore.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
assert.js:*
throw newErr;
^

AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at z (*if-error-has-good-stack.js:*:*
at y (*if-error-has-good-stack.js:*:*)
at x (*if-error-has-good-stack.js:*:*)
at Anonymous function (*if-error-has-good-stack.js:*:*)
at c (*if-error-has-good-stack.js:*:*)
at b (*if-error-has-good-stack.js:*:*)
at a (*if-error-has-good-stack.js:*:*)
at Anonymous function (*if-error-has-good-stack.js:*:*)
at Module.prototype._compile (module.js:*:*)
at Module._extensions[.js] (module.js:*:*)
at Module.prototype.load (module.js:*:*)
at tryModuleLoad (module.js:*:*)
at Module._load (module.js:*:*)
at Module.runMain (module.js:*:*)
19 changes: 0 additions & 19 deletions test/message/if-error-has-good-stack.out

This file was deleted.

19 changes: 19 additions & 0 deletions test/message/if-error-has-good-stack.v8.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
assert.js:*
throw newErr;
^

AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at z (*if-error-has-good-stack.js:*:*
at y (*if-error-has-good-stack.js:*:*)
at x (*if-error-has-good-stack.js:*:*)
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
at c (*if-error-has-good-stack.js:*:*)
at b (*if-error-has-good-stack.js:*:*)
at a (*if-error-has-good-stack.js:*:*)
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
at Module._compile (module.js:*:*)
at Object.Module._extensions..js (module.js:*:*)
at Module.load (module.js:*:*)
at tryModuleLoad (module.js:*:*)
at Function.Module._load (module.js:*:*)
at Function.Module.runMain (module.js:*:*)
84 changes: 43 additions & 41 deletions test/parallel/test-fs-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,49 @@ const fn3 = path.join(common.tmpDir, 'write3.txt');
const expected = 'ümlaut.';
const constants = fs.constants;

/* eslint-disable no-undef */
common.allowGlobals(externalizeString, isOneByteString, x);

{
const expected = 'ümlaut eins'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(true, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'latin1');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'latin1'));
}

{
const expected = 'ümlaut zwei'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(true, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'utf8');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'utf8'));
}

{
const expected = '中文 1'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(false, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'ucs2');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'ucs2'));
}

{
const expected = '中文 2'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(false, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'utf8');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'utf8'));
if (!common.isChakraEngine) {
/* eslint-disable no-undef */
common.allowGlobals(externalizeString, isOneByteString, x);

{
const expected = 'ümlaut eins'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(true, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'latin1');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'latin1'));
}

{
const expected = 'ümlaut zwei'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(true, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'utf8');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'utf8'));
}

{
const expected = '中文 1'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(false, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'ucs2');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'ucs2'));
}

{
const expected = '中文 2'; // Must be a unique string.
externalizeString(expected);
assert.strictEqual(false, isOneByteString(expected));
const fd = fs.openSync(fn, 'w');
fs.writeSync(fd, expected, 0, 'utf8');
fs.closeSync(fd);
assert.strictEqual(expected, fs.readFileSync(fn, 'utf8'));
}
}

common.refreshTmpDir();
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-tty-get-color-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { WriteStream } = require('tty');

// Do our best to grab a tty fd.
function getTTYfd() {
const ttyFd = [0, 1, 2, 4, 5].find(tty.isatty);
const ttyFd = [1, 2, 4, 5].find(tty.isatty);
if (ttyFd === undefined) {
try {
return openSync('/dev/tty');
Expand Down
23 changes: 16 additions & 7 deletions test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
FILES_PATTERN = re.compile(r"//\s+Files:(.*)")

chakraBannedFlags = ["--expose_externalize_string"]

class SimpleTestCase(test.TestCase):

def __init__(self, path, file, arch, mode, context, config, additional=None):
def __init__(self, path, file, arch, mode, context, config, jsEngine, additional=None):
super(SimpleTestCase, self).__init__(context, path, arch, mode)
self.file = file
self.config = config
self.arch = arch
self.mode = mode
self.jsEngine = jsEngine
if additional is not None:
self.additional_flags = additional
else:
Expand All @@ -61,6 +63,9 @@ def GetCommand(self):
flags_match = FLAGS_PATTERN.search(source)
if flags_match:
flag = flags_match.group(1).strip().split()
if self.jsEngine == "chakracore":
flag = filter(lambda x: x not in chakraBannedFlags, flag)

# The following block reads config.gypi to extract the v8_enable_inspector
# value. This is done to check if the inspector is disabled in which case
# the '--inspect' flag cannot be passed to the node process as it will
Expand All @@ -70,7 +75,9 @@ def GetCommand(self):
# the inspector related tests). Also, if there is no ssl support the
# options '--use-bundled-ca' and '--use-openssl-ca' will also cause a
# similar failure so such tests are also skipped.
if ('--inspect' in flag[0] or \
if len(flag) == 0:
pass
elif ('--inspect' in flag[0] or \
'--use-bundled-ca' in flag[0] or \
'--use-openssl-ca' in flag[0]) and \
self.context.v8_enable_inspector == 0:
Expand All @@ -97,9 +104,9 @@ def GetSource(self):
class MessageTestCase(SimpleTestCase):

def __init__(self, path, file, arch, mode, context, config, expected,
additional=None):
jsEngine, additional=None):
super(MessageTestCase, self).__init__(path, file, arch, mode, context,
config, additional)
config, jsEngine, additional)
self.expected = expected

def IgnoreLine(self, str):
Expand Down Expand Up @@ -172,7 +179,8 @@ def ListTests(self, current_path, path, arch, mode, jsEngine):
file_path = join(self.root, reduce(join, test[1:], ""))
test_name = test[:-1] + [splitext(test[-1])[0]]
result.append(SimpleTestCase(test_name, file_path, arch, mode,
self.context, self, self.additional_flags))
self.context, self, jsEngine,
self.additional_flags))
return result

def GetBuildRequirements(self):
Expand Down Expand Up @@ -220,7 +228,7 @@ def ListTests(self, current_path, path, arch, mode, jsEngine):
file_path = join(self.root, reduce(join, test[1:], "") + ".js")
result.append(
SimpleTestCase(test, file_path, arch, mode, self.context, self,
self.additional_flags))
jsEngine, self.additional_flags))
return result

class AsyncHooksTestConfiguration(SimpleTestConfiguration):
Expand Down Expand Up @@ -275,5 +283,6 @@ def ListTests(self, current_path, path, arch, mode, jsEngine):
if not exists(output_path):
raise Exception("Could not find %s" % output_path)
result.append(MessageTestCase(test_name, file_path, arch, mode,
self.context, self, output_path, self.additional_flags))
self.context, self, output_path, jsEngine,
self.additional_flags))
return result

0 comments on commit d657866

Please sign in to comment.