From d65786653a928ca8b8e9ee1e42f82ee171b5b8fc Mon Sep 17 00:00:00 2001 From: Jimmy Thomson Date: Thu, 8 Feb 2018 00:30:57 -0800 Subject: [PATCH] test: fixing test failures 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. --- test/message/error_exit.chakracore.out | 2 +- .../if-error-has-good-stack.chakracore.out | 19 +++++ test/message/if-error-has-good-stack.out | 19 ----- test/message/if-error-has-good-stack.v8.out | 19 +++++ test/parallel/test-fs-write.js | 84 ++++++++++--------- test/parallel/test-tty-get-color-depth.js | 2 +- test/testpy/__init__.py | 23 +++-- 7 files changed, 99 insertions(+), 69 deletions(-) create mode 100644 test/message/if-error-has-good-stack.chakracore.out delete mode 100644 test/message/if-error-has-good-stack.out create mode 100644 test/message/if-error-has-good-stack.v8.out diff --git a/test/message/error_exit.chakracore.out b/test/message/error_exit.chakracore.out index b2e7b7044cc..5e14ec4af15 100644 --- a/test/message/error_exit.chakracore.out +++ b/test/message/error_exit.chakracore.out @@ -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 diff --git a/test/message/if-error-has-good-stack.chakracore.out b/test/message/if-error-has-good-stack.chakracore.out new file mode 100644 index 00000000000..f3f66832617 --- /dev/null +++ b/test/message/if-error-has-good-stack.chakracore.out @@ -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:*:*) \ No newline at end of file diff --git a/test/message/if-error-has-good-stack.out b/test/message/if-error-has-good-stack.out deleted file mode 100644 index fa72322b446..00000000000 --- a/test/message/if-error-has-good-stack.out +++ /dev/null @@ -1,19 +0,0 @@ -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. (*/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. (*/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:*:*) diff --git a/test/message/if-error-has-good-stack.v8.out b/test/message/if-error-has-good-stack.v8.out new file mode 100644 index 00000000000..7aa58b0283f --- /dev/null +++ b/test/message/if-error-has-good-stack.v8.out @@ -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. (*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. (*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:*:*) diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index 7e8d6f8b539..cf8395727ed 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -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(); diff --git a/test/parallel/test-tty-get-color-depth.js b/test/parallel/test-tty-get-color-depth.js index a5a998b6a3a..a4c7ffacd17 100644 --- a/test/parallel/test-tty-get-color-depth.js +++ b/test/parallel/test-tty-get-color-depth.js @@ -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'); diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 08d4a68b31a..a92739974c2 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -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: @@ -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 @@ -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: @@ -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): @@ -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): @@ -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): @@ -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