From e9c2ffd20c28f7442effaba4445c48be0040ad58 Mon Sep 17 00:00:00 2001 From: Stewart Addison Date: Mon, 14 Nov 2016 13:41:31 +0000 Subject: [PATCH 001/195] deps: backport GYP fix to fix AIX shared suffix Required to support the shared library builds on AIX - this sets the shared library suffix within GYP to .a instead of .so on AIX My patch: https://codereview.chromium.org/2492233002/ was landed as as part of this one which fixed some other (not required, but included for completeness of the backport) changes: Ref: https://codereview.chromium.org/2511733005/ --- tools/gyp/AUTHORS | 7 ++++--- tools/gyp/PRESUBMIT.py | 26 ++++++++++++++------------ tools/gyp/pylib/gyp/generator/make.py | 10 ++++++++-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/tools/gyp/AUTHORS b/tools/gyp/AUTHORS index 9389ca0a23e48f..dcd231ceb2d341 100644 --- a/tools/gyp/AUTHORS +++ b/tools/gyp/AUTHORS @@ -1,9 +1,10 @@ # Names should be added to this file like so: # Name or Organization -Google Inc. -Bloomberg Finance L.P. -Yandex LLC +Google Inc. <*@google.com> +Bloomberg Finance L.P. <*@bloomberg.net> +IBM Inc. <*@*.ibm.com> +Yandex LLC <*@yandex-team.ru> Steven Knight Ryan Norton diff --git a/tools/gyp/PRESUBMIT.py b/tools/gyp/PRESUBMIT.py index dde025383c3276..f6c8a357afe149 100644 --- a/tools/gyp/PRESUBMIT.py +++ b/tools/gyp/PRESUBMIT.py @@ -73,23 +73,15 @@ ] -def CheckChangeOnUpload(input_api, output_api): - report = [] - report.extend(input_api.canned_checks.PanProjectChecks( - input_api, output_api)) - return report - - -def CheckChangeOnCommit(input_api, output_api): - report = [] - +def _LicenseHeader(input_api): # Accept any year number from 2009 to the current year. current_year = int(input_api.time.strftime('%Y')) allowed_years = (str(s) for s in reversed(xrange(2009, current_year + 1))) + years_re = '(' + '|'.join(allowed_years) + ')' # The (c) is deprecated, but tolerate it until it's removed from all files. - license = ( + return ( r'.*? Copyright (\(c\) )?%(year)s Google Inc\. All rights reserved\.\n' r'.*? Use of this source code is governed by a BSD-style license that ' r'can be\n' @@ -98,8 +90,18 @@ def CheckChangeOnCommit(input_api, output_api): 'year': years_re, } +def CheckChangeOnUpload(input_api, output_api): + report = [] + report.extend(input_api.canned_checks.PanProjectChecks( + input_api, output_api, license_header=_LicenseHeader(input_api))) + return report + + +def CheckChangeOnCommit(input_api, output_api): + report = [] + report.extend(input_api.canned_checks.PanProjectChecks( - input_api, output_api, license_header=license)) + input_api, output_api, license_header=_LicenseHeader(input_api))) report.extend(input_api.canned_checks.CheckTreeIsOpen( input_api, output_api, 'http://gyp-status.appspot.com/status', diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index 4a6b283f152329..39373b9844e49e 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -92,7 +92,10 @@ def CalculateVariables(default_variables, params): if flavor == 'android': operating_system = 'linux' # Keep this legacy behavior for now. default_variables.setdefault('OS', operating_system) - default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') + if flavor == 'aix': + default_variables.setdefault('SHARED_LIB_SUFFIX', '.a') + else: + default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)') default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)') @@ -1349,7 +1352,10 @@ def ComputeOutputBasename(self, spec): if target[:3] == 'lib': target = target[3:] target_prefix = 'lib' - target_ext = '.so' + if self.flavor == 'aix': + target_ext = '.a' + else: + target_ext = '.so' elif self.type == 'none': target = '%s.stamp' % target elif self.type != 'executable': From 16af4671466a3f00825066c60787b4a45f86005c Mon Sep 17 00:00:00 2001 From: Stewart Addison Date: Mon, 14 Nov 2016 13:43:41 +0000 Subject: [PATCH 002/195] build: add shared library support to AIX build Updates to build the shared library version of node on AIX. Adds the same functionality to AIX that was added on Linux under this: Ref: https://github.com/nodejs/node/pull/6994/ PR-URL: https://github.com/nodejs/node/pull/9675 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Michael Dawson --- configure | 9 ++++++++- node.gyp | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 88be15abdb0c18..82e0c2897e3061 100755 --- a/configure +++ b/configure @@ -848,7 +848,14 @@ def configure_node(o): o['variables']['node_no_browser_globals'] = b(options.no_browser_globals) o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() - shlib_suffix = '%s.dylib' if sys.platform == 'darwin' else 'so.%s' + + if sys.platform == 'darwin': + shlib_suffix = '%s.dylib' + elif sys.platform.startswith('aix'): + shlib_suffix = '%s.a' + else: + shlib_suffix = 'so.%s' + shlib_suffix %= node_module_version o['variables']['node_module_version'] = int(node_module_version) o['variables']['shlib_suffix'] = shlib_suffix diff --git a/node.gyp b/node.gyp index 2254a6e89136bb..f59037737c905a 100644 --- a/node.gyp +++ b/node.gyp @@ -928,7 +928,15 @@ 'targets': [ { 'target_name': 'node', - 'type': 'executable', + 'conditions': [ + ['node_shared=="true"', { + 'type': 'shared_library', + 'ldflags': ['--shared'], + 'product_extension': '<(shlib_suffix)', + }, { + 'type': 'executable', + }], + ], 'dependencies': ['<(node_core_target_name)', 'node_exp'], 'include_dirs': [ From 561b1494bc40345b57c3a8d2024792f7b07e53a9 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Sat, 19 Nov 2016 00:02:41 -0500 Subject: [PATCH 003/195] tools: allow test.py to use full paths of tests Allow test.py to run tests with a 'tests/' prefix or a '.js' postfix PR-URL: https://github.com/nodejs/node/pull/9694 Fixes: https://github.com/nodejs/node/issues/9684 Reviewed-By: Prince John Wesley Reviewed-By: Myles Borins Reviewed-By: Anna Henningsen Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Gibson Fahnestock --- tools/test.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/test.py b/tools/test.py index 6e1840b7672006..4a272475ccfffc 100755 --- a/tools/test.py +++ b/tools/test.py @@ -298,7 +298,7 @@ def HasRun(self, output): if output.HasCrashed(): self.severity = 'crashed' - exit_code = output.output.exit_code + exit_code = output.output.exit_code self.traceback = "oh no!\nexit code: " + PrintCrashed(exit_code) if output.HasTimedOut(): @@ -1461,6 +1461,13 @@ def SplitPath(s): stripped = [ c.strip() for c in s.split('/') ] return [ Pattern(s) for s in stripped if len(s) > 0 ] +def NormalizePath(path): + # strip the extra path information of the specified test + if path.startswith('test/'): + path = path[5:] + if path.endswith('.js'): + path = path[:-3] + return path def GetSpecialCommandProcessor(value): if (not value) or (value.find('@') == -1): @@ -1534,7 +1541,7 @@ def Main(): else: paths = [ ] for arg in args: - path = SplitPath(arg) + path = SplitPath(NormalizePath(arg)) paths.append(path) # Check for --valgrind option. If enabled, we overwrite the special From 3e5be7fc8b6428ee71129bf95087f193b9283b99 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 22 Nov 2016 17:01:02 -0700 Subject: [PATCH 004/195] async_wrap: mode constructor/destructor to .cc The constructor and destructor shouldn't have been placed in the -inl.h file from the beginning. PR-URL: https://github.com/nodejs/node/pull/9753 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis --- src/async-wrap-inl.h | 71 -------------------------------------------- src/async-wrap.cc | 71 ++++++++++++++++++++++++++++++++++++++++++++ src/async-wrap.h | 10 +++---- 3 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index 85e31b1ed09d27..64b5f091612368 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -15,77 +15,6 @@ namespace node { -inline AsyncWrap::AsyncWrap(Environment* env, - v8::Local object, - ProviderType provider, - AsyncWrap* parent) - : BaseObject(env, object), bits_(static_cast(provider) << 1), - uid_(env->get_async_wrap_uid()) { - CHECK_NE(provider, PROVIDER_NONE); - CHECK_GE(object->InternalFieldCount(), 1); - - // Shift provider value over to prevent id collision. - persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider); - - v8::Local init_fn = env->async_hooks_init_function(); - - // No init callback exists, no reason to go on. - if (init_fn.IsEmpty()) - return; - - // If async wrap callbacks are disabled and no parent was passed that has - // run the init callback then return. - if (!env->async_wrap_callbacks_enabled() && - (parent == nullptr || !parent->ran_init_callback())) - return; - - v8::HandleScope scope(env->isolate()); - - v8::Local argv[] = { - v8::Number::New(env->isolate(), get_uid()), - v8::Int32::New(env->isolate(), provider), - Null(env->isolate()), - Null(env->isolate()) - }; - - if (parent != nullptr) { - argv[2] = v8::Number::New(env->isolate(), parent->get_uid()); - argv[3] = parent->object(); - } - - v8::TryCatch try_catch(env->isolate()); - - v8::MaybeLocal ret = - init_fn->Call(env->context(), object, arraysize(argv), argv); - - if (ret.IsEmpty()) { - ClearFatalExceptionHandlers(env); - FatalException(env->isolate(), try_catch); - } - - bits_ |= 1; // ran_init_callback() is true now. -} - - -inline AsyncWrap::~AsyncWrap() { - if (!ran_init_callback()) - return; - - v8::Local fn = env()->async_hooks_destroy_function(); - if (!fn.IsEmpty()) { - v8::HandleScope scope(env()->isolate()); - v8::Local uid = v8::Number::New(env()->isolate(), get_uid()); - v8::TryCatch try_catch(env()->isolate()); - v8::MaybeLocal ret = - fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid); - if (ret.IsEmpty()) { - ClearFatalExceptionHandlers(env()); - FatalException(env()->isolate(), try_catch); - } - } -} - - inline bool AsyncWrap::ran_init_callback() const { return static_cast(bits_ & 1); } diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 60124e47ad8833..af634a165a56c3 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -191,6 +191,77 @@ void LoadAsyncWrapperInfo(Environment* env) { } +AsyncWrap::AsyncWrap(Environment* env, + Local object, + ProviderType provider, + AsyncWrap* parent) + : BaseObject(env,object), bits_(static_cast(provider) << 1), + uid_(env->get_async_wrap_uid()) { + CHECK_NE(provider, PROVIDER_NONE); + CHECK_GE(object->InternalFieldCount(), 1); + + // Shift provider value over to prevent id collision. + persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider); + + Local init_fn = env->async_hooks_init_function(); + + // No init callback exists, no reason to go on. + if (init_fn.IsEmpty()) + return; + + // If async wrap callbacks are disabled and no parent was passed that has + // run the init callback then return. + if (!env->async_wrap_callbacks_enabled() && + (parent == nullptr || !parent->ran_init_callback())) + return; + + HandleScope scope(env->isolate()); + + Local argv[] = { + Number::New(env->isolate(), get_uid()), + Int32::New(env->isolate(), provider), + Null(env->isolate()), + Null(env->isolate()) + }; + + if (parent != nullptr) { + argv[2] = Number::New(env->isolate(), parent->get_uid()); + argv[3] = parent->object(); + } + + TryCatch try_catch(env->isolate()); + + MaybeLocal ret = + init_fn->Call(env->context(), object, arraysize(argv), argv); + + if (ret.IsEmpty()) { + ClearFatalExceptionHandlers(env); + FatalException(env->isolate(), try_catch); + } + + bits_ |= 1; // ran_init_callback() is true now. +} + + +AsyncWrap::~AsyncWrap() { + if (!ran_init_callback()) + return; + + Local fn = env()->async_hooks_destroy_function(); + if (!fn.IsEmpty()) { + HandleScope scope(env()->isolate()); + Local uid = Number::New(env()->isolate(), get_uid()); + TryCatch try_catch(env()->isolate()); + MaybeLocal ret = + fn->Call(env()->context(), Null(env()->isolate()), 1, &uid); + if (ret.IsEmpty()) { + ClearFatalExceptionHandlers(env()); + FatalException(env()->isolate(), try_catch); + } + } +} + + Local AsyncWrap::MakeCallback(const Local cb, int argc, Local* argv) { diff --git a/src/async-wrap.h b/src/async-wrap.h index e1ea383d9f1a09..bdd6883f211c2f 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -49,12 +49,12 @@ class AsyncWrap : public BaseObject { #undef V }; - inline AsyncWrap(Environment* env, - v8::Local object, - ProviderType provider, - AsyncWrap* parent = nullptr); + AsyncWrap(Environment* env, + v8::Local object, + ProviderType provider, + AsyncWrap* parent = nullptr); - inline virtual ~AsyncWrap(); + virtual ~AsyncWrap(); inline ProviderType provider_type() const; From 5157a5cee91deab232ff669799a61356d414d10f Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 22 Nov 2016 17:05:14 -0700 Subject: [PATCH 005/195] async_wrap: make Initialize a static class member This is how it's done everywhere else in core. Make it follow suit. PR-URL: https://github.com/nodejs/node/pull/9753 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis --- src/async-wrap.cc | 11 ++++++----- src/async-wrap.h | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index af634a165a56c3..f1f5a09dc0796e 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -14,6 +14,7 @@ using v8::Function; using v8::FunctionCallbackInfo; using v8::HandleScope; using v8::HeapProfiler; +using v8::Int32; using v8::Integer; using v8::Isolate; using v8::Local; @@ -155,9 +156,9 @@ static void SetupHooks(const FunctionCallbackInfo& args) { } -static void Initialize(Local target, - Local unused, - Local context) { +void AsyncWrap::Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); HandleScope scope(isolate); @@ -195,7 +196,7 @@ AsyncWrap::AsyncWrap(Environment* env, Local object, ProviderType provider, AsyncWrap* parent) - : BaseObject(env,object), bits_(static_cast(provider) << 1), + : BaseObject(env, object), bits_(static_cast(provider) << 1), uid_(env->get_async_wrap_uid()) { CHECK_NE(provider, PROVIDER_NONE); CHECK_GE(object->InternalFieldCount(), 1); @@ -361,4 +362,4 @@ Local AsyncWrap::MakeCallback(const Local cb, } // namespace node -NODE_MODULE_CONTEXT_AWARE_BUILTIN(async_wrap, node::Initialize) +NODE_MODULE_CONTEXT_AWARE_BUILTIN(async_wrap, node::AsyncWrap::Initialize) diff --git a/src/async-wrap.h b/src/async-wrap.h index bdd6883f211c2f..5ffd67dba9d15c 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -56,6 +56,10 @@ class AsyncWrap : public BaseObject { virtual ~AsyncWrap(); + static void Initialize(v8::Local target, + v8::Local unused, + v8::Local context); + inline ProviderType provider_type() const; inline int64_t get_uid() const; From 5379b9da11bf8baeafc7074dc64bcc144db89e64 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 22 Nov 2016 22:35:10 -0700 Subject: [PATCH 006/195] async_wrap: call destroy() callback in uv_idle_t Calling JS during GC is a no-no. So intead create a queue of all ids that need to have their destroy() callback called and call them later. Removed checking destroy() in test-async-wrap-uid because destroy() can be called after the 'exit' callback. Missing a reliable test to reproduce the issue that caused the FATAL_ERROR. PR-URL: https://github.com/nodejs/node/pull/9753 Fixes: https://github.com/nodejs/node/issues/8216 Fixes: https://github.com/nodejs/node/issues/9465 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis --- src/async-wrap.cc | 49 +++++++++++++++++++++------- src/async-wrap.h | 3 ++ src/env-inl.h | 15 +++++++++ src/env.cc | 3 ++ src/env.h | 8 +++++ test/parallel/test-async-wrap-uid.js | 8 +---- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/async-wrap.cc b/src/async-wrap.cc index f1f5a09dc0796e..42463bd22b31f4 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -5,6 +5,7 @@ #include "util.h" #include "util-inl.h" +#include "uv.h" #include "v8.h" #include "v8-profiler.h" @@ -182,6 +183,38 @@ void AsyncWrap::Initialize(Local target, } +void AsyncWrap::DestroyIdsCb(uv_idle_t* handle) { + uv_idle_stop(handle); + + Environment* env = Environment::from_destroy_ids_idle_handle(handle); + // None of the V8 calls done outside the HandleScope leak a handle. If this + // changes in the future then the SealHandleScope wrapping the uv_run() + // will catch this can cause the process to abort. + HandleScope handle_scope(env->isolate()); + Context::Scope context_scope(env->context()); + Local fn = env->async_hooks_destroy_function(); + + if (fn.IsEmpty()) + return env->destroy_ids_list()->clear(); + + TryCatch try_catch(env->isolate()); + + for (auto current_id : *env->destroy_ids_list()) { + // Want each callback to be cleaned up after itself, instead of cleaning + // them all up after the while() loop completes. + HandleScope scope(env->isolate()); + Local argv = Number::New(env->isolate(), current_id); + MaybeLocal ret = fn->Call( + env->context(), Undefined(env->isolate()), 1, &argv); + + if (ret.IsEmpty()) { + ClearFatalExceptionHandlers(env); + FatalException(env->isolate(), try_catch); + } + } +} + + void LoadAsyncWrapperInfo(Environment* env) { HeapProfiler* heap_profiler = env->isolate()->GetHeapProfiler(); #define V(PROVIDER) \ @@ -248,18 +281,10 @@ AsyncWrap::~AsyncWrap() { if (!ran_init_callback()) return; - Local fn = env()->async_hooks_destroy_function(); - if (!fn.IsEmpty()) { - HandleScope scope(env()->isolate()); - Local uid = Number::New(env()->isolate(), get_uid()); - TryCatch try_catch(env()->isolate()); - MaybeLocal ret = - fn->Call(env()->context(), Null(env()->isolate()), 1, &uid); - if (ret.IsEmpty()) { - ClearFatalExceptionHandlers(env()); - FatalException(env()->isolate(), try_catch); - } - } + if (env()->destroy_ids_list()->empty()) + uv_idle_start(env()->destroy_ids_idle_handle(), DestroyIdsCb); + + env()->destroy_ids_list()->push_back(get_uid()); } diff --git a/src/async-wrap.h b/src/async-wrap.h index 5ffd67dba9d15c..d01c6ce9f9b724 100644 --- a/src/async-wrap.h +++ b/src/async-wrap.h @@ -4,6 +4,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "base-object.h" +#include "uv.h" #include "v8.h" #include @@ -60,6 +61,8 @@ class AsyncWrap : public BaseObject { v8::Local unused, v8::Local context); + static void DestroyIdsCb(uv_idle_t* handle); + inline ProviderType provider_type() const; inline int64_t get_uid() const; diff --git a/src/env-inl.h b/src/env-inl.h index 74e427e40353d9..83db3d33b6d18f 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -194,6 +194,8 @@ inline Environment::Environment(IsolateData* isolate_data, RB_INIT(&cares_task_list_); AssignToContext(context); + + destroy_ids_list_.reserve(512); } inline Environment::~Environment() { @@ -247,6 +249,15 @@ inline uv_idle_t* Environment::immediate_idle_handle() { return &immediate_idle_handle_; } +inline Environment* Environment::from_destroy_ids_idle_handle( + uv_idle_t* handle) { + return ContainerOf(&Environment::destroy_ids_idle_handle_, handle); +} + +inline uv_idle_t* Environment::destroy_ids_idle_handle() { + return &destroy_ids_idle_handle_; +} + inline void Environment::RegisterHandleCleanup(uv_handle_t* handle, HandleCleanupCb cb, void *arg) { @@ -301,6 +312,10 @@ inline int64_t Environment::get_async_wrap_uid() { return ++async_wrap_uid_; } +inline std::vector* Environment::destroy_ids_list() { + return &destroy_ids_list_; +} + inline uint32_t* Environment::heap_statistics_buffer() const { CHECK_NE(heap_statistics_buffer_, nullptr); return heap_statistics_buffer_; diff --git a/src/env.cc b/src/env.cc index efa2d53f0435b2..40f0c9ebd66a07 100644 --- a/src/env.cc +++ b/src/env.cc @@ -49,6 +49,9 @@ void Environment::Start(int argc, uv_unref(reinterpret_cast(&idle_prepare_handle_)); uv_unref(reinterpret_cast(&idle_check_handle_)); + uv_idle_init(event_loop(), destroy_ids_idle_handle()); + uv_unref(reinterpret_cast(destroy_ids_idle_handle())); + auto close_and_finish = [](Environment* env, uv_handle_t* handle, void* arg) { handle->data = env; diff --git a/src/env.h b/src/env.h index 51049ed2bea473..b99bb45f819e59 100644 --- a/src/env.h +++ b/src/env.h @@ -16,6 +16,7 @@ #include "v8.h" #include +#include // Caveat emptor: we're going slightly crazy with macros here but the end // hopefully justifies the means. We have a lot of per-context properties @@ -431,8 +432,10 @@ class Environment { inline uint32_t watched_providers() const; static inline Environment* from_immediate_check_handle(uv_check_t* handle); + static inline Environment* from_destroy_ids_idle_handle(uv_idle_t* handle); inline uv_check_t* immediate_check_handle(); inline uv_idle_t* immediate_idle_handle(); + inline uv_idle_t* destroy_ids_idle_handle(); // Register clean-up cb to be called on environment destruction. inline void RegisterHandleCleanup(uv_handle_t* handle, @@ -463,6 +466,9 @@ class Environment { inline int64_t get_async_wrap_uid(); + // List of id's that have been destroyed and need the destroy() cb called. + inline std::vector* destroy_ids_list(); + inline uint32_t* heap_statistics_buffer() const; inline void set_heap_statistics_buffer(uint32_t* pointer); @@ -548,6 +554,7 @@ class Environment { IsolateData* const isolate_data_; uv_check_t immediate_check_handle_; uv_idle_t immediate_idle_handle_; + uv_idle_t destroy_ids_idle_handle_; uv_prepare_t idle_prepare_handle_; uv_check_t idle_check_handle_; AsyncHooks async_hooks_; @@ -562,6 +569,7 @@ class Environment { bool trace_sync_io_; size_t makecallback_cntr_; int64_t async_wrap_uid_; + std::vector destroy_ids_list_; debugger::Agent debugger_agent_; #if HAVE_INSPECTOR inspector::Agent inspector_agent_; diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js index 5bf3a8856e0e3f..3497c3b0768ddd 100644 --- a/test/parallel/test-async-wrap-uid.js +++ b/test/parallel/test-async-wrap-uid.js @@ -6,7 +6,7 @@ const assert = require('assert'); const async_wrap = process.binding('async_wrap'); const storage = new Map(); -async_wrap.setupHooks({ init, pre, post, destroy }); +async_wrap.setupHooks({ init, pre, post }); async_wrap.enable(); function init(uid) { @@ -14,7 +14,6 @@ function init(uid) { init: true, pre: false, post: false, - destroy: false }); } @@ -26,10 +25,6 @@ function post(uid) { storage.get(uid).post = true; } -function destroy(uid) { - storage.get(uid).destroy = true; -} - fs.access(__filename, function(err) { assert.ifError(err); }); @@ -51,7 +46,6 @@ process.once('exit', function() { init: true, pre: true, post: true, - destroy: true }); } }); From 44ae0283afe36a8749cafed78864e59b2790baa2 Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Mon, 21 Nov 2016 19:24:02 +0100 Subject: [PATCH 007/195] doc: fix inside stability boxes Fixes: https://github.com/nodejs/node/issues/9714 PR-URL: https://github.com/nodejs/node/pull/9723 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Luigi Pinca --- doc/api_assets/style.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index c187079a26f98e..f45c4672af88f8 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -362,6 +362,11 @@ tt, code { padding: .1em .3em; } +.api_stability code { + background: rgba(0, 0, 0, .1); + padding: .1em .3em; +} + a code { color: inherit; background: inherit; From fc13cc6a123b17f4defc24d6785a6afca33bb3df Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 20 Nov 2016 21:12:09 -0800 Subject: [PATCH 008/195] test:refactor test-tls-hello-parser-failure * setTimeout() with no duration -> setImmediate() * add common.mustCall() where appropriate * var -> const * .on() -> .once() PR-URL: https://github.com/nodejs/node/pull/9715 Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca --- .../parallel/test-tls-hello-parser-failure.js | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/test/parallel/test-tls-hello-parser-failure.js b/test/parallel/test-tls-hello-parser-failure.js index e5e43c408abfc6..f9c280f5e57a34 100644 --- a/test/parallel/test-tls-hello-parser-failure.js +++ b/test/parallel/test-tls-hello-parser-failure.js @@ -1,46 +1,43 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); + +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var net = require('net'); -var fs = require('fs'); +const assert = require('assert'); +const tls = require('tls'); + +const net = require('net'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/test_key.pem'), cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem') }; -var bonkers = Buffer.alloc(1024 * 1024, 42); +const bonkers = Buffer.alloc(1024 * 1024, 42); -var server = tls.createServer(options, function(c) { +const server = tls.createServer(options, function(c) { -}).listen(0, function() { - var client = net.connect(this.address().port, function() { +}).listen(0, common.mustCall(function() { + const client = net.connect(this.address().port, common.mustCall(function() { client.write(bonkers); - }); + })); - var once = false; - - var writeAgain = setTimeout(function() { + const writeAgain = setImmediate(function() { client.write(bonkers); }); - client.on('error', function(err) { - if (!once) { - clearTimeout(writeAgain); - once = true; - client.destroy(); - server.close(); - } - }); + client.once('error', common.mustCall(function(err) { + clearImmediate(writeAgain); + client.destroy(); + server.close(); + })); - client.on('close', function(hadError) { + client.on('close', common.mustCall(function(hadError) { assert.strictEqual(hadError, true, 'Client never errored'); - }); -}); + })); +})); From 2fb825750d17d03cfce9f51ef7b5f92e9c073c86 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 21 Nov 2016 13:13:58 -0800 Subject: [PATCH 009/195] test: fix flaky test-inspector Using `socket.destroy()` instead of `socket.end()` fixes more-than-intermittent ECONNRESET issues on Windows. PR-URL: https://github.com/nodejs/node/pull/9727 Fixes: https://github.com/nodejs/node/issues/8804 Reviewed-By: Gibson Fahnestock Reviewed-By: Eugene Ostroukhov --- test/inspector/inspector-helper.js | 2 +- test/inspector/inspector.status | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/inspector/inspector-helper.js b/test/inspector/inspector-helper.js index a02b6b9a5bc506..3e517123fe27f9 100644 --- a/test/inspector/inspector-helper.js +++ b/test/inspector/inspector-helper.js @@ -286,7 +286,7 @@ TestSession.prototype.disconnect = function(childDone) { this.expectClose_ = true; this.harness_.childInstanceDone = this.harness_.childInstanceDone || childDone; - this.socket_.end(); + this.socket_.destroy(); console.log('[test]', 'Connection terminated'); callback(); }); diff --git a/test/inspector/inspector.status b/test/inspector/inspector.status index 69865843c940fc..ed6a782b9031a7 100644 --- a/test/inspector/inspector.status +++ b/test/inspector/inspector.status @@ -7,4 +7,3 @@ prefix inspector [true] # This section applies to all platforms [$system==win32] -test-inspector : PASS,FLAKY From 65af114267b35996a006bb9c9f2e6de087e48687 Mon Sep 17 00:00:00 2001 From: Adam Brunner Date: Tue, 22 Nov 2016 10:03:04 +0100 Subject: [PATCH 010/195] doc: "util" is not needed to extend ES6 classes PR-URL: https://github.com/nodejs/node/pull/9737 Reviewed-By: Colin Ihrig Reviewed-By: Italo A. Casas Reviewed-By: Roman Reiss Reviewed-By: Luigi Pinca --- doc/api/util.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/util.md b/doc/api/util.md index 3e4a4b1d39fd82..a8fded6b2db042 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -180,7 +180,6 @@ stream.write('It works!'); // Received data: "It works!" ES6 example using `class` and `extends` ```js -const util = require('util'); const EventEmitter = require('events'); class MyStream extends EventEmitter { From 77e145a00ec0a82c649498b9e2210432faa41db6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 21 Nov 2016 20:46:49 -0800 Subject: [PATCH 011/195] doc: clarify slashes-appending in url module PR-URL: https://github.com/nodejs/node/pull/9731 Ref: https://github.com/nodejs/node/issues/9521 Reviewed-By: Luigi Pinca --- doc/api/url.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index 6d573b4b910f27..40a3440195e69a 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -154,10 +154,11 @@ The formatting process operates as follows: [`Error`][] is thrown. * For all string values of `urlObject.protocol` that *do not end* with an ASCII colon (`:`) character, the literal string `:` will be appended to `result`. -* If either the `urlObject.slashes` property is true, `urlObject.protocol` - begins with one of `http`, `https`, `ftp`, `gopher`, or `file`, or - `urlObject.protocol` is `undefined`, the literal string `//` will be appended - to `result`. +* If either of the following conditions is true, then the literal string `//` + will be appended to `result`: + * `urlObject.slashes` property is true; + * `urlObject.protocol` begins with `http`, `https`, `ftp`, `gopher`, or + `file`; * If the value of the `urlObject.auth` property is truthy, and either `urlObject.host` or `urlObject.hostname` are not `undefined`, the value of `urlObject.auth` will be coerced into a string and appended to `result` From a673d44d68b6c21806c63caec0ba82d2d301a0a0 Mon Sep 17 00:00:00 2001 From: Prince J Wesley Date: Mon, 14 Nov 2016 12:53:35 +0530 Subject: [PATCH 012/195] lib,tools: remove unneeded escaping of / The `/` character does not need to be escaped when occurring inside a character class in a regular expression. Remove such instances of escaping in the code base. PR-URL: https://github.com/nodejs/node/pull/9591 Reviewed-By: Teddy Katz --- lib/url.js | 2 +- tools/doc/html.js | 4 ++-- tools/doc/json.js | 8 ++++---- tools/license2rtf.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/url.js b/lib/url.js index a199f4b581dcd2..5f87c0c36c43e5 100644 --- a/lib/url.js +++ b/lib/url.js @@ -44,7 +44,7 @@ const protocolPattern = /^([a-z0-9.+-]+:)/i; const portPattern = /:[0-9]*$/; // Special case for a simple path URL -const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/; +const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/; const hostnameMaxLen = 255; // protocols that can allow "unsafe" and "unwise" chars. diff --git a/tools/doc/html.js b/tools/doc/html.js index daa230cb926e4a..c0790ffca5f0d4 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -90,7 +90,7 @@ function loadGtoc(cb) { function toID(filename) { return filename .replace('.html', '') - .replace(/[^\w\-]/g, '-') + .replace(/[^\w-]/g, '-') .replace(/-+/g, '-'); } @@ -284,7 +284,7 @@ function linkJsTypeDocs(text) { // Handle types, for example the source Markdown might say // "This argument should be a {Number} or {String}" for (i = 0; i < parts.length; i += 2) { - typeMatches = parts[i].match(/\{([^\}]+)\}/g); + typeMatches = parts[i].match(/\{([^}]+)\}/g); if (typeMatches) { typeMatches.forEach(function(typeMatch) { parts[i] = parts[i].replace(typeMatch, typeParser.toLink(typeMatch)); diff --git a/tools/doc/json.js b/tools/doc/json.js index a782c54028d756..f8210ef17fda5c 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -31,7 +31,7 @@ function doJSON(input, filename, cb) { // // This is for cases where the markdown semantic structure is lacking. if (type === 'paragraph' || type === 'html') { - var metaExpr = /\n*/g; + var metaExpr = /\n*/g; text = text.replace(metaExpr, function(_0, k, v) { current[k.trim()] = v.trim(); return ''; @@ -371,7 +371,7 @@ function parseListItem(item) { item.name = 'return'; text = text.replace(retExpr, ''); } else { - var nameExpr = /^['`"]?([^'`": \{]+)['`"]?\s*:?\s*/; + var nameExpr = /^['`"]?([^'`": {]+)['`"]?\s*:?\s*/; var name = text.match(nameExpr); if (name) { item.name = name[1]; @@ -388,7 +388,7 @@ function parseListItem(item) { } text = text.trim(); - var typeExpr = /^\{([^\}]+)\}/; + var typeExpr = /^\{([^}]+)\}/; var type = text.match(typeExpr); if (type) { item.type = type[1]; @@ -551,7 +551,7 @@ var classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i; var methExpr = /^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i; -var newExpr = /^new ([A-Z][a-zA-Z]+)\([^\)]*\)\s*?$/; +var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*?$/; var paramExpr = /\((.*)\);?$/; function newSection(tok) { diff --git a/tools/license2rtf.js b/tools/license2rtf.js index 694e1c60501414..4b3d71fe5b99e9 100644 --- a/tools/license2rtf.js +++ b/tools/license2rtf.js @@ -122,7 +122,7 @@ function ParagraphParser() { // Detect separator "lines" within a block. These mark a paragraph break // and are stripped from the output. - if (/^\s*[=*\-]{5,}\s*$/.test(line)) { + if (/^\s*[=*-]{5,}\s*$/.test(line)) { flushParagraph(); return; } @@ -286,7 +286,7 @@ function RtfGenerator() { function rtfEscape(string) { return string - .replace(/[\\\{\}]/g, function(m) { + .replace(/[\\{}]/g, function(m) { return '\\' + m; }) .replace(/\t/g, function() { From 53d175267c1389344a533c7c68c4606dc2e1201b Mon Sep 17 00:00:00 2001 From: Prince J Wesley Date: Sun, 13 Nov 2016 11:11:38 +0530 Subject: [PATCH 013/195] tools: Add no useless regex char class rule Eslint Rule: Disallow useless escape in regex character class with optional override characters option and auto fixable with eslint --fix option. Usage: no-useless-regex-char-class-escape: [2, { override: ['[', ']'] }] PR-URL: https://github.com/nodejs/node/pull/9591 Reviewed-By: Teddy Katz --- .eslintrc | 1 + .../no-useless-regex-char-class-escape.js | 190 ++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 tools/eslint-rules/no-useless-regex-char-class-escape.js diff --git a/.eslintrc b/.eslintrc index 337ff4f35de17c..9f150c5d217e0c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -122,6 +122,7 @@ rules: align-multiline-assignment: 2 assert-fail-single-argument: 2 new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] + no-useless-regex-char-class-escape: [2, { override: ['[', ']'] }] # Global scoped method and vars globals: diff --git a/tools/eslint-rules/no-useless-regex-char-class-escape.js b/tools/eslint-rules/no-useless-regex-char-class-escape.js new file mode 100644 index 00000000000000..934a3fa193b506 --- /dev/null +++ b/tools/eslint-rules/no-useless-regex-char-class-escape.js @@ -0,0 +1,190 @@ +/** + * @fileoverview Disallow useless escape in regex character class + * Based on 'no-useless-escape' rule + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +const REGEX_CHARCLASS_ESCAPES = new Set('\\bcdDfnrsStvwWxu0123456789]'); + +/** + * Parses a regular expression into a list of regex character class list. + * @param {string} regExpText raw text used to create the regular expression + * @returns {Object[]} A list of character classes tokens with index and + * escape info + * @example + * + * parseRegExpCharClass('a\\b[cd-]') + * + * returns: + * [ + * { + * empty: false, + * start: 4, + * end: 6, + * chars: [ + * {text: 'c', index: 4, escaped: false}, + * {text: 'd', index: 5, escaped: false}, + * {text: '-', index: 6, escaped: false} + * ] + * } + * ] + */ + +function parseRegExpCharClass(regExpText) { + const charList = []; + let charListIdx = -1; + const initState = { + escapeNextChar: false, + inCharClass: false, + startingCharClass: false + }; + + regExpText.split('').reduce((state, char, index) => { + if (!state.escapeNextChar) { + if (char === '\\') { + return Object.assign(state, { escapeNextChar: true }); + } + if (char === '[' && !state.inCharClass) { + charListIdx += 1; + charList.push({ start: index + 1, chars: [], end: -1 }); + return Object.assign(state, { + inCharClass: true, + startingCharClass: true + }); + } + if (char === ']' && state.inCharClass) { + const charClass = charList[charListIdx]; + charClass.empty = charClass.chars.length === 0; + if (charClass.empty) { + charClass.start = charClass.end = -1; + } else { + charList[charListIdx].end = index - 1; + } + return Object.assign(state, { + inCharClass: false, + startingCharClass: false + }); + } + } + if (state.inCharClass) { + charList[charListIdx].chars.push({ + text: char, + index, escaped: + state.escapeNextChar + }); + } + return Object.assign(state, { + escapeNextChar: false, + startingCharClass: false + }); + }, initState); + + return charList; +} + +module.exports = { + meta: { + docs: { + description: 'disallow unnecessary regex characer class escape sequences', + category: 'Best Practices', + recommended: false + }, + fixable: 'code', + schema: [{ + 'type': 'object', + 'properties': { + 'override': { + 'type': 'array', + 'items': { 'type': 'string' }, + 'uniqueItems': true + } + }, + 'additionalProperties': false + }] + }, + + create(context) { + const overrideSet = new Set(context.options.length + ? context.options[0].override || [] + : []); + + /** + * Reports a node + * @param {ASTNode} node The node to report + * @param {number} startOffset The backslash's offset + * from the start of the node + * @param {string} character The uselessly escaped character + * (not including the backslash) + * @returns {void} + */ + function report(node, startOffset, character) { + context.report({ + node, + loc: { + line: node.loc.start.line, + column: node.loc.start.column + startOffset + }, + message: 'Unnecessary regex escape in character' + + ' class: \\{{character}}', + data: { character }, + fix: (fixer) => { + const start = node.range[0] + startOffset; + return fixer.replaceTextRange([start, start + 1], ''); + } + }); + } + + /** + * Checks if a node has superflous escape character + * in regex character class. + * + * @param {ASTNode} node - node to check. + * @returns {void} + */ + function check(node) { + if (node.regex) { + parseRegExpCharClass(node.regex.pattern) + .forEach((charClass) => { + charClass + .chars + // The '-' character is a special case if is not at + // either edge of the character class. To account for this, + // filter out '-' characters that appear in the middle of a + // character class. + .filter((charInfo) => !(charInfo.text === '-' && + (charInfo.index !== charClass.start && + charInfo.index !== charClass.end))) + + // The '^' character is a special case if it's at the beginning + // of the character class. To account for this, filter out '^' + // characters that appear at the start of a character class. + // + .filter((charInfo) => !(charInfo.text === '^' && + charInfo.index === charClass.start)) + + // Filter out characters that aren't escaped. + .filter((charInfo) => charInfo.escaped) + + // Filter out characters that are valid to escape, based on + // their position in the regular expression. + .filter((charInfo) => !REGEX_CHARCLASS_ESCAPES.has(charInfo.text)) + + // Filter out overridden character list. + .filter((charInfo) => !overrideSet.has(charInfo.text)) + + // Report all the remaining characters. + .forEach((charInfo) => + report(node, charInfo.index, charInfo.text)); + }); + } + } + + return { + Literal: check + }; + } +}; From c7cd400fcb8c7111618fa779ffa9bbdb83fed705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E4=B8=B6=E8=A8=80?= Date: Thu, 24 Nov 2016 16:28:02 +0800 Subject: [PATCH 014/195] doc: fix crypto "decipher.setAAD()" typo PR-URL: https://github.com/nodejs/node/pull/9782 Reviewed-By: Brian White Reviewed-By: Italo A. Casas Reviewed-By: Sam Roberts --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 62588bfa43c047..9526e06353481e 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -330,7 +330,7 @@ added: v1.0.0 --> When using an authenticated encryption mode (only `GCM` is currently -supported), the `cipher.setAAD()` method sets the value used for the +supported), the `decipher.setAAD()` method sets the value used for the _additional authenticated data_ (AAD) input parameter. Returns `this` for method chaining. From a8d84d5b50b206aefbb5b180511fe785a5913bbd Mon Sep 17 00:00:00 2001 From: atrioom Date: Tue, 15 Nov 2016 12:47:30 +0100 Subject: [PATCH 015/195] doc: changed order of invocations in https.request() example. When you call req.end() before you add .on listeners you get an Error that you can't call .on on undefined. PR-URL: https://github.com/nodejs/node/pull/9614 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- doc/api/https.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/https.md b/doc/api/https.md index c2231dca1830e5..355fd7b133a76d 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -158,11 +158,11 @@ var req = https.request(options, (res) => { process.stdout.write(d); }); }); -req.end(); req.on('error', (e) => { console.error(e); }); +req.end(); ``` The options argument has the following options From 6297b9afc568a49e717ed6dd9370818d5958a481 Mon Sep 17 00:00:00 2001 From: Dan Koster Date: Sun, 16 Oct 2016 22:07:49 -0700 Subject: [PATCH 016/195] doc: minor fixes event-loop-timers-and-nexttick.md Minor fixes and enhancements to event-loop-timers-and-nexttick.md Added missing "be" Added a link to REPL docs Added definition of libuv and a link PR-URL: https://github.com/nodejs/node/pull/9126 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- doc/topics/event-loop-timers-and-nexttick.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/topics/event-loop-timers-and-nexttick.md b/doc/topics/event-loop-timers-and-nexttick.md index ca2e1b555981c7..d7d0ee96e9c438 100644 --- a/doc/topics/event-loop-timers-and-nexttick.md +++ b/doc/topics/event-loop-timers-and-nexttick.md @@ -9,13 +9,13 @@ offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells Node.js so that the appropriate callback -may added to the **poll** queue to eventually be executed. We'll explain +may be added to the **poll** queue to eventually be executed. We'll explain this in further detail later in this topic. ## Event Loop Explained When Node.js starts, it initializes the event loop, processes the -provided input script (or drops into the REPL, which is not covered in +provided input script (or drops into the [REPL][], which is not covered in this document) which may make async API calls, schedule timers, or call `process.nextTick()`, then begins processing the event loop. @@ -144,7 +144,9 @@ the timer's callback. In this example, you will see that the total delay between the timer being scheduled and its callback being executed will be 105ms. -Note: To prevent the **poll** phase from starving the event loop, libuv +Note: To prevent the **poll** phase from starving the event loop, [libuv] +(http://libuv.org/) (the C library that implements the Node.js +event loop and all of the asynchronous behaviors of the platform) also has a hard maximum (system dependent) before it stops polling for more events. @@ -480,3 +482,5 @@ myEmitter.on('event', function() { console.log('an event occurred!'); }); ``` + +[REPL]: https://nodejs.org/api/repl.html#repl_repl From 4971c3bb798bff5be90191f2c821034d3b5c2b52 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 21 Nov 2016 11:05:24 -0800 Subject: [PATCH 017/195] test: fix flaky test-dgram-empty-packet & friends * Liberal use of common.mustCall() * Rename test-dgram-empty-packet -> test-dgram-send-empty-packet * Remove use of timers to avoid CI failures like seen in the Ref below: ``` not ok 237 parallel/test-dgram-empty-packet --- duration_ms: 0.717 severity: fail stack: |- ... throw new Error('Timeout'); ^ Error: Timeout at Timeout._onTimeout ... at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) ``` Refs: https://ci.nodejs.org/job/node-test-commit-freebsd/5341/nodes=freebsd11-x64/console: PR-URL: https://github.com/nodejs/node/pull/9724 Reviewed-By: Santiago Gimeno --- test/parallel/test-dgram-empty-packet.js | 40 ------------------- test/parallel/test-dgram-send-empty-array.js | 16 +++++--- test/parallel/test-dgram-send-empty-buffer.js | 21 +++++----- test/parallel/test-dgram-send-empty-packet.js | 34 ++++++++++++++++ 4 files changed, 56 insertions(+), 55 deletions(-) delete mode 100644 test/parallel/test-dgram-empty-packet.js create mode 100644 test/parallel/test-dgram-send-empty-packet.js diff --git a/test/parallel/test-dgram-empty-packet.js b/test/parallel/test-dgram-empty-packet.js deleted file mode 100644 index 34bce4e07aede7..00000000000000 --- a/test/parallel/test-dgram-empty-packet.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; -const common = require('../common'); -const dgram = require('dgram'); - -let callbacks = 0; -let timer; - -if (common.isOSX) { - common.skip('because of 17894467 Apple bug'); - return; -} - -const client = dgram.createSocket('udp4'); - -client.bind(0, function() { - - function callback() { - callbacks++; - if (callbacks === 2) { - clearTimeout(timer); - client.close(); - } else if (callbacks > 2) { - throw new Error('the callbacks should be called only two times'); - } - } - - client.on('message', function(buffer, bytes) { - callback(); - }); - - const port = this.address().port; - client.send( - Buffer.allocUnsafe(1), 0, 0, port, '127.0.0.1', (err, len) => { - callback(); - }); - - timer = setTimeout(function() { - throw new Error('Timeout'); - }, 200); -}); diff --git a/test/parallel/test-dgram-send-empty-array.js b/test/parallel/test-dgram-send-empty-array.js index f9de345f112254..442803e6db8632 100644 --- a/test/parallel/test-dgram-send-empty-array.js +++ b/test/parallel/test-dgram-send-empty-array.js @@ -1,24 +1,30 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); -const dgram = require('dgram'); if (common.isOSX) { common.skip('because of 17894467 Apple bug'); return; } +const assert = require('assert'); +const dgram = require('dgram'); + const client = dgram.createSocket('udp4'); +var interval; + client.on('message', common.mustCall(function onMessage(buf, info) { const expected = Buffer.alloc(0); assert.ok(buf.equals(expected), 'message was received correctly'); + clearInterval(interval); client.close(); })); -client.on('listening', function() { - client.send([], this.address().port, common.localhostIPv4); -}); +client.on('listening', common.mustCall(function() { + interval = setInterval(function() { + client.send([], client.address().port, common.localhostIPv4); + }, 10); +})); client.bind(0); diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js index ac541a9c243947..70e7e46e0a327e 100644 --- a/test/parallel/test-dgram-send-empty-buffer.js +++ b/test/parallel/test-dgram-send-empty-buffer.js @@ -1,26 +1,27 @@ 'use strict'; const common = require('../common'); -const dgram = require('dgram'); +const assert = require('assert'); if (common.isOSX) { common.skip('because of 17894467 Apple bug'); return; } +const dgram = require('dgram'); + const client = dgram.createSocket('udp4'); -client.bind(0, function() { +client.bind(0, common.mustCall(function() { const port = this.address().port; - client.on('message', common.mustCall(function onMessage(buffer, bytes) { - clearTimeout(timer); + client.on('message', common.mustCall(function onMessage(buffer) { + assert.strictEqual(buffer.length, 0); + clearInterval(interval); client.close(); })); const buf = Buffer.alloc(0); - client.send(buf, 0, 0, port, '127.0.0.1', function(err, len) { }); - - const timer = setTimeout(function() { - throw new Error('Timeout'); - }, common.platformTimeout(200)); -}); + var interval = setInterval(function() { + client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {})); + }, 10); +})); diff --git a/test/parallel/test-dgram-send-empty-packet.js b/test/parallel/test-dgram-send-empty-packet.js new file mode 100644 index 00000000000000..131e808aec0b72 --- /dev/null +++ b/test/parallel/test-dgram-send-empty-packet.js @@ -0,0 +1,34 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +if (common.isOSX) { + common.skip('because of 17894467 Apple bug'); + return; +} + +const dgram = require('dgram'); + +const client = dgram.createSocket('udp4'); + +client.bind(0, common.mustCall(function() { + + client.on('message', common.mustCall(callback)); + + const port = this.address().port; + const buf = Buffer.alloc(1); + + const interval = setInterval(function() { + client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(callback)); + }, 10); + + function callback(firstArg) { + // If client.send() callback, firstArg should be null. + // If client.on('message') listener, firstArg should be a 0-length buffer. + if (firstArg instanceof Buffer) { + assert.strictEqual(firstArg.length, 0); + clearInterval(interval); + client.close(); + } + } +})); From 2b7ecb5012018644b0f32cf1a8067e907be943ec Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Wed, 23 Nov 2016 10:12:02 -0500 Subject: [PATCH 018/195] test: exclude no_interleaved_stdio test for AIX pseudo-tty/no_interleaved_stdio has hung a few times in the last couple of days on AIX. We believe it is not a Node.js issue but an issue with python on AIX. Its being investigated under: https://github.com/nodejs/node/issues/7973. Excluding this additional test until we can resolve the python issue. Fixes https://github.com/nodejs/node/issues/9765 PR-URL: https://github.com/nodejs/node/pull/9772 Reviewed-By: Sam Roberts Reviewed-By: Gibson Fahnestock --- test/pseudo-tty/pseudo-tty.status | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pseudo-tty/pseudo-tty.status b/test/pseudo-tty/pseudo-tty.status index 27c6f75e10648c..e16bb28cd7be61 100644 --- a/test/pseudo-tty/pseudo-tty.status +++ b/test/pseudo-tty/pseudo-tty.status @@ -3,3 +3,4 @@ prefix pseudo-tty [$system==aix] # test issue only, covered under https://github.com/nodejs/node/issues/7973 no_dropped_stdio : SKIP +no_interleaved_stdio : SKIP From 80a3934cd7fd988e8941d03b1eae9da89f18fe0b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 23 Nov 2016 14:14:20 +0100 Subject: [PATCH 019/195] inspector: /json/version returns object, not array Make /json/version return an object instead of an object wrapped in an array. Fixes: https://github.com/nodejs/node/issues/9760 PR-URL: https://github.com/nodejs/node/pull/9762 Reviewed-By: Colin Ihrig Reviewed-By: Eugene Ostroukhov Reviewed-By: Santiago Gimeno --- src/inspector_agent.cc | 21 ++++++++++++++------- test/inspector/test-inspector.js | 6 ++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index a01ec0c2f5e2c0..fd7968ff68ced1 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -89,23 +89,30 @@ void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) { buf->len = len; } -void SendHttpResponse(InspectorSocket* socket, const std::string& response) { +void SendHttpResponse(InspectorSocket* socket, const char* response, + size_t size) { const char HEADERS[] = "HTTP/1.0 200 OK\r\n" "Content-Type: application/json; charset=UTF-8\r\n" "Cache-Control: no-cache\r\n" "Content-Length: %zu\r\n" "\r\n"; char header[sizeof(HEADERS) + 20]; - int header_len = snprintf(header, sizeof(header), HEADERS, response.size()); + int header_len = snprintf(header, sizeof(header), HEADERS, size); inspector_write(socket, header, header_len); - inspector_write(socket, response.data(), response.size()); + inspector_write(socket, response, size); +} + +void SendHttpResponse(InspectorSocket* socket, const std::string& response) { + SendHttpResponse(socket, response.data(), response.size()); } void SendVersionResponse(InspectorSocket* socket) { - std::map response; - response["Browser"] = "node.js/" NODE_VERSION; - response["Protocol-Version"] = "1.1"; - SendHttpResponse(socket, MapToString(response)); + static const char response[] = + "{\n" + " \"Browser\": \"node.js/" NODE_VERSION "\",\n" + " \"Protocol-Version\": \"1.1\"\n" + "}\n"; + SendHttpResponse(socket, response, sizeof(response) - 1); } std::string GetProcessTitle() { diff --git a/test/inspector/test-inspector.js b/test/inspector/test-inspector.js index 75c645bb222781..7e53eaa55fffb7 100644 --- a/test/inspector/test-inspector.js +++ b/test/inspector/test-inspector.js @@ -17,6 +17,12 @@ function checkListResponse(err, response) { function checkVersion(err, response) { assert.ifError(err); assert.ok(response); + const expected = { + 'Browser': 'node.js/' + process.version, + 'Protocol-Version': '1.1', + }; + assert.strictEqual(JSON.stringify(response), + JSON.stringify(expected)); } function checkBadPath(err, response) { From 4fa84c9589a2eb040b530353efa23786820894b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E4=B8=B6=E8=A8=80?= Date: Fri, 25 Nov 2016 15:07:24 +0800 Subject: [PATCH 020/195] doc: fix crypto Verify cut-n-paste from Sign Verify documentation had cut-n-pasted documentation from Sign. PR-URL: https://github.com/nodejs/node/pull/9796 Reviewed-By: Anna Henningsen Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Sam Roberts Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: Prince John Wesley --- doc/api/crypto.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9526e06353481e..4dec3e0aca17f8 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -935,8 +935,8 @@ of two ways: - Using the [`verify.update()`][] and [`verify.verify()`][] methods to verify the signature. - The [`crypto.createSign()`][] method is used to create `Sign` instances. - `Sign` objects are not to be created directly using the `new` keyword. +The [`crypto.createVerify()`][] method is used to create `Verify` instances. +`Verify` objects are not to be created directly using the `new` keyword. Example: Using `Verify` objects as streams: From 9554a974d1acc1bebb17b0ba1ad94d755901b02f Mon Sep 17 00:00:00 2001 From: Pedro Lima Date: Fri, 21 Oct 2016 03:21:47 +0000 Subject: [PATCH 021/195] https: name anonymous functions in https MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Naming anonymous function in the https module PR-URL: https://github.com/nodejs/node/pull/9217 Ref: https://github.com/nodejs/node/issues/8913 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso --- lib/https.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/https.js b/lib/https.js index b8969b68452451..26b6cbf279a15f 100644 --- a/lib/https.js +++ b/lib/https.js @@ -31,7 +31,7 @@ function Server(opts, requestListener) { this.addListener('request', requestListener); } - this.addListener('tlsClientError', function(err, conn) { + this.addListener('tlsClientError', function addListener(err, conn) { if (!this.emit('clientError', err, conn)) conn.destroy(err); }); @@ -43,7 +43,7 @@ exports.Server = Server; Server.prototype.setTimeout = http.Server.prototype.setTimeout; -exports.createServer = function(opts, requestListener) { +exports.createServer = function createServer(opts, requestListener) { return new Server(opts, requestListener); }; @@ -112,7 +112,7 @@ function Agent(options) { inherits(Agent, http.Agent); Agent.prototype.createConnection = createConnection; -Agent.prototype.getName = function(options) { +Agent.prototype.getName = function getName(options) { var name = http.Agent.prototype.getName.call(this, options); name += ':'; @@ -186,7 +186,7 @@ const globalAgent = new Agent(); exports.globalAgent = globalAgent; exports.Agent = Agent; -exports.request = function(options, cb) { +exports.request = function request(options, cb) { if (typeof options === 'string') { options = url.parse(options); if (!options.hostname) { @@ -199,7 +199,7 @@ exports.request = function(options, cb) { return http.request(options, cb); }; -exports.get = function(options, cb) { +exports.get = function get(options, cb) { var req = exports.request(options, cb); req.end(); return req; From b763a31af0d75bb2c718bd825a2b207ea49b67c4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 23 Nov 2016 22:19:24 -0800 Subject: [PATCH 022/195] test: refactor test-child-process-exec-error * assert.equal() -> assert.strictEqual() * regex -> .include() * Change variable representing a function from `fun` to idiomatic `fn` * var -> const PR-URL: https://github.com/nodejs/node/pull/9780 Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Evan Lucas Reviewed-By: Prince John Wesley --- test/parallel/test-child-process-exec-error.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-child-process-exec-error.js b/test/parallel/test-child-process-exec-error.js index 006a2eebb912d0..f937fec5d252fc 100644 --- a/test/parallel/test-child-process-exec-error.js +++ b/test/parallel/test-child-process-exec-error.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var child_process = require('child_process'); +const common = require('../common'); +const assert = require('assert'); +const child_process = require('child_process'); -function test(fun, code) { - fun('does-not-exist', common.mustCall(function(err) { - assert.equal(err.code, code); - assert(/does\-not\-exist/.test(err.cmd)); +function test(fn, code) { + fn('does-not-exist', common.mustCall(function(err) { + assert.strictEqual(err.code, code); + assert(err.cmd.includes('does-not-exist')); })); } From 2ee3543e040e62040237d123d470cb346f4fad48 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 23 Nov 2016 22:25:57 -0800 Subject: [PATCH 023/195] tools: remove unneeded escaping in generate.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `-` does not need to be escaped in a regular expression outside of character classes. PR-URL: https://github.com/nodejs/node/pull/9781 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Prince John Wesley Reviewed-By: Michaël Zasso --- tools/doc/generate.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 077e740432c837..31b23c52a08ba7 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -13,14 +13,14 @@ let inputFile = null; let nodeVersion = null; args.forEach(function(arg) { - if (!arg.match(/^\-\-/)) { + if (!arg.match(/^--/)) { inputFile = arg; - } else if (arg.match(/^\-\-format=/)) { - format = arg.replace(/^\-\-format=/, ''); - } else if (arg.match(/^\-\-template=/)) { - template = arg.replace(/^\-\-template=/, ''); - } else if (arg.match(/^\-\-node\-version=/)) { - nodeVersion = arg.replace(/^\-\-node\-version=/, ''); + } else if (arg.match(/^--format=/)) { + format = arg.replace(/^--format=/, ''); + } else if (arg.match(/^--template=/)) { + template = arg.replace(/^--template=/, ''); + } else if (arg.match(/^--node-version=/)) { + nodeVersion = arg.replace(/^--node-version=/, ''); } }); From d51c856f11aad43f8c43d77630e035c9f11c2d73 Mon Sep 17 00:00:00 2001 From: Yosuke Saito Date: Sat, 12 Nov 2016 16:47:27 +0900 Subject: [PATCH 024/195] test: fix test-http-status-reason-invalid-chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use port 0 instead of common.PORT, and use server address instead of localhost to follow writing test guideline. This is a part of Code And Learn at NodeFest 2016 Challenge in Tokyo. PR-URL: https://github.com/nodejs/node/pull/9572 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Santiago Gimeno Reviewed-By: Shigeki Ohtsu Reviewed-By: James M Snell --- test/parallel/test-http-status-reason-invalid-chars.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js index 7a8564a906131a..245822d0146975 100644 --- a/test/parallel/test-http-status-reason-invalid-chars.js +++ b/test/parallel/test-http-status-reason-invalid-chars.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); +const net = require('net'); function explicit(req, res) { assert.throws(() => { @@ -32,8 +33,10 @@ const server = http.createServer((req, res) => { } else { implicit(req, res); } -}).listen(common.PORT, common.mustCall(() => { - const url = `http://localhost:${common.PORT}`; +}).listen(0, common.mustCall(() => { + const addr = server.address().address; + const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr; + const url = `http://${hostname}:${server.address().port}`; let left = 2; const check = common.mustCall((res) => { left--; From d31a41149df64ea08a04f474f41d176707e5d6ce Mon Sep 17 00:00:00 2001 From: mkamakura Date: Sat, 12 Nov 2016 16:53:23 +0900 Subject: [PATCH 025/195] test: fix test-tls-connect-address-family MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use port 0 instead of common.PORT. PR-URL: https://github.com/nodejs/node/pull/9573 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Michaël Zasso Reviewed-By: Santiago Gimeno --- test/parallel/test-tls-connect-address-family.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-connect-address-family.js b/test/parallel/test-tls-connect-address-family.js index 35216d91f6e49f..f22831f395a8dd 100644 --- a/test/parallel/test-tls-connect-address-family.js +++ b/test/parallel/test-tls-connect-address-family.js @@ -18,10 +18,10 @@ function runTest() { const ciphers = 'AECDH-NULL-SHA'; tls.createServer({ ciphers }, common.mustCall(function() { this.close(); - })).listen(common.PORT, '::1', common.mustCall(function() { + })).listen(0, '::1', common.mustCall(function() { const options = { host: 'localhost', - port: common.PORT, + port: this.address().port, family: 6, ciphers: ciphers, rejectUnauthorized: false, From 88464ac6ac3dec0cd2d415b9b4321389dec6145a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 24 Nov 2016 11:43:35 -0800 Subject: [PATCH 026/195] benchmark: reformat code for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the benchmark code can be a little dense. Not *very* hard to read but perhaps harder than it needs to be. These changes (many of them whitespace-only) hopefully improve readability. There are also a few cases of `assert.equal()` that are changed to `assert.strictEqual()`. PR-URL: https://github.com/nodejs/node/pull/9790 Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig --- benchmark/_http-benchmarkers.js | 20 ++++++++++----- benchmark/arrays/var-int.js | 18 ++++++++++--- benchmark/arrays/zero-float.js | 18 ++++++++++--- benchmark/arrays/zero-int.js | 18 ++++++++++--- benchmark/buffers/buffer-base64-decode.js | 2 +- benchmark/buffers/buffer-indexof.js | 24 ++++++++++++++---- benchmark/buffers/buffer-read.js | 24 +++++++++++++----- benchmark/buffers/buffer-write.js | 25 ++++++++++++++----- benchmark/buffers/dataview-set.js | 25 ++++++++++++++----- benchmark/es/map-bench.js | 8 +++--- benchmark/http/_http_simple.js | 22 ++++++++++------ .../http/http_server_for_chunky_client.js | 7 ++++-- benchmark/misc/console.js | 12 ++++++--- benchmark/querystring/querystring-parse.js | 18 +++++++------ benchmark/tls/throughput.js | 10 +++++--- benchmark/tls/tls-connect.js | 19 ++++++++------ benchmark/util/format.js | 13 ++++++---- 17 files changed, 204 insertions(+), 79 deletions(-) diff --git a/benchmark/_http-benchmarkers.js b/benchmark/_http-benchmarkers.js index 581bed6b2dc9e6..5429bf386d85ac 100644 --- a/benchmark/_http-benchmarkers.js +++ b/benchmark/_http-benchmarkers.js @@ -15,8 +15,13 @@ function AutocannonBenchmarker() { } AutocannonBenchmarker.prototype.create = function(options) { - const args = ['-d', options.duration, '-c', options.connections, '-j', '-n', - `http://127.0.0.1:${options.port}${options.path}` ]; + const args = [ + '-d', options.duration, + '-c', options.connections, + '-j', + '-n', + `http://127.0.0.1:${options.port}${options.path}` + ]; const child = child_process.spawn(this.autocannon_exe, args); return child; }; @@ -43,8 +48,12 @@ function WrkBenchmarker() { } WrkBenchmarker.prototype.create = function(options) { - const args = ['-d', options.duration, '-c', options.connections, '-t', 8, - `http://127.0.0.1:${options.port}${options.path}` ]; + const args = [ + '-d', options.duration, + '-c', options.connections, + '-t', 8, + `http://127.0.0.1:${options.port}${options.path}` + ]; const child = child_process.spawn('wrk', args); return child; }; @@ -59,8 +68,7 @@ WrkBenchmarker.prototype.processResults = function(output) { } }; -const http_benchmarkers = [ new WrkBenchmarker(), - new AutocannonBenchmarker() ]; +const http_benchmarkers = [new WrkBenchmarker(), new AutocannonBenchmarker()]; const benchmarkers = {}; diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js index 74a73c9515fffa..36b0a908a59a4f 100644 --- a/benchmark/arrays/var-int.js +++ b/benchmark/arrays/var-int.js @@ -1,9 +1,21 @@ 'use strict'; var common = require('../common.js'); + +var types = [ + 'Array', + 'Buffer', + 'Int8Array', + 'Uint8Array', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array' +]; + var bench = common.createBenchmark(main, { - type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', - 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', - 'Float64Array'], + type: types, n: [25] }); diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js index e2569eed5c4e75..047e179234f33a 100644 --- a/benchmark/arrays/zero-float.js +++ b/benchmark/arrays/zero-float.js @@ -1,9 +1,21 @@ 'use strict'; var common = require('../common.js'); + +var types = [ + 'Array', + 'Buffer', + 'Int8Array', + 'Uint8Array', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array' +]; + var bench = common.createBenchmark(main, { - type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', - 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', - 'Float64Array'], + type: types, n: [25] }); diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js index 8be70c1e87113a..4e5c97e8af0b9c 100644 --- a/benchmark/arrays/zero-int.js +++ b/benchmark/arrays/zero-int.js @@ -1,9 +1,21 @@ 'use strict'; var common = require('../common.js'); + +var types = [ + 'Array', + 'Buffer', + 'Int8Array', + 'Uint8Array', + 'Int16Array', + 'Uint16Array', + 'Int32Array', + 'Uint32Array', + 'Float32Array', + 'Float64Array' +]; + var bench = common.createBenchmark(main, { - type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', - 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', - 'Float64Array'], + type: types, n: [25] }); diff --git a/benchmark/buffers/buffer-base64-decode.js b/benchmark/buffers/buffer-base64-decode.js index 3497bfd05fd2a2..01f7f1bc91bc4a 100644 --- a/benchmark/buffers/buffer-base64-decode.js +++ b/benchmark/buffers/buffer-base64-decode.js @@ -7,7 +7,7 @@ const bench = common.createBenchmark(main, {}); function main(conf) { const s = 'abcd'.repeat(8 << 20); s.match(/./); // Flatten string. - assert.equal(s.length % 4, 0); + assert.strictEqual(s.length % 4, 0); const b = Buffer.allocUnsafe(s.length / 4 * 3); b.write(s, 0, s.length, 'base64'); bench.start(); diff --git a/benchmark/buffers/buffer-indexof.js b/benchmark/buffers/buffer-indexof.js index 380f40b23d8ab6..cae8b964aebbcf 100644 --- a/benchmark/buffers/buffer-indexof.js +++ b/benchmark/buffers/buffer-indexof.js @@ -3,12 +3,26 @@ var common = require('../common.js'); var fs = require('fs'); const path = require('path'); +const searchStrings = [ + '@', + 'SQ', + '10x', + '--l', + 'Alice', + 'Gryphon', + 'Panther', + 'Ou est ma chatte?', + 'found it very', + 'among mad people', + 'neighbouring pool', + 'Soo--oop', + 'aaaaaaaaaaaaaaaaa', + 'venture to go near the house till she had brought herself down to', + ' to the Caterpillar' +]; + var bench = common.createBenchmark(main, { - search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther', - 'Ou est ma chatte?', 'found it very', 'among mad people', - 'neighbouring pool', 'Soo--oop', 'aaaaaaaaaaaaaaaaa', - 'venture to go near the house till she had brought herself down to', - ' to the Caterpillar'], + search: searchStrings, encoding: ['undefined', 'utf8', 'ucs2', 'binary'], type: ['buffer', 'string'], iter: [1] diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js index 1cdc4bc4697067..d23bd029f8bd44 100644 --- a/benchmark/buffers/buffer-read.js +++ b/benchmark/buffers/buffer-read.js @@ -1,15 +1,27 @@ 'use strict'; var common = require('../common.js'); +var types = [ + 'UInt8', + 'UInt16LE', + 'UInt16BE', + 'UInt32LE', + 'UInt32BE', + 'Int8', + 'Int16LE', + 'Int16BE', + 'Int32LE', + 'Int32BE', + 'FloatLE', + 'FloatBE', + 'DoubleLE', + 'DoubleBE' +]; + var bench = common.createBenchmark(main, { noAssert: ['false', 'true'], buffer: ['fast', 'slow'], - type: ['UInt8', 'UInt16LE', 'UInt16BE', - 'UInt32LE', 'UInt32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'FloatLE', 'FloatBE', - 'DoubleLE', 'DoubleBE'], + type: types, millions: [1] }); diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js index ae78eaf91d0147..32c733045335cd 100644 --- a/benchmark/buffers/buffer-write.js +++ b/benchmark/buffers/buffer-write.js @@ -1,14 +1,27 @@ 'use strict'; var common = require('../common.js'); + +var types = [ + 'UInt8', + 'UInt16LE', + 'UInt16BE', + 'UInt32LE', + 'UInt32BE', + 'Int8', + 'Int16LE', + 'Int16BE', + 'Int32LE', + 'Int32BE', + 'FloatLE', + 'FloatBE', + 'DoubleLE', + 'DoubleBE' +]; + var bench = common.createBenchmark(main, { noAssert: ['false', 'true'], buffer: ['fast', 'slow'], - type: ['UInt8', 'UInt16LE', 'UInt16BE', - 'UInt32LE', 'UInt32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'FloatLE', 'FloatBE', - 'DoubleLE', 'DoubleBE'], + type: types, millions: [1] }); diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js index a208effd82bf19..717a77de71d641 100644 --- a/benchmark/buffers/dataview-set.js +++ b/benchmark/buffers/dataview-set.js @@ -1,12 +1,25 @@ 'use strict'; var common = require('../common.js'); + +var types = [ + 'Uint8', + 'Uint16LE', + 'Uint16BE', + 'Uint32LE', + 'Uint32BE', + 'Int8', + 'Int16LE', + 'Int16BE', + 'Int32LE', + 'Int32BE', + 'Float32LE', + 'Float32BE', + 'Float64LE', + 'Float64BE' +]; + var bench = common.createBenchmark(main, { - type: ['Uint8', 'Uint16LE', 'Uint16BE', - 'Uint32LE', 'Uint32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'Float32LE', 'Float32BE', - 'Float64LE', 'Float64BE'], + type: types, millions: [1] }); diff --git a/benchmark/es/map-bench.js b/benchmark/es/map-bench.js index 574da25d53f2f2..047fc05abdc92f 100644 --- a/benchmark/es/map-bench.js +++ b/benchmark/es/map-bench.js @@ -15,7 +15,7 @@ function runObject(n) { for (; i < n; i++) { m['i' + i] = i; m['s' + i] = String(i); - assert.equal(m['i' + i], m['s' + i]); + assert.strictEqual(String(m['i' + i]), m['s' + i]); m['i' + i] = undefined; m['s' + i] = undefined; } @@ -29,7 +29,7 @@ function runNullProtoObject(n) { for (; i < n; i++) { m['i' + i] = i; m['s' + i] = String(i); - assert.equal(m['i' + i], m['s' + i]); + assert.strictEqual(String(m['i' + i]), m['s' + i]); m['i' + i] = undefined; m['s' + i] = undefined; } @@ -53,7 +53,7 @@ function runFakeMap(n) { for (; i < n; i++) { m.set('i' + i, i); m.set('s' + i, String(i)); - assert.equal(m.get('i' + i), m.get('s' + i)); + assert.strictEqual(String(m.get('i' + i)), m.get('s' + i)); m.set('i' + i, undefined); m.set('s' + i, undefined); } @@ -67,7 +67,7 @@ function runMap(n) { for (; i < n; i++) { m.set('i' + i, i); m.set('s' + i, String(i)); - assert.equal(m.get('i' + i), m.get('s' + i)); + assert.strictEqual(String(m.get('i' + i)), m.get('s' + i)); m.set('i' + i, undefined); m.set('s' + i, undefined); } diff --git a/benchmark/http/_http_simple.js b/benchmark/http/_http_simple.js index 1c965b21c15ca0..644601864dd857 100644 --- a/benchmark/http/_http_simple.js +++ b/benchmark/http/_http_simple.js @@ -75,8 +75,11 @@ var server = module.exports = http.createServer(function(req, res) { body = fixed; } else if (command === 'echo') { - res.writeHead(200, { 'Content-Type': 'text/plain', - 'Transfer-Encoding': 'chunked' }); + const headers = { + 'Content-Type': 'text/plain', + 'Transfer-Encoding': 'chunked' + }; + res.writeHead(200, headers); req.pipe(res); return; @@ -88,8 +91,11 @@ var server = module.exports = http.createServer(function(req, res) { // example: http://localhost:port/bytes/512/4 // sends a 512 byte body in 4 chunks of 128 bytes if (n_chunks > 0) { - res.writeHead(status, { 'Content-Type': 'text/plain', - 'Transfer-Encoding': 'chunked' }); + const headers = { + 'Content-Type': 'text/plain', + 'Transfer-Encoding': 'chunked' + }; + res.writeHead(status, headers); // send body in chunks var len = body.length; var step = Math.floor(len / n_chunks) || 1; @@ -99,10 +105,12 @@ var server = module.exports = http.createServer(function(req, res) { } res.end(body.slice((n_chunks - 1) * step)); } else { - var content_length = body.length.toString(); + const headers = { + 'Content-Type': 'text/plain', + 'Content-Length': body.length.toString() + }; - res.writeHead(status, { 'Content-Type': 'text/plain', - 'Content-Length': content_length }); + res.writeHead(status, headers); res.end(body); } }); diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js index fade895aa07fdd..e58ba5f5a15cc7 100644 --- a/benchmark/http/http_server_for_chunky_client.js +++ b/benchmark/http/http_server_for_chunky_client.js @@ -21,8 +21,11 @@ try { } catch (e) { /* ignore */ } server = http.createServer(function(req, res) { - res.writeHead(200, { 'content-type': 'text/plain', - 'content-length': '2' }); + var headers = { + 'content-type': 'text/plain', + 'content-length': '2' + }; + res.writeHead(200, headers); res.end('ok'); }); diff --git a/benchmark/misc/console.js b/benchmark/misc/console.js index 17f7ed0f4d96b0..9a08a411c51f82 100644 --- a/benchmark/misc/console.js +++ b/benchmark/misc/console.js @@ -8,11 +8,15 @@ const v8 = require('v8'); v8.setFlagsFromString('--allow_natives_syntax'); +const methods = [ + 'restAndSpread', + 'argumentsAndApply', + 'restAndApply', + 'restAndConcat' +]; + var bench = common.createBenchmark(main, { - method: ['restAndSpread', - 'argumentsAndApply', - 'restAndApply', - 'restAndConcat'], + method: methods, concat: [1, 0], n: [1000000] }); diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js index 590b89f307c697..d78ef99f84f3d4 100644 --- a/benchmark/querystring/querystring-parse.js +++ b/benchmark/querystring/querystring-parse.js @@ -3,14 +3,18 @@ var common = require('../common.js'); var querystring = require('querystring'); var v8 = require('v8'); +var types = [ + 'noencode', + 'multicharsep', + 'encodemany', + 'encodelast', + 'multivalue', + 'multivaluemany', + 'manypairs' +]; + var bench = common.createBenchmark(main, { - type: ['noencode', - 'multicharsep', - 'encodemany', - 'encodelast', - 'multivalue', - 'multivaluemany', - 'manypairs'], + type: types, n: [1e6], }); diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js index d0de99e7b54b85..d3b7d0c02237a2 100644 --- a/benchmark/tls/throughput.js +++ b/benchmark/tls/throughput.js @@ -37,10 +37,12 @@ function main(conf) { throw new Error('invalid type'); } - options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), - cert: fs.readFileSync(cert_dir + '/test_cert.pem'), - ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], - ciphers: 'AES256-GCM-SHA384' }; + options = { + key: fs.readFileSync(cert_dir + '/test_key.pem'), + cert: fs.readFileSync(cert_dir + '/test_cert.pem'), + ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], + ciphers: 'AES256-GCM-SHA384' + }; server = tls.createServer(options, onConnection); setTimeout(done, dur * 1000); diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index 6ed4253f97fca8..5ca67f3230d3c8 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -20,11 +20,13 @@ function main(conf) { dur = +conf.dur; concurrency = +conf.concurrency; - var cert_dir = path.resolve(__dirname, '../../test/fixtures'), - options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), - cert: fs.readFileSync(cert_dir + '/test_cert.pem'), - ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], - ciphers: 'AES256-GCM-SHA384' }; + var cert_dir = path.resolve(__dirname, '../../test/fixtures'); + var options = { + key: fs.readFileSync(cert_dir + '/test_key.pem'), + cert: fs.readFileSync(cert_dir + '/test_cert.pem'), + ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], + ciphers: 'AES256-GCM-SHA384' + }; server = tls.createServer(options, onConnection); server.listen(common.PORT, onListening); @@ -42,8 +44,11 @@ function onConnection(conn) { } function makeConnection() { - var conn = tls.connect({ port: common.PORT, - rejectUnauthorized: false }, function() { + var options = { + port: common.PORT, + rejectUnauthorized: false + }; + var conn = tls.connect(options, function() { clientConn++; conn.on('error', function(er) { console.error('client error', er); diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 05176aa24fb01f..8040554ba0861a 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -3,13 +3,16 @@ const util = require('util'); const common = require('../common'); const v8 = require('v8'); +const types = [ + 'string', + 'number', + 'object', + 'unknown', + 'no-replace' +]; const bench = common.createBenchmark(main, { n: [1e6], - type: ['string', - 'number', - 'object', - 'unknown', - 'no-replace'] + type: types }); const inputs = { From 3f1b068644b1561183fba98ae84e0f3195a6fa35 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 21 Nov 2016 21:25:37 -0800 Subject: [PATCH 027/195] test: refactor common.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove unused common.faketimeCli * remove mosly-unused common.testDir * assert.ok(false...) -> fail() * alphabetize list of known globals * .indexOf() -> .includes() PR-URL: https://github.com/nodejs/node/pull/9732 Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson Reviewed-By: Michaël Zasso --- test/README.md | 11 -------- test/common.js | 47 ++++++++++++++----------------- test/parallel/test-npm-install.js | 3 +- 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/test/README.md b/test/README.md index 93f1090fef7323..1c3303435db517 100644 --- a/test/README.md +++ b/test/README.md @@ -205,11 +205,6 @@ Checks if there are multiple localhosts available. Throws an `AssertionError` with `msg` -### faketimeCli -* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - -Return the path to the fake. - ### fileExists(pathname) * pathname [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) * return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) @@ -365,12 +360,6 @@ Synchronous version of `spawnCat`. Synchronous version of `spawnPwd`. -### testDir - -* return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) - -Path to the 'test' directory. - ### tmpDir * return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) diff --git a/test/common.js b/test/common.js index 3bbf7d87300ccc..3c769345dd6b31 100644 --- a/test/common.js +++ b/test/common.js @@ -12,8 +12,7 @@ const Timer = process.binding('timer_wrap').Timer; const testRoot = process.env.NODE_TEST_DIR ? path.resolve(process.env.NODE_TEST_DIR) : __dirname; -exports.testDir = __dirname; -exports.fixturesDir = path.join(exports.testDir, 'fixtures'); +exports.fixturesDir = path.join(__dirname, 'fixtures'); exports.tmpDirName = 'tmp'; // PORT should match the definition in test/testpy/__init__.py. exports.PORT = +process.env.NODE_COMMON_PORT || 12346; @@ -195,13 +194,6 @@ if (exports.isWindows) { exports.PIPE = exports.tmpDir + '/test.sock'; } -if (exports.isWindows) { - exports.faketimeCli = false; -} else { - exports.faketimeCli = path.join(__dirname, '..', 'tools', 'faketime', 'src', - 'faketime'); -} - var ifaces = os.networkInterfaces(); exports.hasIPv6 = Object.keys(ifaces).some(function(name) { return /lo/.test(name) && ifaces[name].some(function(info) { @@ -285,17 +277,19 @@ exports.platformTimeout = function(ms) { return ms; // ARMv8+ }; -var knownGlobals = [setTimeout, - setInterval, - setImmediate, - clearTimeout, - clearInterval, - clearImmediate, - console, - constructor, // Enumerable in V8 3.21. - Buffer, - process, - global]; +var knownGlobals = [ + Buffer, + clearImmediate, + clearInterval, + clearTimeout, + console, + constructor, // Enumerable in V8 3.21. + global, + process, + setImmediate, + setInterval, + setTimeout +]; if (global.gc) { knownGlobals.push(global.gc); @@ -360,7 +354,7 @@ function leakedGlobals() { var leaked = []; for (var val in global) - if (-1 === knownGlobals.indexOf(global[val])) + if (!knownGlobals.includes(global[val])) leaked.push(val); return leaked; @@ -375,7 +369,7 @@ process.on('exit', function() { var leaked = leakedGlobals(); if (leaked.length > 0) { console.error('Unknown globals: %s', leaked); - assert.ok(false, 'Unknown global found'); + fail('Unknown global found'); } }); @@ -440,9 +434,10 @@ exports.fileExists = function(pathname) { } }; -exports.fail = function(msg) { +function fail(msg) { assert.fail(null, null, msg); -}; +} +exports.fail = fail; exports.skip = function(msg) { console.log(`1..0 # Skipped: ${msg}`); @@ -493,9 +488,9 @@ exports.nodeProcessAborted = function nodeProcessAborted(exitCode, signal) { // one of them (exit code or signal) needs to be set to one of // the expected exit codes or signals. if (signal !== null) { - return expectedSignals.indexOf(signal) > -1; + return expectedSignals.includes(signal); } else { - return expectedExitCodes.indexOf(exitCode) > -1; + return expectedExitCodes.includes(exitCode); } }; diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js index 60c590f40c0a37..c7f216fce5f2fa 100644 --- a/test/parallel/test-npm-install.js +++ b/test/parallel/test-npm-install.js @@ -17,7 +17,8 @@ const installDir = path.join(common.tmpDir, 'install-dir'); fs.mkdirSync(installDir); const npmPath = path.join( - common.testDir, + __dirname, + '..', '..', 'deps', 'npm', From 3b193defb2526ca0a3c11bde5a2f87e851c0c04e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 24 Nov 2016 15:04:14 -0800 Subject: [PATCH 028/195] test: fix flaky test-cluster-dgram-2 There is no guarantee that a dgram packet will be received. The test is currently written to only send exactly as many dgram packets as required assuming they are all received. As a result, failures like this may occur (from CI): ``` not ok 719 parallel/test-cluster-dgram-2 --- duration_ms: 120.39 severity: fail stack: |- timeout ``` This change has the workers send packets continuously until disconnect. PR-URL: https://github.com/nodejs/node/pull/9791 Reviewed-By: Santiago Gimeno --- test/parallel/test-cluster-dgram-2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js index 179b1ee15327e7..863e0fa358c73e 100644 --- a/test/parallel/test-cluster-dgram-2.js +++ b/test/parallel/test-cluster-dgram-2.js @@ -57,6 +57,13 @@ function worker() { // send(), explicitly bind them to an ephemeral port. socket.bind(0); - for (var i = 0; i < PACKETS_PER_WORKER; i++) + // There is no guarantee that a sent dgram packet will be received so keep + // sending until disconnect. + const interval = setInterval(() => { socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1'); + }, 1); + + cluster.worker.on('disconnect', () => { + clearInterval(interval); + }); } From d06f010482fbe8f20c2edc2e60b566c4787671e5 Mon Sep 17 00:00:00 2001 From: Michael Macherey Date: Wed, 5 Oct 2016 12:37:56 +0200 Subject: [PATCH 029/195] test: cleanup test-dgram-error-message-address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * var -> const * assert.equal() -> assert.strictEqual() * assert.notEqual() -> assert.notStrictEqual() Fixes: https://github.com/nodejs/node/issues/8925 PR-URL: https://github.com/nodejs/node/pull/8938 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michaël Zasso --- .../test-dgram-error-message-address.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-dgram-error-message-address.js b/test/parallel/test-dgram-error-message-address.js index d27b0043321aaf..3a87e8cabf3ca8 100644 --- a/test/parallel/test-dgram-error-message-address.js +++ b/test/parallel/test-dgram-error-message-address.js @@ -1,35 +1,35 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); // IPv4 Test -var socket_ipv4 = dgram.createSocket('udp4'); +const socket_ipv4 = dgram.createSocket('udp4'); socket_ipv4.on('listening', common.fail); socket_ipv4.on('error', common.mustCall(function(e) { assert.strictEqual(e.port, undefined); - assert.equal(e.message, 'bind EADDRNOTAVAIL 1.1.1.1'); - assert.equal(e.address, '1.1.1.1'); - assert.equal(e.code, 'EADDRNOTAVAIL'); + assert.strictEqual(e.message, 'bind EADDRNOTAVAIL 1.1.1.1'); + assert.strictEqual(e.address, '1.1.1.1'); + assert.strictEqual(e.code, 'EADDRNOTAVAIL'); socket_ipv4.close(); })); socket_ipv4.bind(0, '1.1.1.1'); // IPv6 Test -var socket_ipv6 = dgram.createSocket('udp6'); +const socket_ipv6 = dgram.createSocket('udp6'); socket_ipv6.on('listening', common.fail); socket_ipv6.on('error', common.mustCall(function(e) { // EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system. - var allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT']; - assert.notEqual(allowed.indexOf(e.code), -1); + const allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT']; + assert.notStrictEqual(allowed.indexOf(e.code), -1); assert.strictEqual(e.port, undefined); - assert.equal(e.message, 'bind ' + e.code + ' 111::1'); - assert.equal(e.address, '111::1'); + assert.strictEqual(e.message, 'bind ' + e.code + ' 111::1'); + assert.strictEqual(e.address, '111::1'); socket_ipv6.close(); })); From e0e62d1113673521e9f8db1284959cb2db704a81 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 9 Nov 2016 17:58:40 +0100 Subject: [PATCH 030/195] Revert "buffer: runtime deprecation of calling Buffer without new" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f2fe5583c434e9864a1171209908c3a24b9d54bb (https://github.com/nodejs/node/pull/8169) as the original justification for the runtime-deprecation does not appear to justify the disruption to Node’s existing ecosystem. Futhermore, the possibility of deprecating the Buffer constructor entirely in v8.0 might lead to people having to change their code twice. PR-URL: https://github.com/nodejs/node/pull/9529 Reviewed-By: Roman Reiss Reviewed-By: Myles Borins Reviewed-By: Sam Roberts Reviewed-By: Nikolai Vavilov Reviewed-By: Evan Lucas Reviewed-By: Michaël Zasso Reviewed-By: Rich Trott --- lib/buffer.js | 10 ---------- test/parallel/test-buffer-deprecated.js | 11 ----------- 2 files changed, 21 deletions(-) delete mode 100644 test/parallel/test-buffer-deprecated.js diff --git a/lib/buffer.js b/lib/buffer.js index b2325098bcbb9d..f4d16f41fc93dd 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -72,17 +72,7 @@ function alignPool() { * much breakage at this time. It's not likely that the Buffer constructors * would ever actually be removed. **/ -var newBufferWarned = false; function Buffer(arg, encodingOrOffset, length) { - if (!new.target && !newBufferWarned) { - newBufferWarned = true; - process.emitWarning( - 'Using Buffer without `new` will soon stop working. ' + - 'Use `new Buffer()`, or preferably ' + - '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.', - 'DeprecationWarning' - ); - } // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { diff --git a/test/parallel/test-buffer-deprecated.js b/test/parallel/test-buffer-deprecated.js deleted file mode 100644 index ec49321de43941..00000000000000 --- a/test/parallel/test-buffer-deprecated.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; -const common = require('../common'); - -const expected = - 'Using Buffer without `new` will soon stop working. ' + - 'Use `new Buffer()`, or preferably ' + - '`Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.'; -common.expectWarning('DeprecationWarning', expected); - -Buffer(1); -Buffer(1); From dcba25082f1e47e44647a1184757c9ab7114a92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 10:20:05 +0100 Subject: [PATCH 031/195] test: refactor and fix test-buffer-bytelength * assert.equal -> assert.strictEqual. * Fix incorrect use of string instead of RegExp in `throws` assertions. PR-URL: https://github.com/nodejs/node/pull/9808 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Prince John Wesley Reviewed-By: Rich Trott --- test/parallel/test-buffer-bytelength.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js index de122b4fc7c737..e31e514ffa1182 100644 --- a/test/parallel/test-buffer-bytelength.js +++ b/test/parallel/test-buffer-bytelength.js @@ -8,13 +8,13 @@ const vm = require('vm'); // coerce values to string assert.throws(() => { Buffer.byteLength(32, 'latin1'); }, - '"string" must be a string, Buffer, or ArrayBuffer'); + /"string" must be a string, Buffer, or ArrayBuffer/); assert.throws(() => { Buffer.byteLength(NaN, 'utf8'); }, - '"string" must be a string, Buffer, or ArrayBuffer'); + /"string" must be a string, Buffer, or ArrayBuffer/); assert.throws(() => { Buffer.byteLength({}, 'latin1'); }, - '"string" must be a string, Buffer, or ArrayBuffer'); + /"string" must be a string, Buffer, or ArrayBuffer/); assert.throws(() => { Buffer.byteLength(); }, - '"string" must be a string, Buffer, or ArrayBuffer'); + /"string" must be a string, Buffer, or ArrayBuffer/); assert(ArrayBuffer.isView(new Buffer(10))); assert(ArrayBuffer.isView(new SlowBuffer(10))); @@ -31,7 +31,7 @@ assert.strictEqual(Buffer.byteLength(ascii), 3); // ArrayBuffer var buffer = new ArrayBuffer(8); -assert.equal(Buffer.byteLength(buffer), 8); +assert.strictEqual(Buffer.byteLength(buffer), 8); // TypedArray var int8 = new Int8Array(8); From 6ab920a3fc5f285b2e227b58dc951e1617ea027c Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Wed, 23 Nov 2016 17:50:31 -0800 Subject: [PATCH 032/195] doc: add guide for maintaining V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: https://github.com/nodejs/LTS/pull/137 PR-URL: https://github.com/nodejs/node/pull/9777 Reviewed-By: mhdawson - Michael Dawson Reviewed-By: targos - Michaël Zasso --- doc/guides/maintaining-V8.md | 279 +++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 doc/guides/maintaining-V8.md diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md new file mode 100644 index 00000000000000..82312cf6bcf4d1 --- /dev/null +++ b/doc/guides/maintaining-V8.md @@ -0,0 +1,279 @@ +# Maintaining V8 in Node + +# Background + +V8 follows the Chromium release schedule. The support horizon for Chromium is very different from the support horizon that Node.js needs to provide to its users. As a result Node.js needs to support a version of V8 for quite a bit longer than what upstream needs to support. Since V8 doesn't have an LTS supported branch, there is no official process around how the V8 branches in Node are maintained. + +This document attempts to document the current processes and proposes a workflow for maintaining the V8 branches in Node.js LTS and Current releases and how the Node and V8 teams at Google can help. + +# V8 Release Schedule + +V8 and Chromium follow a [roughly 6-week release cadence](https://www.chromium.org/developers/calendar). At any given time there are three V8 branches that are **active**. + +For example, at the time of this writing: + +* **Stable**: V8 5.4 is currently shipping as part of Chromium stable. This branch was created approx. 6 weeks before from when V8 5.3 shipped as stable. +* **Beta**: V8 5.5 is currently in beta. It will be promoted to stable next; approximately 6 weeks after V8 5.4 shipped as stable. +* **Master**: V8 tip-of-tree corresponds to V8 5.6. This branch gets regularly released as part of the Chromium **canary** builds. This branch will be promoted to beta next when V8 5.5 ships as stable. + +All older branches are considered **abandoned**, and are not maintained by the V8 team. + +## V8 merge process overview + +The process for backporting bug fixes to active branches is officially documented [on the V8 wiki](https://github.com/v8/v8/wiki/Merging%20&%20Patching). The summary of the process is: + +* V8 only supports active branches. There is no testing done on any branches older than the current stable/beta/master. +* A fix needing backport is tagged w/ *merge-request-x.x* tag. This can be done by anyone interested in getting the fix backported. Issues with this tag are reviewed by the V8 team regularly as candidates for backporting. +* Fixes need some 'baking time' before they can be approved for backporting. This means waiting a few days to ensure that no issues are detected on the canary/beta builds. +* Once ready, the issue is tagged w/ *merge-approved-x.x* and one can do the actual merge by using the scripts on the [wiki page](https://github.com/v8/v8/wiki/Merging%20&%20Patching). +* Merge requests to an abandoned branch will be rejected. +* Only bug fixes are accepted for backporting. + +# Node Support Requirements + +At any given time Node needs to be maintaining a few different V8 branches for the various Current, LTS, and nightly releases. At present this list includes the following branches1: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Release + Support Start + Support End + V8 version + V8 branch released + V8 branch abandoned +
Node v4.x + 2015-10-01 + 2018-04-01 + 4.5 + 2015-09-01 + 2015-10-13 +
Node v6.x + 2016-04-01 + 2019-04-01 + 5.1 + 2016-05-31 + 2016-06-26 +
Node v7.x + 2016-10-01 + 2017-04-01 + 5.4 + 2016-10-18 + ~2016-12-01 +
master + N/A + N/A + 5.4 + 2016-10-18 + ~2016-12-01 +
+ + +The versions of V8 used in Node v4.x and v6.x have already been abandoned by upstream V8. However, Node.js needs to continue supporting these branches for many months (Current branches) or several years (LTS branches). + +# Maintenance Process + +Once a bug in Node.js has been identified to be caused by V8, the first step is to identify the versions of Node and V8 affected. The bug may be present in multiple different locations, each of which follows a slightly different process. + +* Unfixed bugs. The bug exists in the V8 master branch. +* Fixed, but needs backport. The bug may need porting to one or more branches. + * Backporting to active branches. + * Backporting to abandoned branches. +* Backports identified by the V8 team. Bugs identified by upstream V8 that we haven't encountered in Node yet. + +## Unfixed Upstream Bugs + +If the bug can be reproduced on the [`vee-eight-lkgr` branch](https://github.com/v8/node/tree/vee-eight-lkgr), Chromium canary, or V8 tip-of-tree, and the test case is valid, then the bug needs to be fixed upstream first. + +* Start by opening a bug upstream [using this template](https://bugs.chromium.org/p/v8/issues/entry?template=Node.js%20upstream%20bug). +* Make sure to include a link to the corresponding Node.js issue (if one exists). +* If the fix is simple enough, you may fix it yourself; [contributions](https://github.com/v8/v8/wiki/Contributing) are welcome. +* V8's build waterfall tests your change. +* Once the bug is fixed it may still need backporting, if it exists in other V8 branches that are still active or are branches that Node cares about. Follow the process for backporting below. + +## Backporting to Active Branches + +If the bug exists in any of the active V8 branches, we may need to get the fix backported. At any given time there are [two active branches](https://build.chromium.org/p/client.v8.branches/console) (beta and stable) in addition to master. The following steps are needed to backport the fix: + +* Identify which version of V8 the bug was fixed in. +* Identify if any active V8 branches still contain the bug: +* A tracking bug is needed to request a backport. + * If there isn't already a V8 bug tracking the fix, open a new merge request bug using this [Node.js specific template](https://bugs.chromium.org/p/v8/issues/entry?template=Node.js%20merge%20request). + * If a bug already exists + * Add a reference to the GitHub issue. + * Attach *merge-request-x.x* labels to the bug for any active branches that still contain the bug. (e.g. merge-request-5.3, merge-request-5.4) + * Add ofrobots-at-google.com to the cc list. +* Once the merge has been approved, it should be merged using the [merge script documented in the V8 wiki](https://github.com/v8/v8/wiki/Merging%20&%20Patching). Merging requires commit access to the V8 repository. If you don't have commit access you can indicate someone on the V8 team can do the merge for you. +* It is possible that the merge request may not get approved, for example if it is considered to be a feature or otherwise too risky for V8 stable. In such cases we float the patch on the Node side. See the process on 'Backporting to Abandoned branches'. +* Once the fix has been merged upstream, it can be picked up during an update of the V8 branch, (see below). + +## Backporting to Abandoned Branches + +Abandoned V8 branches are supported in the Node.js V8 repository. The fix needs to be cherry-picked in the Node.js repository and V8-CI must test the change. + +* For each abandoned V8 branch corresponding to an LTS branch that is affected by the bug: + * Open a cherry-pick PR on nodejs/node targeting the appropriate *vY.x-staging* branch (e.g. *v6.x-staging* to fix an issue in V8-5.1). + * Increase the patch level version in v8-version.h. This will not cause any problems with versioning because V8 will not publish other patches for this branch, so Node.js can effectively bump the patch version. + * In some cases the patch may require extra effort to merge in case V8 has changed substantially. For important issues we may be able to lean on the V8 team to get help with reimplementing the patch. + * Run Node's [V8-CI](https://ci.nodejs.org/job/node-test-commit-v8-linux/) in addition to the [Node CI](https://ci.nodejs.org/job/node-test-pull-request/). + +An example for workflow how to cherry-pick consider the following bug: https://crbug.com/v8/5199. From the bug we can see that it was merged by V8 into 5.2 and 5.3, and not into V8 5.1 (since it was already abandoned). Since Node.js `v6.x` uses V8 5.1, the fix needed to cherry-picked. To cherry-pick, here's an example workflow: + +* Download and apply the commit linked-to in the issue (in this case a51f429). `curl -L https://github.com/v8/v8/commit/a51f429.patch | git apply --directory=deps/v8`. If the branches have diverged significantly, this may not apply cleanly. It may help to try to cherry-pick the merge to the oldest branch that was done upstream in V8. In this example, this would be the patch from the merge to 5.2. The hope is that this would be closer to the V8 5.1, and has a better chance of applying cleanly. If you're stuck, feel free to ping @ofrobots for help. +* Modify the commit message to match the format we use for V8 backports. You may want to add extra description if necessary to indicate the impact of the fix on Node. In this case the original issue was descriptive enough. Example: +``` +deps: cherry-pick a51f429 from V8 upstream + +Original commit message: + [regexp] Fix case-insensitive matching for one-byte subjects. + + The bug occurs because we do not canonicalize character class ranges + before adding case equivalents. While adding case equivalents, we abort + early for one-byte subject strings, assuming that the ranges are sorted. + Which they are not. + + R=marja@chromium.org + BUG=v8:5199 + + Review-Url: https://codereview.chromium.org/2159683002 + Cr-Commit-Position: refs/heads/master@{#37833} + +PR-URL: +``` +* Open a PR against the `v6.x-staging` branch in the Node.js repo. Launch the normal and [V8-CI](https://ci.nodejs.org/job/node-test-commit-v8-linux/) using the Node.js CI system. We only needed to backport to `v6.x` as the other LTS branches weren't affected by this bug. + +## Backports Identified by the V8 team + +For bugs found through the browser or other channels, the V8 team marks bugs that might be applicable to the abandoned branches in use by Node.js. This is done through manual tagging by the V8 team and through an automated process that tags any fix that gets backported to the stable branch (as it is likely candidate for backporting further). + +Such fixes are tagged with the following labels in the V8 issue tracker: + +* `NodeJS-Backport-Review` ([V8](https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Review), [Chromium](https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Review)): to be reviewed if this is applicable to abandoned branches in use by Node.js. This list if regularly reviewed by the node team at Google to determine applicability to Node.js. +* `NodeJS-Backport-Approved` ([V8](https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Approved), [Chromium](https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Approved)): marks bugs that are deemed relevant to Node.js and should be backported. +* `NodeJS-Backport-Done` ([V8](https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Done), [Chromium](https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Done)): Backport for Node.js has been performed already. +* `NodeJS-Backport-Rejected` ([V8](https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Rejected), [Chromium](https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Rejected)): Backport for Node.js is not desired. + +The backlog of issues with such is regularly reviewed by the node-team at Google to shepherd through the backport process. External contributors are welcome to collaborate on the backport process as well. Note that some of the bugs may be security issues and will not be visible to external collaborators. + +# Updating V8 + +Node keeps a vendored copy of V8 inside of deps/ directory. In addition Node may need to float patches that do not exist upstream. This means that some care may need to be taken to update the vendored copy of V8. + +## Minor updates (patch level) + +Because there may be floating patches on the version of V8 in Node.js, it is safest to apply the patch level updates as a patch. For example, imagine that upstream V8 is at 5.0.71.47 and Node.js is at 5.0.71.32. It would be best to compute the diff between these tags on the V8 repository, and then apply that patch on the copy of V8 in Node.js. This should preserve the patches/backports that Node.js may be floating (or else cause a merge conflict). + +The rough outline of the process is: + +```shell +# Assuming your fork of Node.js is checked out in $NODE_DIR +# and you want to update the Node.js master branch. +# Find the current (OLD) version in +# $NODE_DIR/deps/v8/include/v8-version.h +cd $NODE_DIR +git checkout master +git merge --ff-only origin/master +git checkout -b V8_NEW_VERSION +curl -L https://github.com/v8/v8/compare/${V8_OLD_VERSION}...${V8_NEW_VERSION}.patch | git apply --directory=deps/v8 +# You may want to amend the commit message to describe the nature of the update +``` + +V8 also keeps tags of the form *5.4-lkgr* which point to the *Last Known Good Revision* from the 5.4 branch that can be useful in the update process above. + + +## Major Updates + +We upgrade the version of V8 in Node.js master whenever a V8 release goes stable upstream, that is, whenever a new release of Chrome comes out. + +Upgrading major versions would be much harder to do with the patch mechanism above. A better strategy is to + +1. Audit the current master branch and look at the patches that have been floated since the last major V8 update. +1. Replace the copy of V8 in Node.js with a fresh checkout of the latest stable V8 branch. Special care must be taken to recursively update the DEPS that V8 has a compile time dependency on (at the moment of this writing, these are only trace_event and gtest_prod.h) +1. Refloat (cherry-pick) all the patches from list computed in 1) as necessary. Some of the patches may no longer be necessary. + +To audit for floating patches: + +```shell +git log --oneline deps/v8 +``` + +To replace the copy of V8 in Node, use the '[update-v8](https://gist.github.com/targos/8da405e96e98fdff01a395bed365b816)' script2. For example, if you want to replace the copy of V8 in Node.js with the branch-head for V8 5.1 branch: + +```shell +cd $NODE_DIR +rm -rf deps/v8 +path/to/update-v8 branch-heads/5.1 +``` + +You may want to look at the commits created by the above scripts, and squash them once you have reviewed them. + +This should be followed up with manual refloating of all relevant patches. + +# Proposal: Using a fork repo to track upstream V8 + +The fact that Node.js keeps a vendored, potentially edited copy of V8 in deps/ makes the above processes a bit complicated. An alternative proposal would be to create a fork of V8 at nodejs/v8 that would be used to maintain the V8 branches. This has several benefits: + +* The process to update the version of V8 in Node.js could be automated to track the tips of various V8 branches in nodejs/v8. +* It would simplify cherry-picking and porting of fixes between branches as the version bumps in v8-version.h would happen as part of this update instead of on every change. +* It would simplify the V8-CI and make it more automatable. +* The history of the V8 branch in nodejs/v8 becomes purer and it would make it easier to pull in the V8 team for help with reviewing. +* It would make it simpler to setup an automated build that tracks Node.js master + V8 lkgr integration build. + +This would require some tooling to: + +* A script that would update the V8 in a specific Node branch with V8 from upstream (dependent on branch abandoned vs. active). +* We need a script to bump V8 version numbers when a new version of V8 is promoted from nodejs/v8 to nodejs/node. +* Enabled the V8-CI build in Jenkins to build from the nodejs/v8 fork. + +# Proposal: Dealing with the need to float patches to a stable/beta + +Sometimes upstream V8 may not want to merge a fix to their stable branches, but we might. An example of this would be a fix for a performance regression that only affects Node.js and not the browser. At the moment we don't have a mechanism to deal with this situation. If we float a patch and bump the V8 version, we might run into a problem if upstream releases a fix with the same version number. + +One idea we have been kicking around is that we could move to a 5-place version number in V8, e.g.: 5.4.500.30.${embedder}. The ${embedder} represents the number of patches an embedder is floating on top of an official V8 version. This would also help with auditing the floating patches in the Node commit history. + +We are trying this out in https://github.com/nodejs/node/pull/9754. If this ends up working, we will investigate making this change upstream. + + +## Notes + +1Node.js 0.12 and older are intentionally omitted from this document as their support is ending soon. + +2It seems that @targos is working on port of this script here https://github.com/targos/update-v8. From 5ae549c3aaafc4cd753ad5fa0b199e9754bfb72f Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Tue, 22 Nov 2016 14:47:11 +0100 Subject: [PATCH 033/195] url: fix -Warray-bounds warning Avoid out of bounds access to `url_host_value.ipv6` array. PR-URL: https://github.com/nodejs/node/pull/9751 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- src/node_url.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index 001475b04c9f7a..7502461114a7b4 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -472,10 +472,8 @@ namespace url { uint16_t* piece = &host->value.ipv6[n]; if (compress_pointer == piece) { *dest += n == 0 ? "::" : ":"; - while (*piece == 0 && n < 8) { - n++; + while (*piece == 0 && ++n < 8) piece = &host->value.ipv6[n]; - } if (n == 8) break; } From cd10e1ae4a52e54d6404836906a7cfe75866c222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 11:17:58 +0100 Subject: [PATCH 034/195] test: refactor and fix test-dns * More precise length assertion. * Fix incorrect use of string instead of RegExp in `throws` assertions. * Add missing RegExp to `throws` assertions. PR-URL: https://github.com/nodejs/node/pull/9811 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca --- test/parallel/test-dns.js | 46 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 5fcc045b2e3fe4..9ee2e9f974f625 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -5,7 +5,7 @@ const assert = require('assert'); const dns = require('dns'); const existing = dns.getServers(); -assert(existing.length); +assert(existing.length > 0); // Verify that setServers() handles arrays with holes and other oddities assert.doesNotThrow(() => { @@ -42,7 +42,8 @@ const goog = [ ]; assert.doesNotThrow(() => dns.setServers(goog)); assert.deepStrictEqual(dns.getServers(), goog); -assert.throws(() => dns.setServers(['foobar'])); +assert.throws(() => dns.setServers(['foobar']), + /^Error: IP address is not properly formatted: foobar$/); assert.deepStrictEqual(dns.getServers(), goog); const goog6 = [ @@ -77,20 +78,18 @@ assert.throws(() => { }, 'Unexpected error'); // dns.lookup should accept falsey and string values -assert.throws(() => dns.lookup({}, noop), - 'invalid arguments: hostname must be a string or falsey'); +const errorReg = + /^TypeError: Invalid arguments: hostname must be a string or falsey$/; -assert.throws(() => dns.lookup([], noop), - 'invalid arguments: hostname must be a string or falsey'); +assert.throws(() => dns.lookup({}, noop), errorReg); -assert.throws(() => dns.lookup(true, noop), - 'invalid arguments: hostname must be a string or falsey'); +assert.throws(() => dns.lookup([], noop), errorReg); -assert.throws(() => dns.lookup(1, noop), - 'invalid arguments: hostname must be a string or falsey'); +assert.throws(() => dns.lookup(true, noop), errorReg); -assert.throws(() => dns.lookup(noop, noop), - 'invalid arguments: hostname must be a string or falsey'); +assert.throws(() => dns.lookup(1, noop), errorReg); + +assert.throws(() => dns.lookup(noop, noop), errorReg); assert.doesNotThrow(() => dns.lookup('', noop)); @@ -114,13 +113,13 @@ assert.doesNotThrow(() => dns.lookup(NaN, noop)); assert.throws(() => { dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, noop); -}); +}, /^TypeError: Invalid argument: hints must use valid flags$/); assert.throws(() => dns.lookup('www.google.com'), - 'invalid arguments: callback must be passed'); + /^TypeError: Invalid arguments: callback must be passed$/); assert.throws(() => dns.lookup('www.google.com', 4), - 'invalid arguments: callback must be passed'); + /^TypeError: Invalid arguments: callback must be passed$/); assert.doesNotThrow(() => dns.lookup('www.google.com', 6, noop)); @@ -143,26 +142,29 @@ assert.doesNotThrow(() => { }, noop); }); -assert.throws(() => dns.lookupService('0.0.0.0'), /Invalid arguments/); +assert.throws(() => dns.lookupService('0.0.0.0'), + /^Error: Invalid arguments$/); assert.throws(() => dns.lookupService('fasdfdsaf', 0, noop), - /"host" argument needs to be a valid IP address/); + /^TypeError: "host" argument needs to be a valid IP address$/); assert.doesNotThrow(() => dns.lookupService('0.0.0.0', '0', noop)); assert.doesNotThrow(() => dns.lookupService('0.0.0.0', 0, noop)); assert.throws(() => dns.lookupService('0.0.0.0', null, noop), - /"port" should be >= 0 and < 65536, got "null"/); + /^TypeError: "port" should be >= 0 and < 65536, got "null"$/); -assert.throws(() => dns.lookupService('0.0.0.0', undefined, noop), - /"port" should be >= 0 and < 65536, got "undefined"/); +assert.throws( + () => dns.lookupService('0.0.0.0', undefined, noop), + /^TypeError: "port" should be >= 0 and < 65536, got "undefined"$/ +); assert.throws(() => dns.lookupService('0.0.0.0', 65538, noop), - /"port" should be >= 0 and < 65536, got "65538"/); + /^TypeError: "port" should be >= 0 and < 65536, got "65538"$/); assert.throws(() => dns.lookupService('0.0.0.0', 'test', noop), - /"port" should be >= 0 and < 65536, got "test"/); + /^TypeError: "port" should be >= 0 and < 65536, got "test"$/); assert.throws(() => dns.lookupService('0.0.0.0', 80, null), /^TypeError: "callback" argument must be a function$/); From e2db5c8e7a0056e4ec0abf4571d4de11460a3a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 12:20:21 +0100 Subject: [PATCH 035/195] test: refactor test-net-pingpong * var -> const. * Verify that callbacks are called with common.mustCall. * Replace usage of deprecated `server.connections`. * Use common.fail instead of rethrowing errors. * Remove console.log statements. * assert.equal -> assert.strictEqual. * Correct order of arguments in assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9812 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Luigi Pinca --- test/parallel/test-net-pingpong.js | 124 +++++++++++++---------------- 1 file changed, 56 insertions(+), 68 deletions(-) diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index 33fbafd8f97861..b49b3a78778719 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -1,87 +1,87 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); - -var net = require('net'); - -var tests_run = 0; +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); function pingPongTest(port, host) { - var N = 1000; + const N = 1000; var count = 0; var sentPongs = 0; var sent_final_ping = false; - var server = net.createServer({ allowHalfOpen: true }, function(socket) { - console.log('connection: ' + socket.remoteAddress); - assert.equal(server, socket.server); - assert.equal(1, server.connections); + const server = net.createServer( + { allowHalfOpen: true }, + common.mustCall(onSocket) + ); + + function onSocket(socket) { + assert.strictEqual(socket.server, server); + server.getConnections(common.mustCall(function(err, connections) { + assert.ifError(err); + assert.strictEqual(connections, 1); + })); socket.setNoDelay(); socket.timeout = 0; socket.setEncoding('utf8'); - socket.on('data', function(data) { + socket.on('data', common.mustCall(function(data) { // Since we never queue data (we're always waiting for the PING // before sending a pong) the writeQueueSize should always be less // than one message. assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4); - assert.equal(true, socket.writable); - assert.equal(true, socket.readable); - assert.equal(true, count <= N); - assert.equal(data, 'PING'); + assert.strictEqual(socket.writable, true); + assert.strictEqual(socket.readable, true); + assert.ok(count <= N); + assert.strictEqual(data, 'PING'); - socket.write('PONG', function() { + socket.write('PONG', common.mustCall(function() { sentPongs++; - }); - }); + })); + }, N + 1)); - socket.on('end', function() { - assert.equal(true, socket.allowHalfOpen); - assert.equal(true, socket.writable); // because allowHalfOpen - assert.equal(false, socket.readable); + socket.on('end', common.mustCall(function() { + assert.strictEqual(socket.allowHalfOpen, true); + assert.strictEqual(socket.writable, true); // because allowHalfOpen + assert.strictEqual(socket.readable, false); socket.end(); - }); + })); - socket.on('error', function(e) { - throw e; - }); + socket.on('error', common.fail); - socket.on('close', function() { - console.log('server socket.end'); - assert.equal(false, socket.writable); - assert.equal(false, socket.readable); + socket.on('close', common.mustCall(function() { + assert.strictEqual(socket.writable, false); + assert.strictEqual(socket.readable, false); socket.server.close(); - }); - }); + })); + } - server.listen(port, host, function() { + server.listen(port, host, common.mustCall(function() { if (this.address().port) port = this.address().port; - console.log(`server listening on ${port} ${host}`); - var client = net.createConnection(port, host); + const client = net.createConnection(port, host); client.setEncoding('ascii'); - client.on('connect', function() { - assert.equal(true, client.readable); - assert.equal(true, client.writable); + client.on('connect', common.mustCall(function() { + assert.strictEqual(client.readable, true); + assert.strictEqual(client.writable, true); client.write('PING'); - }); + })); - client.on('data', function(data) { - assert.equal('PONG', data); + client.on('data', common.mustCall(function(data) { + assert.strictEqual(data, 'PONG'); count += 1; if (sent_final_ping) { - assert.equal(false, client.writable); - assert.equal(true, client.readable); + assert.strictEqual(client.writable, false); + assert.strictEqual(client.readable, true); return; } else { - assert.equal(true, client.writable); - assert.equal(true, client.readable); + assert.strictEqual(client.writable, true); + assert.strictEqual(client.readable, true); } if (count < N) { @@ -91,20 +91,16 @@ function pingPongTest(port, host) { client.write('PING'); client.end(); } - }); - - client.on('close', function() { - console.log('client.end'); - assert.equal(N + 1, count); - assert.equal(N + 1, sentPongs); - assert.equal(true, sent_final_ping); - tests_run += 1; - }); - - client.on('error', function(e) { - throw e; - }); - }); + }, N + 1)); + + client.on('close', common.mustCall(function() { + assert.strictEqual(count, N + 1); + assert.strictEqual(sentPongs, N + 1); + assert.strictEqual(sent_final_ping, true); + })); + + client.on('error', common.fail); + })); } /* All are run at once, so run on different ports */ @@ -114,11 +110,3 @@ pingPongTest(0); pingPongTest(0, 'localhost'); if (common.hasIPv6) pingPongTest(0, '::1'); - -process.on('exit', function() { - if (common.hasIPv6) - assert.equal(4, tests_run); - else - assert.equal(3, tests_run); - console.log('done'); -}); From 74c3283cfa5c293e44c32b7788855693f782e8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 10:28:18 +0100 Subject: [PATCH 036/195] test: fix test-buffer-slow Fix incorrect use of string instead of RegExp in `throws` assertions. PR-URL: https://github.com/nodejs/node/pull/9809 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Prince John Wesley Reviewed-By: Michael Dawson --- test/parallel/test-buffer-slow.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js index 24bd9e1cfd314d..cecc01a95923c3 100644 --- a/test/parallel/test-buffer-slow.js +++ b/test/parallel/test-buffer-slow.js @@ -51,10 +51,10 @@ assert.strictEqual(SlowBuffer('string').length, 0); // should throw with invalid length assert.throws(function() { SlowBuffer(Infinity); -}, 'invalid Buffer length'); +}, /^RangeError: Invalid array buffer length$/); assert.throws(function() { SlowBuffer(-1); -}, 'invalid Buffer length'); +}, /^RangeError: Invalid array buffer length$/); assert.throws(function() { SlowBuffer(buffer.kMaxLength + 1); -}, 'invalid Buffer length'); +}, /^RangeError: (Invalid typed array length|Array buffer allocation failed)$/); From 5c9aa1848404084a7c2398348a719d95c6048004 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Fri, 28 Oct 2016 16:42:38 -0700 Subject: [PATCH 037/195] constants: errors -> errno lib/constants.js was incorrectly copying the constants from the binding, by copying from `contants.os.errors` instead of `constants.os.errno`. PR-URL: https://github.com/nodejs/node/pull/9349 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Ron Korving Reviewed-By: Luigi Pinca --- lib/constants.js | 2 +- test/parallel/test-constants.js | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index deebf90513da46..fec7e13d94145a 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -5,7 +5,7 @@ // are most relevant. const constants = process.binding('constants'); Object.assign(exports, - constants.os.errors, + constants.os.errno, constants.os.signals, constants.fs, constants.crypto); diff --git a/test/parallel/test-constants.js b/test/parallel/test-constants.js index ea0b93ba7fab6a..c11935783f861d 100644 --- a/test/parallel/test-constants.js +++ b/test/parallel/test-constants.js @@ -1,12 +1,26 @@ 'use strict'; require('../common'); -const constants = process.binding('constants'); +const binding = process.binding('constants'); +const constants = require('constants'); const assert = require('assert'); -assert.ok(constants); -assert.ok(constants.os); -assert.ok(constants.os.signals); -assert.ok(constants.os.errno); -assert.ok(constants.fs); -assert.ok(constants.crypto); +assert.ok(binding); +assert.ok(binding.os); +assert.ok(binding.os.signals); +assert.ok(binding.os.errno); +assert.ok(binding.fs); +assert.ok(binding.crypto); + +['os', 'fs', 'crypto'].forEach((l) => { + Object.keys(binding[l]).forEach((k) => { + if (typeof binding[l][k] === 'object') { // errno and signals + Object.keys(binding[l][k]).forEach((j) => { + assert.strictEqual(binding[l][k][j], constants[j]); + }); + } + if (l !== 'os') { // top level os constant isn't currently copied + assert.strictEqual(binding[l][k], constants[k]); + } + }); +}); From 4d1e11243b34e67ffd1d384ea2bfc20d0d222a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 09:34:43 +0100 Subject: [PATCH 038/195] test: refactor and fix test-crypto * var -> const. * Group and sort imports. * Replace use of the deprecated crypto.createCredentials. * Fix incorrect use of string instead of RegExp in `throws` assertions. * Clone array with `.slice()` and remove dependency on util. * assert.notEqual -> assert.notStrictEqual. * indexOf -> includes. PR-URL: https://github.com/nodejs/node/pull/9807 Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/parallel/test-crypto.js | 89 ++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index b9634b650ac1d7..13401e4ac594ab 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -1,34 +1,33 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var util = require('util'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); -crypto.DEFAULT_ENCODING = 'buffer'; +const assert = require('assert'); +const crypto = require('crypto'); +const fs = require('fs'); +const tls = require('tls'); -var fs = require('fs'); +crypto.DEFAULT_ENCODING = 'buffer'; // Test Certificates -var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii'); -var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); -var certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); -var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); -var tls = require('tls'); +const caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii'); +const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); +const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); +const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); // 'this' safety // https://github.com/joyent/node/issues/6690 assert.throws(function() { - var options = {key: keyPem, cert: certPem, ca: caPem}; - var credentials = crypto.createCredentials(options); - var context = credentials.context; - var notcontext = { setOptions: context.setOptions, setKey: context.setKey }; - crypto.createCredentials({ secureOptions: 1 }, notcontext); -}, TypeError); + const options = {key: keyPem, cert: certPem, ca: caPem}; + const credentials = tls.createSecureContext(options); + const context = credentials.context; + const notcontext = { setOptions: context.setOptions, setKey: context.setKey }; + tls.createSecureContext({ secureOptions: 1 }, notcontext); +}, /^TypeError: Illegal invocation$/); // PFX tests assert.doesNotThrow(function() { @@ -37,55 +36,55 @@ assert.doesNotThrow(function() { assert.throws(function() { tls.createSecureContext({pfx: certPfx}); -}, 'mac verify failure'); +}, /^Error: mac verify failure$/); assert.throws(function() { tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); -}, 'mac verify failure'); +}, /^Error: mac verify failure$/); assert.throws(function() { tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); -}, 'not enough data'); +}, /^Error: not enough data$/); // update() should only take buffers / strings assert.throws(function() { crypto.createHash('sha1').update({foo: 'bar'}); -}, /buffer/); +}, /^TypeError: Data must be a string or a buffer$/); function assertSorted(list) { // Array#sort() modifies the list in place so make a copy. - var sorted = util._extend([], list).sort(); + const sorted = list.slice().sort(); assert.deepStrictEqual(list, sorted); } // Assume that we have at least AES-128-CBC. -assert.notEqual(0, crypto.getCiphers().length); -assert.notEqual(-1, crypto.getCiphers().indexOf('aes-128-cbc')); -assert.equal(-1, crypto.getCiphers().indexOf('AES-128-CBC')); +assert.notStrictEqual(0, crypto.getCiphers().length); +assert(crypto.getCiphers().includes('aes-128-cbc')); +assert(!crypto.getCiphers().includes('AES-128-CBC')); assertSorted(crypto.getCiphers()); // Assume that we have at least AES256-SHA. -assert.notEqual(0, tls.getCiphers().length); -assert.notEqual(-1, tls.getCiphers().indexOf('aes256-sha')); -assert.equal(-1, tls.getCiphers().indexOf('AES256-SHA')); +assert.notStrictEqual(0, tls.getCiphers().length); +assert(tls.getCiphers().includes('aes256-sha')); +assert(!tls.getCiphers().includes('AES256-SHA')); assertSorted(tls.getCiphers()); // Assert that we have sha and sha1 but not SHA and SHA1. -assert.notEqual(0, crypto.getHashes().length); -assert.notEqual(-1, crypto.getHashes().indexOf('sha1')); -assert.notEqual(-1, crypto.getHashes().indexOf('sha')); -assert.equal(-1, crypto.getHashes().indexOf('SHA1')); -assert.equal(-1, crypto.getHashes().indexOf('SHA')); -assert.notEqual(-1, crypto.getHashes().indexOf('RSA-SHA1')); -assert.equal(-1, crypto.getHashes().indexOf('rsa-sha1')); +assert.notStrictEqual(0, crypto.getHashes().length); +assert(crypto.getHashes().includes('sha1')); +assert(crypto.getHashes().includes('sha')); +assert(!crypto.getHashes().includes('SHA1')); +assert(!crypto.getHashes().includes('SHA')); +assert(crypto.getHashes().includes('RSA-SHA1')); +assert(!crypto.getHashes().includes('rsa-sha1')); assertSorted(crypto.getHashes()); // Assume that we have at least secp384r1. -assert.notEqual(0, crypto.getCurves().length); -assert.notEqual(-1, crypto.getCurves().indexOf('secp384r1')); -assert.equal(-1, crypto.getCurves().indexOf('SECP384R1')); +assert.notStrictEqual(0, crypto.getCurves().length); +assert(crypto.getCurves().includes('secp384r1')); +assert(!crypto.getCurves().includes('SECP384R1')); assertSorted(crypto.getCurves()); // Regression tests for #5725: hex input that's not a power of two should @@ -100,18 +99,18 @@ assert.throws(function() { assert.throws(function() { crypto.createHash('sha1').update('0', 'hex'); -}, /Bad input string/); +}, /^TypeError: Bad input string$/); assert.throws(function() { crypto.createSign('RSA-SHA1').update('0', 'hex'); -}, /Bad input string/); +}, /^TypeError: Bad input string$/); assert.throws(function() { crypto.createVerify('RSA-SHA1').update('0', 'hex'); -}, /Bad input string/); +}, /^TypeError: Bad input string$/); assert.throws(function() { - var priv = [ + const priv = [ '-----BEGIN RSA PRIVATE KEY-----', 'MIGrAgEAAiEA+3z+1QNF2/unumadiwEr+C5vfhezsb3hp4jAnCNRpPcCAwEAAQIgQNriSQK4', 'EFwczDhMZp2dvbcz7OUUyt36z3S4usFPHSECEQD/41K7SujrstBfoCPzwC1xAhEA+5kt4BJy', @@ -121,7 +120,7 @@ assert.throws(function() { '' ].join('\n'); crypto.createSign('RSA-SHA256').update('test').sign(priv); -}, /digest too big for rsa key/); +}, /digest too big for rsa key$/); assert.throws(function() { // The correct header inside `test_bad_rsa_privkey.pem` should have been @@ -133,7 +132,7 @@ assert.throws(function() { // $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \ // -out private_key.pem -nocrypt; // Then open private_key.pem and change its header and footer. - var sha1_privateKey = fs.readFileSync(common.fixturesDir + + const sha1_privateKey = fs.readFileSync(common.fixturesDir + '/test_bad_rsa_privkey.pem', 'ascii'); // this would inject errors onto OpenSSL's error stack crypto.createSign('sha1').sign(sha1_privateKey); @@ -144,4 +143,4 @@ console.log(crypto.randomBytes(16)); assert.throws(function() { tls.createSecureContext({ crl: 'not a CRL' }); -}, '/Failed to parse CRL/'); +}, /^Error: Failed to parse CRL$/); From c35bf44f60d28de17ddd487dd931da5dca4026e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 26 Nov 2016 11:05:14 +0100 Subject: [PATCH 039/195] test: refactor test-crypto-binary-default * var -> const. * Group and sort imports. * Correctly align function arguments. * Fix incorrect use of string instead of RegExp in `throws` assertions. * assert.equal -> assert.strictEqual. * Verify that callbacks are called with common.mustCall. PR-URL: https://github.com/nodejs/node/pull/9810 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- test/parallel/test-crypto-binary-default.js | 247 ++++++++++---------- 1 file changed, 130 insertions(+), 117 deletions(-) diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js index 3b3603157786de..33a0783fe99963 100644 --- a/test/parallel/test-crypto-binary-default.js +++ b/test/parallel/test-crypto-binary-default.js @@ -3,30 +3,30 @@ // to use buffers by default. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); -var tls = require('tls'); + +const assert = require('assert'); +const crypto = require('crypto'); +const fs = require('fs'); +const path = require('path'); +const tls = require('tls'); const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR; crypto.DEFAULT_ENCODING = 'latin1'; -var fs = require('fs'); -var path = require('path'); - // Test Certificates -var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); -var certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); -var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); -var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', - 'ascii'); -var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', - 'ascii'); +const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); +const certPfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); +const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); +const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', + 'ascii'); +const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', + 'ascii'); // PFX tests assert.doesNotThrow(function() { @@ -35,22 +35,22 @@ assert.doesNotThrow(function() { assert.throws(function() { tls.createSecureContext({pfx: certPfx}); -}, 'mac verify failure'); +}, /^Error: mac verify failure$/); assert.throws(function() { tls.createSecureContext({pfx: certPfx, passphrase: 'test'}); -}, 'mac verify failure'); +}, /^Error: mac verify failure$/); assert.throws(function() { tls.createSecureContext({pfx: 'sample', passphrase: 'test'}); -}, 'not enough data'); +}, /^Error: not enough data$/); // Test HMAC const hmacHash = crypto.createHmac('sha1', 'Node') .update('some data') .update('to hmac') .digest('hex'); -assert.equal(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC'); +assert.strictEqual(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892'); // Test HMAC-SHA-* (rfc 4231 Test Cases) var rfc4231 = [ @@ -74,7 +74,7 @@ var rfc4231 = [ { key: Buffer.from('4a656665', 'hex'), // 'Jefe' data: Buffer.from('7768617420646f2079612077616e7420666f72206e6f74686' + - '96e673f', 'hex'), // 'what do ya want for nothing?' + '96e673f', 'hex'), // 'what do ya want for nothing?' hmac: { sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44', sha256: @@ -92,8 +92,8 @@ var rfc4231 = [ { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' + - 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', - 'hex'), + 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', + 'hex'), hmac: { sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea', sha256: @@ -110,10 +110,10 @@ var rfc4231 = [ }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), - data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + - 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'), + data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', + 'hex'), hmac: { sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a', sha256: @@ -143,15 +143,15 @@ var rfc4231 = [ }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaa', 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaa', 'hex'), // 'Test Using Larger Than Block-Size Key - Hash Key First' data: Buffer.from('54657374205573696e67204c6172676572205468616e20426' + - 'c6f636b2d53697a65204b6579202d2048617368204b657920' + - '4669727374', 'hex'), + 'c6f636b2d53697a65204b6579202d2048617368204b657920' + + '4669727374', 'hex'), hmac: { sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e', sha256: @@ -168,21 +168,21 @@ var rfc4231 = [ }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaa', 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaa', 'hex'), // 'This is a test using a larger than block-size key and a larger ' + // 'than block-size data. The key needs to be hashed before being ' + // 'used by the HMAC algorithm.' data: Buffer.from('5468697320697320612074657374207573696e672061206c6' + - '172676572207468616e20626c6f636b2d73697a65206b6579' + - '20616e642061206c6172676572207468616e20626c6f636b2' + - 'd73697a6520646174612e20546865206b6579206e65656473' + - '20746f20626520686173686564206265666f7265206265696' + - 'e6720757365642062792074686520484d414320616c676f72' + - '6974686d2e', 'hex'), + '172676572207468616e20626c6f636b2d73697a65206b6579' + + '20616e642061206c6172676572207468616e20626c6f636b2' + + 'd73697a6520646174612e20546865206b6579206e65656473' + + '20746f20626520686173686564206265666f7265206265696' + + 'e6720757365642062792074686520484d414320616c676f72' + + '6974686d2e', 'hex'), hmac: { sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1', sha256: @@ -207,9 +207,11 @@ for (let i = 0, l = rfc4231.length; i < l; i++) { if (rfc4231[i]['truncate']) { result = result.substr(0, 32); // first 128 bits == 32 hex chars } - assert.equal(rfc4231[i]['hmac'][hash], - result, - 'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231'); + assert.strictEqual( + rfc4231[i]['hmac'][hash], + result, + `Test HMAC-${hash}: Test case ${i + 1} rfc 4231` + ); } } @@ -228,17 +230,17 @@ var rfc2202_md5 = [ { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' + - 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', - 'hex'), + 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', + 'hex'), hmac: '56be34521d144c88dbb8c733f0e8b3f6' }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), - data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + - 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + - 'cdcdcdcdcd', 'hex'), + data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + + 'cdcdcdcdcd', + 'hex'), hmac: '697eaf0aca3a3aea3a75164746ffaa79' }, { @@ -248,19 +250,19 @@ var rfc2202_md5 = [ }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaa', + 'hex'), data: 'Test Using Larger Than Block-Size Key - Hash Key First', hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd' }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaa', + 'hex'), data: 'Test Using Larger Than Block-Size Key and Larger Than One ' + 'Block-Size Data', @@ -281,18 +283,18 @@ var rfc2202_sha1 = [ { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddd' + - 'ddddddddddddddddddddddddddddddddddddddddddddd' + - 'dddddddddd', - 'hex'), + 'ddddddddddddddddddddddddddddddddddddddddddddd' + + 'dddddddddd', + 'hex'), hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3' }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), - data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + - 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + - 'cdcdcdcdcd', 'hex'), + data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + + 'cdcdcdcdcd', + 'hex'), hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da' }, { @@ -302,19 +304,19 @@ var rfc2202_sha1 = [ }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaa', + 'hex'), data: 'Test Using Larger Than Block-Size Key - Hash Key First', hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112' }, { key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + - 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + + 'aaaaaaaaaaaaaaaaaaaaaa', + 'hex'), data: 'Test Using Larger Than Block-Size Key and Larger Than One ' + 'Block-Size Data', @@ -329,7 +331,7 @@ for (let i = 0, l = rfc2202_md5.length; i < l; i++) { crypto.createHmac('md5', rfc2202_md5[i]['key']) .update(rfc2202_md5[i]['data']) .digest('hex'), - 'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202' + `Test HMAC-MD5 : Test case ${i + 1} rfc 2202` ); } } @@ -339,7 +341,7 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) { crypto.createHmac('sha1', rfc2202_sha1[i]['key']) .update(rfc2202_sha1[i]['data']) .digest('hex'), - 'Test HMAC-SHA1 : Test case ' + (i + 1) + ' rfc 2202' + `Test HMAC-SHA1 : Test case ${i + 1} rfc 2202` ); } @@ -351,24 +353,27 @@ var a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); if (!common.hasFipsCrypto) { var a0 = crypto.createHash('md5').update('Test123').digest('latin1'); - assert.equal( + assert.strictEqual( a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c', 'Test MD5 as latin1' ); } -assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); +assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); -assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', - 'Test SHA256 as base64'); +assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', + 'Test SHA256 as base64'); -assert.equal(a3, '\u00c1(4\u00f1\u0003\u001fd\u0097!O\'\u00d4C/&Qz\u00d4' + - '\u0094\u0015l\u00b8\u008dQ+\u00db\u001d\u00c4\u00b5}\u00b2' + - '\u00d6\u0092\u00a3\u00df\u00a2i\u00a1\u009b\n\n*\u000f' + - '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' + - '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'', - 'Test SHA512 as assumed latin1'); +assert.strictEqual( + a3, + '\u00c1(4\u00f1\u0003\u001fd\u0097!O\'\u00d4C/&Qz\u00d4' + + '\u0094\u0015l\u00b8\u008dQ+\u00db\u001d\u00c4\u00b5}\u00b2' + + '\u00d6\u0092\u00a3\u00df\u00a2i\u00a1\u009b\n\n*\u000f' + + '\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' + + '\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'', + 'Test SHA512 as assumed latin1' +); assert.deepStrictEqual( a4, @@ -379,7 +384,7 @@ assert.deepStrictEqual( // Test multiple updates to same hash var h1 = crypto.createHash('sha1').update('Test123').digest('hex'); var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); -assert.equal(h1, h2, 'multipled updates'); +assert.strictEqual(h1, h2, 'multipled updates'); // Test hashing for binary files var fn = path.join(common.fixturesDir, 'sample.png'); @@ -388,16 +393,18 @@ var fileStream = fs.createReadStream(fn); fileStream.on('data', function(data) { sha1Hash.update(data); }); -fileStream.on('close', function() { - assert.equal(sha1Hash.digest('hex'), - '22723e553129a336ad96e10f6aecdf0f45e4149e', - 'Test SHA1 of sample.png'); -}); +fileStream.on('close', common.mustCall(function() { + assert.strictEqual( + sha1Hash.digest('hex'), + '22723e553129a336ad96e10f6aecdf0f45e4149e', + 'Test SHA1 of sample.png' + ); +})); // Issue #2227: unknown digest method should throw an error. assert.throws(function() { crypto.createHash('xyzzy'); -}); +}, /^Error: Digest method not supported$/); // Test signing and verifying var s1 = crypto.createSign('RSA-SHA1') @@ -443,7 +450,7 @@ function testCipher1(key) { var txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption'); + assert.strictEqual(txt, plaintext, 'encryption and decryption'); } @@ -465,7 +472,7 @@ function testCipher2(key) { var txt = decipher.update(ciph, 'base64', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with Base64'); + assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64'); } @@ -483,7 +490,8 @@ function testCipher3(key, iv) { var txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with key and iv'); + assert.strictEqual(txt, plaintext, + 'encryption and decryption with key and iv'); } @@ -501,7 +509,8 @@ function testCipher4(key, iv) { var txt = decipher.update(ciph, 'buffer', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with key and iv'); + assert.strictEqual(txt, plaintext, + 'encryption and decryption with key and iv'); } if (!common.hasFipsCrypto) { @@ -523,7 +532,7 @@ testCipher4(Buffer.from('0123456789abcd0123456789'), Buffer.from('12345678')); // update() should only take buffers / strings assert.throws(function() { crypto.createHash('sha1').update({foo: 'bar'}); -}, /buffer/); +}, /^TypeError: Data must be a string or a buffer$/); // Test Diffie-Hellman with two parties sharing a secret, @@ -536,7 +545,7 @@ var key2 = dh2.generateKeys('hex'); var secret1 = dh1.computeSecret(key2, 'hex', 'base64'); var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); -assert.equal(secret1, secret2.toString('base64')); +assert.strictEqual(secret1, secret2.toString('base64')); // Create "another dh1" using generated keys from dh1, // and compute secret again @@ -545,14 +554,14 @@ var privkey1 = dh1.getPrivateKey(); dh3.setPublicKey(key1); dh3.setPrivateKey(privkey1); -assert.equal(dh1.getPrime(), dh3.getPrime()); -assert.equal(dh1.getGenerator(), dh3.getGenerator()); -assert.equal(dh1.getPublicKey(), dh3.getPublicKey()); -assert.equal(dh1.getPrivateKey(), dh3.getPrivateKey()); +assert.strictEqual(dh1.getPrime(), dh3.getPrime()); +assert.strictEqual(dh1.getGenerator(), dh3.getGenerator()); +assert.strictEqual(dh1.getPublicKey(), dh3.getPublicKey()); +assert.strictEqual(dh1.getPrivateKey(), dh3.getPrivateKey()); var secret3 = dh3.computeSecret(key2, 'hex', 'base64'); -assert.equal(secret1, secret3); +assert.strictEqual(secret1, secret3); // https://github.com/joyent/node/issues/2338 var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + @@ -560,22 +569,24 @@ var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; var d = crypto.createDiffieHellman(p, 'hex'); -assert.equal(d.verifyError, DH_NOT_SUITABLE_GENERATOR); +assert.strictEqual(d.verifyError, DH_NOT_SUITABLE_GENERATOR); // Test RSA key signing/verification var rsaSign = crypto.createSign('RSA-SHA1'); var rsaVerify = crypto.createVerify('RSA-SHA1'); -assert.ok(rsaSign); -assert.ok(rsaVerify); +assert.ok(rsaSign instanceof crypto.Sign); +assert.ok(rsaVerify instanceof crypto.Verify); rsaSign.update(rsaPubPem); var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex'); -assert.equal(rsaSignature, - '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + - '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' + - 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' + - '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' + - '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'); +assert.strictEqual( + rsaSignature, + '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + + '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' + + 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' + + '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' + + '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6' +); rsaVerify.update(rsaPubPem); assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true); @@ -642,12 +653,14 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true); // Test PBKDF2 with RFC 6070 test vectors (except #4) // function testPBKDF2(password, salt, iterations, keylen, expected) { - var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256'); - assert.equal(actual, expected); + const actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, + 'sha256'); + assert.strictEqual(actual, expected); - crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => { - assert.equal(actual, expected); + const cb = common.mustCall((err, actual) => { + assert.strictEqual(actual, expected); }); + crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', cb); } From 59aec82f88e1e61a77d73e5f69104c76afe0a3f8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Nov 2016 20:37:19 -0800 Subject: [PATCH 040/195] test: refine test-http-status-reason-invalid-chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * replace unneeded template strings with strings; there was no variable substitution or concatenation or anything like that * assert.notEqual() -> assert.notStrictEqual() PR-URL: https://github.com/nodejs/node/pull/9802 Reviewed-By: Prince John Wesley Reviewed-By: Michaël Zasso Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Luigi Pinca --- test/parallel/test-http-status-reason-invalid-chars.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js index 245822d0146975..9950eeeee9cdd2 100644 --- a/test/parallel/test-http-status-reason-invalid-chars.js +++ b/test/parallel/test-http-status-reason-invalid-chars.js @@ -7,7 +7,7 @@ const net = require('net'); function explicit(req, res) { assert.throws(() => { - res.writeHead(200, `OK\r\nContent-Type: text/html\r\n`); + res.writeHead(200, 'OK\r\nContent-Type: text/html\r\n'); }, /Invalid character in statusMessage/); assert.throws(() => { @@ -20,7 +20,7 @@ function explicit(req, res) { function implicit(req, res) { assert.throws(() => { - res.statusMessage = `OK\r\nContent-Type: text/html\r\n`; + res.statusMessage = 'OK\r\nContent-Type: text/html\r\n'; res.writeHead(200); }, /Invalid character in statusMessage/); res.statusMessage = 'OK'; @@ -40,8 +40,8 @@ const server = http.createServer((req, res) => { let left = 2; const check = common.mustCall((res) => { left--; - assert.notEqual(res.headers['content-type'], 'text/html'); - assert.notEqual(res.headers['content-type'], 'gotcha'); + assert.notStrictEqual(res.headers['content-type'], 'text/html'); + assert.notStrictEqual(res.headers['content-type'], 'gotcha'); if (left === 0) server.close(); }, 2); http.get(`${url}/explicit`, check).end(); From 4c2ad8c89f7e8207a685350499d8a18126b3cc3a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Nov 2016 20:47:56 -0800 Subject: [PATCH 041/195] test: refactor test-preload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * assert.equal() -> assert.strictEqual() * replace template string with a string; no variable substitution or concatenation or anything like that PR-URL: https://github.com/nodejs/node/pull/9803 Reviewed-By: Prince John Wesley Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-preload.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js index e60b29dfbe7e47..f849bc3dda3243 100644 --- a/test/parallel/test-preload.js +++ b/test/parallel/test-preload.js @@ -37,7 +37,7 @@ childProcess.exec(nodeBinary + ' ' + fixtureB, function(err, stdout, stderr) { if (err) throw err; - assert.equal(stdout, 'A\nB\n'); + assert.strictEqual(stdout, 'A\nB\n'); }); // test preloading multiple modules works @@ -46,7 +46,7 @@ childProcess.exec(nodeBinary + ' ' + fixtureC, function(err, stdout, stderr) { if (err) throw err; - assert.equal(stdout, 'A\nB\nC\n'); + assert.strictEqual(stdout, 'A\nB\nC\n'); }); // test that preloading a throwing module aborts @@ -55,7 +55,7 @@ childProcess.exec(nodeBinary + ' ' + fixtureB, function(err, stdout, stderr) { if (err) { - assert.equal(stdout, 'A\n'); + assert.strictEqual(stdout, 'A\n'); } else { throw new Error('Preload should have failed'); } @@ -67,7 +67,7 @@ childProcess.exec(nodeBinary + ' ' + '-e "console.log(\'hello\');"', function(err, stdout, stderr) { if (err) throw err; - assert.equal(stdout, 'A\nhello\n'); + assert.strictEqual(stdout, 'A\nhello\n'); }); // test that preload can be used with stdin @@ -76,14 +76,14 @@ const stdinProc = childProcess.spawn( ['--require', fixtureA], {stdio: 'pipe'} ); -stdinProc.stdin.end('console.log(\'hello\');'); +stdinProc.stdin.end("console.log('hello');"); var stdinStdout = ''; stdinProc.stdout.on('data', function(d) { stdinStdout += d; }); stdinProc.on('close', function(code) { - assert.equal(code, 0); - assert.equal(stdinStdout, 'A\nhello\n'); + assert.strictEqual(code, 0); + assert.strictEqual(stdinStdout, 'A\nhello\n'); }); // test that preload can be used with repl @@ -98,12 +98,12 @@ replProc.stdout.on('data', function(d) { replStdout += d; }); replProc.on('close', function(code) { - assert.equal(code, 0); + assert.strictEqual(code, 0); const output = [ 'A', '> ' ].join('\n'); - assert.equal(replStdout, output); + assert.strictEqual(replStdout, output); }); // test that preload placement at other points in the cmdline @@ -114,7 +114,7 @@ childProcess.exec(nodeBinary + ' ' + preloadOption([fixtureA, fixtureB]), function(err, stdout, stderr) { if (err) throw err; - assert.equal(stdout, 'A\nB\nhello\n'); + assert.strictEqual(stdout, 'A\nB\nhello\n'); }); // test that preload works with -i @@ -123,7 +123,7 @@ const interactive = childProcess.exec(nodeBinary + ' ' + '-i', common.mustCall(function(err, stdout, stderr) { assert.ifError(err); - assert.strictEqual(stdout, `> 'test'\n> `); + assert.strictEqual(stdout, "> 'test'\n> "); })); interactive.stdin.write('a\n'); From 70633f965d67952193f4c0981ad108d58d0cec26 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Nov 2016 21:11:55 -0800 Subject: [PATCH 042/195] test: refactor test-util-inspect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Handle a rejected Promise as that is expected to cause the process to exit in a future version of Node.js. (Currently, it emits a warning.) * Remove unneeded escaping in regexps * Replace template strings with strings where there is no variable substitution. * A few minor readability changes (whitespace). PR-URL: https://github.com/nodejs/node/pull/9804 Reviewed-By: Prince John Wesley Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-util-inspect.js | 39 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index f730ec1c98303e..1118065f1a09da 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -143,12 +143,12 @@ for (const showHidden of [true, false]) { assert.strictEqual( util.inspect(array, true), `${constructor.name} [\n` + - ` 65,\n` + - ` 97,\n` + + ' 65,\n' + + ' 97,\n' + ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + ` [length]: ${length},\n` + ` [byteLength]: ${byteLength},\n` + - ` [byteOffset]: 0,\n` + + ' [byteOffset]: 0,\n' + ` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`); assert.strictEqual( util.inspect(array, false), @@ -168,23 +168,21 @@ for (const showHidden of [true, false]) { Uint8ClampedArray ].forEach((constructor) => { const length = 2; const byteLength = length * constructor.BYTES_PER_ELEMENT; - const array = vm.runInNewContext('new constructor(new ArrayBuffer(' + - 'byteLength), 0, length)', - { constructor: constructor, - byteLength: byteLength, - length: length - }); + const array = vm.runInNewContext( + 'new constructor(new ArrayBuffer(byteLength), 0, length)', + { constructor, byteLength, length } + ); array[0] = 65; array[1] = 97; assert.strictEqual( util.inspect(array, true), `${constructor.name} [\n` + - ` 65,\n` + - ` 97,\n` + + ' 65,\n' + + ' 97,\n' + ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + ` [length]: ${length},\n` + ` [byteLength]: ${byteLength},\n` + - ` [byteOffset]: 0,\n` + + ' [byteOffset]: 0,\n' + ` [buffer]: ArrayBuffer { byteLength: ${byteLength} } ]`); assert.strictEqual( util.inspect(array, false), @@ -208,8 +206,8 @@ for (const showHidden of [true, false]) { // Objects without prototype { const out = util.inspect(Object.create(null, - { name: {value: 'Tim', enumerable: true}, - hidden: {value: 'secret'}}), true); + { name: {value: 'Tim', enumerable: true}, + hidden: {value: 'secret'}}), true); if (out !== "{ [hidden]: 'secret', name: 'Tim' }" && out !== "{ name: 'Tim', [hidden]: 'secret' }") { common.fail(`unexpected value for out ${out}`); @@ -696,7 +694,14 @@ assert.strictEqual( // test Promise assert.strictEqual(util.inspect(Promise.resolve(3)), 'Promise { 3 }'); -assert.strictEqual(util.inspect(Promise.reject(3)), 'Promise { 3 }'); + +{ + const rejected = Promise.reject(3); + assert.strictEqual(util.inspect(rejected), 'Promise { 3 }'); + // squelch UnhandledPromiseRejection + rejected.catch(() => {}); +} + assert.strictEqual( util.inspect(new Promise(function() {})), 'Promise { }' @@ -831,7 +836,7 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; }))); { const x = Array(101); - assert(/^\[ ... 101 more items \]$/.test( + assert(/^\[ ... 101 more items ]$/.test( util.inspect(x, {maxArrayLength: 0}))); } @@ -847,7 +852,7 @@ checkAlignment(new Map(big_array.map(function(y) { return [y, null]; }))); { const x = new Uint8Array(101); - assert(/\[ ... 101 more items \]$/.test( + assert(/\[ ... 101 more items ]$/.test( util.inspect(x, {maxArrayLength: 0}))); } From 2e22fa043d24952f13694d4f0b02e269cca1f941 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Tue, 15 Nov 2016 10:31:27 -0800 Subject: [PATCH 043/195] doc: improve description of module `exports` - Do not use word alias, it isn't well defined - Fix return value of require() example, which confusingly was not the exported API as it should have been. - Fix the require() example, which claimed that the module exported `0`, when it exports `some_func`. - Describe best practice in keeping exports and module.exports bound together. - Describe why exports exists - Remove reference to magic, which is also not well defined PR-URL: https://github.com/nodejs/node/pull/9622 Reviewed-By: Luigi Pinca Reviewed-By: Stephen Belanger Reviewed-By: James M Snell --- doc/api/modules.md | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index ad98a0abcc20c4..1978c0aa3f521f 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -529,34 +529,51 @@ const x = require('./x'); console.log(x.a); ``` -#### exports alias +#### exports shortcut -The `exports` variable that is available within a module starts as a reference -to `module.exports`. As with any variable, if you assign a new value to it, it -is no longer bound to the previous value. +The `exports` variable is available within a module's file-level scope, and is +assigned the value of `module.exports` before the module is evaluated. + +It allows a shortcut, so that `module.exports.f = ...` can be written more +succinctly as `exports.f = ...`. However, be aware that like any variable, if a +new value is assigned to `exports`, it is no longer bound to `module.exports`: + +```js +module.exports.hello = true; // Exported from require of module +exports = { hello: false }; // Not exported, only available in the module +``` + +When the `module.exports` property is being completely replaced by a new +object, it is common to also reassign `exports`, for example: + +```js +module.exports = exports = function Constructor() { + // ... etc. +``` To illustrate the behavior, imagine this hypothetical implementation of -`require()`: +`require()`, which is quite similar to what is actually done by `require()`: ```js function require(...) { - // ... + var module = { exports: {} }; ((module, exports) => { - // Your module code here - exports = some_func; // re-assigns exports, exports is no longer - // a shortcut, and nothing is exported. - module.exports = some_func; // makes your module export 0 + // Your module code here. In this example, define a function. + function some_func() {}; + exports = some_func; + // At this point, exports is no longer a shortcut to module.exports, and + // this module will still export an empty default object. + module.exports = some_func; + // At this point, the module will now export some_func, instead of the + // default object. })(module, module.exports); - return module; + return module.exports; } ``` -As a guideline, if the relationship between `exports` and `module.exports` -seems like magic to you, ignore `exports` and only use `module.exports`. - ### module.filename -Node.js includes a full-featured out-of-process debugging utility accessible -via a simple [TCP-based protocol][] and built-in debugging client. To use it, -start Node.js with the `debug` argument followed by the path to the script to -debug; a prompt will be displayed indicating successful launch of the debugger: +Node.js includes an out-of-process debugging utility accessible via a +[TCP-based protocol][] and built-in debugging client. To use it, start Node.js +with the `debug` argument followed by the path to the script to debug; a prompt +will be displayed indicating successful launch of the debugger: ```txt $ node debug myscript.js From 5c15a68091708c04b0c1c2ffbc69440af4c0d91a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 28 Nov 2016 13:50:21 -0800 Subject: [PATCH 053/195] test: refactor test-debug-args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * indexOf() -> includes() * var -> const PR-URL: https://github.com/nodejs/node/pull/9833 Reviewed-By: Evan Lucas Reviewed-By: Prince John Wesley Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-debug-args.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-debug-args.js b/test/parallel/test-debug-args.js index e5f9f3716119ed..a4ed4f9f1ee719 100644 --- a/test/parallel/test-debug-args.js +++ b/test/parallel/test-debug-args.js @@ -2,6 +2,6 @@ // Flags: --debug-code require('../common'); -var assert = require('assert'); +const assert = require('assert'); -assert.notEqual(process.execArgv.indexOf('--debug-code'), -1); +assert(process.execArgv.includes('--debug-code')); From f6c1f240686d7210e163b3fddfd8073b49b60fc8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 29 Nov 2016 14:04:20 -0600 Subject: [PATCH 054/195] doc: update Collaborators list in README The Collaborators list in the README has a couple entries of people that have left the Collaborators team in GitHub. This updates the list in the README accordingly. PR-URL: https://github.com/nodejs/node/pull/9846 Reviewed-By: Gibson Fahnestock Reviewed-By: Roman Reiss Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index f8cc58c8310136..e21f07a25afd17 100644 --- a/README.md +++ b/README.md @@ -217,8 +217,6 @@ more information about the governance of the Node.js project, see **Claudio Rodriguez** <cjrodr@yahoo.com> * [danbev](https://github.com/danbev) - **Daniel Bevenius** <daniel.bevenius@gmail.com> -* [domenic](https://github.com/domenic) - -**Domenic Denicola** <d@domenic.me> * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - **Robert Jefe Lindstaedt** <robert.lindstaedt@gmail.com> * [estliberitas](https://github.com/estliberitas) - @@ -337,8 +335,6 @@ more information about the governance of the Node.js project, see **Yorkie Liu** <yorkiefixer@gmail.com> * [yosuke-furukawa](https://github.com/yosuke-furukawa) - **Yosuke Furukawa** <yosuke.furukawa@gmail.com> -* [zkat](https://github.com/zkat) - -**Kat Marchán** <kzm@sykosomatic.org> Collaborators (which includes CTC members) follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in maintaining the Node.js From c948d9051b23dfac5dbcad62824a07f7d4c50448 Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Fri, 2 Dec 2016 11:03:43 -0600 Subject: [PATCH 055/195] =?UTF-8?q?doc:=20it=E2=80=99s=20->=20its=20in=20a?= =?UTF-8?q?pi/child=5Fprocess.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/10090 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 6c8861b3b2e192..738b916eb6ac4b 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -278,7 +278,7 @@ allows messages to be passed back and forth between the parent and child. See It is important to keep in mind that spawned Node.js child processes are independent of the parent with exception of the IPC communication channel -that is established between the two. Each process has it's own memory, with +that is established between the two. Each process has its own memory, with their own V8 instances. Because of the additional resource allocations required, spawning a large number of child Node.js processes is not recommended. From 3af4ef4642f01634b067428a4fd3bdc210478876 Mon Sep 17 00:00:00 2001 From: ben_cripps Date: Wed, 30 Nov 2016 09:43:26 -0600 Subject: [PATCH 056/195] test: use strictEqual in test-debugger-client.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/9857 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- test/debugger/test-debugger-client.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/debugger/test-debugger-client.js b/test/debugger/test-debugger-client.js index fbe7ad1f0609be..04823113ec32c1 100644 --- a/test/debugger/test-debugger-client.js +++ b/test/debugger/test-debugger-client.js @@ -25,40 +25,40 @@ p.execute('Type: connect\r\n' + 'Protocol-Version: 1\r\n' + 'Embedding-Host: node v0.3.3-pre\r\n' + 'Content-Length: 0\r\n\r\n'); -assert.equal(1, resCount); +assert.strictEqual(resCount, 1); // Make sure split messages go in. var parts = []; parts.push('Content-Length: 336\r\n'); -assert.equal(21, parts[0].length); +assert.strictEqual(parts[0].length, 21); parts.push('\r\n'); -assert.equal(2, parts[1].length); +assert.strictEqual(parts[1].length, 2); var bodyLength = 0; parts.push('{"seq":12,"type":"event","event":"break","body":' + '{"invocationText":"#'); -assert.equal(78, parts[2].length); +assert.strictEqual(parts[2].length, 78); bodyLength += parts[2].length; parts.push('.[anonymous](req=#, ' + 'res=#)","sourceLine"'); -assert.equal(78, parts[3].length); +assert.strictEqual(parts[3].length, 78); bodyLength += parts[3].length; parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;",' + '"script":{"id":24,"name":"/home/ryan/projects/node/' + 'benchmark/http_simple.js","lineOffset":0,"columnOffset":0,' + '"lineCount":98}}}'); -assert.equal(180, parts[4].length); +assert.strictEqual(parts[4].length, 180); bodyLength += parts[4].length; -assert.equal(336, bodyLength); +assert.strictEqual(bodyLength, 336); for (var i = 0; i < parts.length; i++) { p.execute(parts[i]); } -assert.equal(2, resCount); +assert.strictEqual(resCount, 2); // Make sure that if we get backed up, we still manage to get all the @@ -77,7 +77,7 @@ var d = 'Content-Length: 466\r\n\r\n' + '{"seq":11,"type":"event","event":"scriptCollected","success":true,' + '"body":{"script":{"id":26}},"refs":[],"running":true}'; p.execute(d); -assert.equal(4, resCount); +assert.strictEqual(resCount, 4); var expectedConnections = 0; var tests = []; @@ -91,7 +91,7 @@ addTest(function(client, done) { client.reqVersion(function(err, v) { assert.ok(!err); console.log('version: %s', v); - assert.equal(process.versions.v8, v); + assert.strictEqual(process.versions.v8, v); done(); }); }); @@ -120,8 +120,8 @@ addTest(function(client, done) { client.reqEval('2+2', function(err, res) { console.error(res); assert.ok(!err); - assert.equal('4', res.text); - assert.equal(4, res.value); + assert.strictEqual(res.text, '4'); + assert.strictEqual(res.value, 4); done(); }); }); @@ -212,5 +212,5 @@ run(); process.on('exit', function(code) { if (!code) - assert.equal(expectedConnections, connectCount); + assert.strictEqual(connectCount, expectedConnections); }); From eb369f6d485a5cc270f8cee947f61da88ce2ad2b Mon Sep 17 00:00:00 2001 From: ben_cripps Date: Wed, 30 Nov 2016 10:27:50 -0600 Subject: [PATCH 057/195] test: use strictEqual in test-zlib-truncated PR-URL: https://github.com/nodejs/node/pull/9858 Reviewed-By: Rich Trott --- test/parallel/test-zlib-truncated.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-zlib-truncated.js b/test/parallel/test-zlib-truncated.js index 3fac824bbf9e53..92a18a538c1ee4 100644 --- a/test/parallel/test-zlib-truncated.js +++ b/test/parallel/test-zlib-truncated.js @@ -24,17 +24,18 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' zlib[methods.comp](inputString, function(err, compressed) { assert(!err); const truncated = compressed.slice(0, compressed.length / 2); + const toUTF8 = (buffer) => buffer.toString('utf-8'); // sync sanity assert.doesNotThrow(function() { const decompressed = zlib[methods.decompSync](compressed); - assert.equal(decompressed, inputString); + assert.strictEqual(toUTF8(decompressed), inputString); }); // async sanity zlib[methods.decomp](compressed, function(err, result) { assert.ifError(err); - assert.equal(result, inputString); + assert.strictEqual(toUTF8(result), inputString); }); // sync truncated input test @@ -51,17 +52,15 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' // sync truncated input test, finishFlush = Z_SYNC_FLUSH assert.doesNotThrow(function() { - const result = zlib[methods.decompSync](truncated, syncFlushOpt) - .toString(); - assert.equal(result, inputString.substr(0, result.length)); + const result = toUTF8(zlib[methods.decompSync](truncated, syncFlushOpt)); + assert.strictEqual(result, inputString.substr(0, result.length)); }); // async truncated input test, finishFlush = Z_SYNC_FLUSH zlib[methods.decomp](truncated, syncFlushOpt, function(err, decompressed) { assert.ifError(err); - - const result = decompressed.toString(); - assert.equal(result, inputString.substr(0, result.length)); + const result = toUTF8(decompressed); + assert.strictEqual(result, inputString.substr(0, result.length)); }); }); }); From 65cda7f265126bbb59e55e486c4476147322ebf0 Mon Sep 17 00:00:00 2001 From: Walter Beller-Morales Date: Tue, 29 Nov 2016 17:58:05 -0600 Subject: [PATCH 058/195] lib: use === in _http_server and _tls_wrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor fix to favor strict equality in http_server.js and tls_wrap.js to ensure accurate comparisons without type coercion. PR-URL: https://github.com/nodejs/node/pull/9849 Reviewed-By: Rich Trott Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca --- lib/_http_server.js | 2 +- lib/_tls_wrap.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/_http_server.js b/lib/_http_server.js index 99671832ebb2cb..c5f92d52d54d9b 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -525,7 +525,7 @@ function connectionListener(socket) { } if (req.headers.expect !== undefined && - (req.httpVersionMajor == 1 && req.httpVersionMinor == 1)) { + (req.httpVersionMajor === 1 && req.httpVersionMinor === 1)) { if (continueExpression.test(req.headers.expect)) { res._expect_continue = true; diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index cd793cb34f0a54..d9dafceb950dc7 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -545,7 +545,7 @@ TLSSocket.prototype.renegotiate = function(options, callback) { }; TLSSocket.prototype.setMaxSendFragment = function setMaxSendFragment(size) { - return this._handle.setMaxSendFragment(size) == 1; + return this._handle.setMaxSendFragment(size) === 1; }; TLSSocket.prototype.getTLSTicket = function getTLSTicket() { From a6377a96dd3e092ce76b9ddf1fbf2a75216dfba5 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 30 Nov 2016 22:04:28 -0600 Subject: [PATCH 059/195] test: increase coverage for lib/events.js Adds tests for the case in which listeners() is invoked on a EventEmitter with no events. Adds a new test case for the situation in which a class inherits from the EventEmitter but overrides the constructor in the EventEmitter so that the _events is never set. PR-URL: https://github.com/nodejs/node/pull/9865 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Myles Borins --- test/parallel/test-event-emitter-listeners.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/parallel/test-event-emitter-listeners.js b/test/parallel/test-event-emitter-listeners.js index cfb2dafb121e03..8aedd8fc3766bd 100644 --- a/test/parallel/test-event-emitter-listeners.js +++ b/test/parallel/test-event-emitter-listeners.js @@ -3,9 +3,12 @@ require('../common'); const assert = require('assert'); const events = require('events'); +const util = require('util'); function listener() {} function listener2() {} +class TestStream { constructor() { } } +util.inherits(TestStream, events.EventEmitter); { const ee = new events.EventEmitter(); @@ -49,3 +52,14 @@ function listener2() {} ee.once('foo', listener2); assert.deepStrictEqual(ee.listeners('foo'), [listener, listener2]); } + +{ + const ee = new events.EventEmitter(); + ee._events = undefined; + assert.deepStrictEqual(ee.listeners('foo'), []); +} + +{ + const s = new TestStream(); + assert.deepStrictEqual(s.listeners('foo'), []); +} From 13eea40d6f20ca04c4695a7b734281469724f29e Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 30 Nov 2016 22:54:38 -0600 Subject: [PATCH 060/195] doc: rename writing_tests.md to writing-tests.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The writing_tests.md file did not utilize kebab-case as the other files in the directory did. PR-URL: https://github.com/nodejs/node/pull/9867 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Jeremiah Senkpiel Reviewed-By: Michaël Zasso --- CONTRIBUTING.md | 2 +- doc/guides/{writing_tests.md => writing-tests.md} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename doc/guides/{writing_tests.md => writing-tests.md} (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 17aa305f8c7fe4..6f44949a31e0ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -150,7 +150,7 @@ $ git rebase upstream/master Bug fixes and features **should come with tests**. Add your tests in the `test/parallel/` directory. For guidance on how to write a test for the Node.js -project, see this [guide](./doc/guides/writing_tests.md). Looking at other tests +project, see this [guide](./doc/guides/writing-tests.md). Looking at other tests to see how they should be structured can also help. To run the tests on Unix / OS X: diff --git a/doc/guides/writing_tests.md b/doc/guides/writing-tests.md similarity index 100% rename from doc/guides/writing_tests.md rename to doc/guides/writing-tests.md From a857c9a74ccdb0e4011c4b623c2284d6fac5cc28 Mon Sep 17 00:00:00 2001 From: makenova Date: Thu, 1 Dec 2016 09:36:20 -0600 Subject: [PATCH 061/195] test: refactor test-vm-debug-context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit change var to const or let change assert.equal to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9875 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso --- test/parallel/test-vm-debug-context.js | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-vm-debug-context.js b/test/parallel/test-vm-debug-context.js index 9b8da58756c8d3..5cc23bb6f39148 100644 --- a/test/parallel/test-vm-debug-context.js +++ b/test/parallel/test-vm-debug-context.js @@ -1,9 +1,9 @@ /* eslint-disable no-debugger */ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var vm = require('vm'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const vm = require('vm'); +const spawn = require('child_process').spawn; assert.throws(function() { vm.runInDebugContext('*'); @@ -21,8 +21,8 @@ assert.throws(function() { vm.runInDebugContext('(function(f) { f(f) })(function(f) { f(f) })'); }, /RangeError/); -assert.equal(typeof vm.runInDebugContext('this'), 'object'); -assert.equal(typeof vm.runInDebugContext('Debug'), 'object'); +assert.strictEqual(typeof vm.runInDebugContext('this'), 'object'); +assert.strictEqual(typeof vm.runInDebugContext('Debug'), 'object'); assert.strictEqual(vm.runInDebugContext(), undefined); assert.strictEqual(vm.runInDebugContext(0), 0); @@ -46,11 +46,11 @@ assert.strictEqual(vm.runInDebugContext(undefined), undefined); debugger; } - assert.equal(breaks, 0); + assert.strictEqual(breaks, 0); Debug.setListener(ondebugevent); - assert.equal(breaks, 0); + assert.strictEqual(breaks, 0); breakpoint(); - assert.equal(breaks, 1); + assert.strictEqual(breaks, 1); } // Can set listeners and breakpoints on a single line file @@ -73,24 +73,24 @@ assert.strictEqual(vm.runInDebugContext(undefined), undefined); // See https://github.com/nodejs/node/issues/1190, fatal errors should not // crash the process. -var script = common.fixturesDir + '/vm-run-in-debug-context.js'; -var proc = spawn(process.execPath, [script]); -var data = []; +const script = common.fixturesDir + '/vm-run-in-debug-context.js'; +let proc = spawn(process.execPath, [script]); +const data = []; proc.stdout.on('data', common.fail); proc.stderr.on('data', data.push.bind(data)); proc.stderr.once('end', common.mustCall(function() { - var haystack = Buffer.concat(data).toString('utf8'); + const haystack = Buffer.concat(data).toString('utf8'); assert(/SyntaxError: Unexpected token \*/.test(haystack)); })); proc.once('exit', common.mustCall(function(exitCode, signalCode) { - assert.equal(exitCode, 1); - assert.equal(signalCode, null); + assert.strictEqual(exitCode, 1); + assert.strictEqual(signalCode, null); })); proc = spawn(process.execPath, [script, 'handle-fatal-exception']); proc.stdout.on('data', common.fail); proc.stderr.on('data', common.fail); proc.once('exit', common.mustCall(function(exitCode, signalCode) { - assert.equal(exitCode, 42); - assert.equal(signalCode, null); + assert.strictEqual(exitCode, 42); + assert.strictEqual(signalCode, null); })); From 66554c75d586b5742ff019018f5da216a42db7e7 Mon Sep 17 00:00:00 2001 From: Adriana Rios Date: Thu, 1 Dec 2016 09:54:26 -0600 Subject: [PATCH 062/195] test: refactor test-tls-ecdh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clear out const/let change assert.notEqual to assert move assert after common.hasCrypto check PR-URL: https://github.com/nodejs/node/pull/9878 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Gibson Fahnestock Reviewed-By: Michaël Zasso --- test/parallel/test-tls-ecdh.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-tls-ecdh.js b/test/parallel/test-tls-ecdh.js index e37552247ebd8c..99c6e108ab736a 100644 --- a/test/parallel/test-tls-ecdh.js +++ b/test/parallel/test-tls-ecdh.js @@ -1,31 +1,31 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const assert = require('assert'); +const tls = require('tls'); -var exec = require('child_process').exec; -var fs = require('fs'); +const exec = require('child_process').exec; +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), ciphers: '-ALL:ECDHE-RSA-AES128-SHA256', ecdhCurve: 'prime256v1' }; -var reply = 'I AM THE WALRUS'; // something recognizable +const reply = 'I AM THE WALRUS'; // something recognizable -var server = tls.createServer(options, common.mustCall(function(conn) { +const server = tls.createServer(options, common.mustCall(function(conn) { conn.end(reply); })); server.listen(0, '127.0.0.1', common.mustCall(function() { - var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + + let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows @@ -34,7 +34,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { exec(cmd, common.mustCall(function(err, stdout, stderr) { if (err) throw err; - assert.notEqual(stdout.indexOf(reply), -1); + assert(stdout.includes(reply)); server.close(); })); })); From f9386f2846bd6ed89fa961ec22c3a04216bbd512 Mon Sep 17 00:00:00 2001 From: scalkpdev Date: Thu, 1 Dec 2016 10:04:59 -0600 Subject: [PATCH 063/195] test: update net-local-address-port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - changed var to const - changed assert.equal to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9885 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso --- test/parallel/test-net-local-address-port.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js index 5eebdb16be379b..56f8eab5855c46 100644 --- a/test/parallel/test-net-local-address-port.js +++ b/test/parallel/test-net-local-address-port.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); var server = net.createServer(common.mustCall(function(socket) { - assert.equal(socket.localAddress, common.localhostIPv4); - assert.equal(socket.localPort, this.address().port); + assert.strictEqual(socket.localAddress, common.localhostIPv4); + assert.strictEqual(socket.localPort, this.address().port); socket.on('end', function() { server.close(); }); From 0cab6eb6ca91f6e1215c8d580a934e2a51223aef Mon Sep 17 00:00:00 2001 From: Ashton Kinslow Date: Thu, 1 Dec 2016 15:12:39 -0600 Subject: [PATCH 064/195] test: test for http.request() invalid method error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a test for when an invalid http method is passed into http.request() to verify an error is thrown, that the error is the correct type, and the error message is correct. PR-URL: https://github.com/nodejs/node/pull/10080 Reviewed-By: Matteo Collina Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso --- .../test-http-request-invalid-method-error.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/parallel/test-http-request-invalid-method-error.js diff --git a/test/parallel/test-http-request-invalid-method-error.js b/test/parallel/test-http-request-invalid-method-error.js new file mode 100644 index 00000000000000..febb340eacd2a4 --- /dev/null +++ b/test/parallel/test-http-request-invalid-method-error.js @@ -0,0 +1,12 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const http = require('http'); + +assert.throws( + () => { http.request({method: '\0'}); }, + (error) => { + return (error instanceof TypeError) && + /Method must be a valid HTTP token/.test(error); + } +); From cdec174d4db8bcc1f2bf4fa2b25728841b04ecb5 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 2 Dec 2016 20:03:12 +0200 Subject: [PATCH 065/195] doc: var => const in js code examples of addons.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/10092 Reviewed-By: Gibson Fahnestock Reviewed-By: Roman Reiss Reviewed-By: Michaël Zasso --- doc/api/addons.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/api/addons.md b/doc/api/addons.md index d91f60ae7bf6ef..44dc69915c428f 100644 --- a/doc/api/addons.md +++ b/doc/api/addons.md @@ -423,8 +423,8 @@ To test it in JavaScript: // test.js const addon = require('./build/Release/addon'); -var obj1 = addon('hello'); -var obj2 = addon('world'); +const obj1 = addon('hello'); +const obj2 = addon('world'); console.log(obj1.msg, obj2.msg); // Prints: 'hello world' ``` @@ -482,7 +482,7 @@ To test: // test.js const addon = require('./build/Release/addon'); -var fn = addon(); +const fn = addon(); console.log(fn()); // Prints: 'hello world' ``` @@ -645,7 +645,7 @@ Test it with: // test.js const addon = require('./build/Release/addon'); -var obj = new addon.MyObject(10); +const obj = new addon.MyObject(10); console.log(obj.plusOne()); // Prints: 11 console.log(obj.plusOne()); @@ -660,9 +660,9 @@ Alternatively, it is possible to use a factory pattern to avoid explicitly creating object instances using the JavaScript `new` operator: ```js -var obj = addon.createObject(); +const obj = addon.createObject(); // instead of: -// var obj = new addon.Object(); +// const obj = new addon.Object(); ``` First, the `createObject()` method is implemented in `addon.cc`: @@ -840,7 +840,7 @@ Test it with: // test.js const createObject = require('./build/Release/addon'); -var obj = createObject(10); +const obj = createObject(10); console.log(obj.plusOne()); // Prints: 11 console.log(obj.plusOne()); @@ -848,7 +848,7 @@ console.log(obj.plusOne()); console.log(obj.plusOne()); // Prints: 13 -var obj2 = createObject(20); +const obj2 = createObject(20); console.log(obj2.plusOne()); // Prints: 21 console.log(obj2.plusOne()); @@ -1022,9 +1022,9 @@ Test it with: // test.js const addon = require('./build/Release/addon'); -var obj1 = addon.createObject(10); -var obj2 = addon.createObject(20); -var result = addon.add(obj1, obj2); +const obj1 = addon.createObject(10); +const obj2 = addon.createObject(20); +const result = addon.add(obj1, obj2); console.log(result); // Prints: 30 From 44d9bc8b9085a55fb5b9c1b984090d670f404817 Mon Sep 17 00:00:00 2001 From: Kevin Zurawel Date: Thu, 1 Dec 2016 09:41:07 -0600 Subject: [PATCH 066/195] test: change equal to strictEqual This commit changes calls to `assert.equal()` to `assert.strictEqual()`. PR-URL: https://github.com/nodejs/node/pull/9872 Reviewed-By: Myles Borins Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Roman Reiss --- test/parallel/test-cluster-shared-handle-bind-error.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-cluster-shared-handle-bind-error.js b/test/parallel/test-cluster-shared-handle-bind-error.js index f5a08a1ed8481e..99573ef9539f56 100644 --- a/test/parallel/test-cluster-shared-handle-bind-error.js +++ b/test/parallel/test-cluster-shared-handle-bind-error.js @@ -12,7 +12,7 @@ if (cluster.isMaster) { var server = this; var worker = cluster.fork(); worker.on('exit', common.mustCall(function(exitCode) { - assert.equal(exitCode, 0); + assert.strictEqual(exitCode, 0); server.close(); })); }); @@ -20,7 +20,7 @@ if (cluster.isMaster) { var s = net.createServer(common.fail); s.listen(common.PORT, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'EADDRINUSE'); + assert.strictEqual(err.code, 'EADDRINUSE'); process.disconnect(); })); } From 78e188d9299bfb05dd880ee460cdd4e17ce3e93e Mon Sep 17 00:00:00 2001 From: Wes Tyler Date: Thu, 1 Dec 2016 15:03:55 -0600 Subject: [PATCH 067/195] doc: clarify fs.createReadStream options * start/end start *counting* at 0 * If fd is specified and start is omitted or undefined, fs.createReadStream() reads sequentially from the current file position. Fixes: https://github.com/nodejs/node/issues/7099 PR-URL: https://github.com/nodejs/node/pull/10078 Reviewed-By: Ben Noordhuis Reviewed-By: Gibson Fahnestock Reviewed-By: Anna Henningsen Reviewed-By: Roman Reiss --- doc/api/fs.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index f799b869e65c53..9eeeffa85785d2 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -602,7 +602,9 @@ default value of 64 kb for the same parameter. `options` can include `start` and `end` values to read a range of bytes from the file instead of the entire file. Both `start` and `end` are inclusive and -start at 0. The `encoding` can be any one of those accepted by [`Buffer`][]. +start counting at 0. If `fd` is specified and `start` is omitted or `undefined`, +`fs.createReadStream()` reads sequentially from the current file position. +The `encoding` can be any one of those accepted by [`Buffer`][]. If `fd` is specified, `ReadStream` will ignore the `path` argument and will use the specified file descriptor. This means that no `'open'` event will be From d1da89906d5e3328c7a98fff55cfcc843f6ed865 Mon Sep 17 00:00:00 2001 From: lrlna Date: Thu, 1 Dec 2016 12:04:27 -0600 Subject: [PATCH 068/195] test: increase coverage for timers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a test for cancelling timers with null or no arguments. PR-URL: https://github.com/nodejs/node/pull/10068 Reviewed-By: Myles Borins Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel Reviewed-By: Michaël Zasso Reviewed-By: Roman Reiss --- ...t-timers-clear-null-does-not-throw-error.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/parallel/test-timers-clear-null-does-not-throw-error.js diff --git a/test/parallel/test-timers-clear-null-does-not-throw-error.js b/test/parallel/test-timers-clear-null-does-not-throw-error.js new file mode 100644 index 00000000000000..a15072a4c63f46 --- /dev/null +++ b/test/parallel/test-timers-clear-null-does-not-throw-error.js @@ -0,0 +1,18 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +// This test makes sure clearing timers with +// 'null' or no input does not throw error + +assert.doesNotThrow(() => clearInterval(null)); + +assert.doesNotThrow(() => clearInterval()); + +assert.doesNotThrow(() => clearTimeout(null)); + +assert.doesNotThrow(() => clearTimeout()); + +assert.doesNotThrow(() => clearImmediate(null)); + +assert.doesNotThrow(() => clearImmediate()); From c0a28622cec2c6de7fcd8263d773c59314e163e7 Mon Sep 17 00:00:00 2001 From: shiya Date: Thu, 1 Dec 2016 10:25:05 -0600 Subject: [PATCH 069/195] test: var -> let/const, .equal -> .strictEqual var -> let/const .equal -> .strictEqual PR-URL: https://github.com/nodejs/node/pull/9913 Reviewed-By: Prince John Wesley Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- .../test-net-better-error-messages-port.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-better-error-messages-port.js b/test/parallel/test-net-better-error-messages-port.js index 514e317fbb0b15..9d74438c5f923b 100644 --- a/test/parallel/test-net-better-error-messages-port.js +++ b/test/parallel/test-net-better-error-messages-port.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); -var assert = require('assert'); +const common = require('../common'); +const net = require('net'); +const assert = require('assert'); -var c = net.createConnection(common.PORT); +const c = net.createConnection(common.PORT); c.on('connect', common.fail); c.on('error', common.mustCall(function(e) { - assert.equal(e.code, 'ECONNREFUSED'); - assert.equal(e.port, common.PORT); - assert.equal(e.address, '127.0.0.1'); + assert.strictEqual(e.code, 'ECONNREFUSED'); + assert.strictEqual(e.port, common.PORT); + assert.strictEqual(e.address, '127.0.0.1'); })); From d226418b87c5d1c6eb52367ba691f9a907033e04 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Thu, 1 Dec 2016 12:21:19 -0500 Subject: [PATCH 070/195] doc: suggest Buffer.alloc instead of Buffer#fill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that `Buffer.alloc` exists, there is no reason to recommend using `new Buffer(size).fill(0)` or `Buffer.allocUnsafe(size).fill(0)`. PR-URL: https://github.com/nodejs/node/pull/10000 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig --- doc/api/buffer.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 093be3f09e9232..2eef3512a0c22a 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -398,8 +398,8 @@ A zero-length `Buffer` will be created if `size <= 0`. Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances created in this way is *not initialized*. The contents of a newly created `Buffer` -are unknown and *could contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`] -to initialize a `Buffer` to zeroes. +are unknown and *could contain sensitive data*. Use +[`Buffer.alloc(size)`][`Buffer.alloc()`] instead to initialize a `Buffer` to zeroes. Example: @@ -517,7 +517,7 @@ be less than or equal to the value of [`buffer.kMaxLength`]. Otherwise, a The underlying memory for `Buffer` instances created in this way is *not initialized*. The contents of the newly created `Buffer` are unknown and -*may contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`] to initialize such +*may contain sensitive data*. Use [`Buffer.alloc()`] instead to initialize `Buffer` instances to zeroes. Example: From 2e889cf0561171d9760d366b26ef227d72c37f19 Mon Sep 17 00:00:00 2001 From: joyeecheung Date: Thu, 1 Dec 2016 10:00:10 -0600 Subject: [PATCH 071/195] test: improve test for crypto pbkdf2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - use assert.strictEqual instead of assert.equal - add regexp for assert.throws PR-URL: https://github.com/nodejs/node/pull/9883 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-crypto-pbkdf2.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js index f9fa7aa486318d..af72dc7f3067dd 100644 --- a/test/parallel/test-crypto-pbkdf2.js +++ b/test/parallel/test-crypto-pbkdf2.js @@ -13,10 +13,10 @@ var crypto = require('crypto'); // function testPBKDF2(password, salt, iterations, keylen, expected) { var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256'); - assert.equal(actual.toString('latin1'), expected); + assert.strictEqual(actual.toString('latin1'), expected); crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => { - assert.equal(actual.toString('latin1'), expected); + assert.strictEqual(actual.toString('latin1'), expected); }); } @@ -47,43 +47,43 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16, var expected = '64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956'; var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256'); -assert.equal(key.toString('hex'), expected); +assert.strictEqual(key.toString('hex'), expected); crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone)); function ondone(err, key) { if (err) throw err; - assert.equal(key.toString('hex'), expected); + assert.strictEqual(key.toString('hex'), expected); } // Error path should not leak memory (check with valgrind). assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, 20, null); -}); +}, /^Error: No callback provided to pbkdf2$/); // Should not work with Infinity key length assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256', common.fail); -}, /Bad key length/); +}, /^TypeError: Bad key length$/); // Should not work with negative Infinity key length assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256', common.fail); -}, /Bad key length/); +}, /^TypeError: Bad key length$/); // Should not work with NaN key length assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.fail); -}, /Bad key length/); +}, /^TypeError: Bad key length$/); // Should not work with negative key length assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.fail); -}, /Bad key length/); +}, /^TypeError: Bad key length$/); // Should not work with key length that does not fit into 32 signed bits assert.throws(function() { crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256', common.fail); -}, /Bad key length/); +}, /^TypeError: Bad key length$/); // Should not get FATAL ERROR with empty password and salt // https://github.com/nodejs/node/issues/8571 From b4ec7d6c504929387c49b850bdf1cdee1d853feb Mon Sep 17 00:00:00 2001 From: Greg Valdez Date: Thu, 1 Dec 2016 10:53:02 -0600 Subject: [PATCH 072/195] test: use const in test-crypto-pbkdf2 Updated all remaining var to const PR-URL: https://github.com/nodejs/node/pull/9974 Reviewed-By: Rich Trott --- test/parallel/test-crypto-pbkdf2.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js index af72dc7f3067dd..20ea5c7298199a 100644 --- a/test/parallel/test-crypto-pbkdf2.js +++ b/test/parallel/test-crypto-pbkdf2.js @@ -1,18 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); // // Test PBKDF2 with RFC 6070 test vectors (except #4) // function testPBKDF2(password, salt, iterations, keylen, expected) { - var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256'); + const actual = + crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256'); assert.strictEqual(actual.toString('latin1'), expected); crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => { @@ -44,9 +45,9 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16, '\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65' + '\x0a\x86\x87'); -var expected = +const expected = '64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956'; -var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256'); +const key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256'); assert.strictEqual(key.toString('hex'), expected); crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone)); From f9d79ef597cce11ce1cb9341b40350758668e668 Mon Sep 17 00:00:00 2001 From: Bidur Adhikari Date: Thu, 1 Dec 2016 11:51:06 -0600 Subject: [PATCH 073/195] test: use assert.strictEqual() cluster test Updated test-cluster-shared-handle-bind-privileged-port test method to use assert.strictEqual() instead of assert.equal() PR-URL: https://github.com/nodejs/node/pull/10042 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- .../test-cluster-shared-handle-bind-privileged-port.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index 9dc0e4ea773137..a04662750f39e4 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -18,13 +18,13 @@ if (cluster.isMaster) { // Master opens and binds the socket and shares it with the worker. cluster.schedulingPolicy = cluster.SCHED_NONE; cluster.fork().on('exit', common.mustCall(function(exitCode) { - assert.equal(exitCode, 0); + assert.strictEqual(exitCode, 0); })); } else { var s = net.createServer(common.fail); s.listen(42, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'EACCES'); + assert.strictEqual(err.code, 'EACCES'); process.disconnect(); })); } From 4cb52ee8270da871a5938825a4fbb25cfd145a9f Mon Sep 17 00:00:00 2001 From: Greg Valdez Date: Thu, 1 Dec 2016 11:23:58 -0600 Subject: [PATCH 074/195] test: update to const iin cluster test Update `var` to `const` PR-URL: https://github.com/nodejs/node/pull/10007 Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig --- .../test-cluster-shared-handle-bind-privileged-port.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js index a04662750f39e4..c58aa5393519ad 100644 --- a/test/parallel/test-cluster-shared-handle-bind-privileged-port.js +++ b/test/parallel/test-cluster-shared-handle-bind-privileged-port.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); if (common.isWindows) { common.skip('not reliable on Windows'); @@ -21,7 +21,7 @@ if (cluster.isMaster) { assert.strictEqual(exitCode, 0); })); } else { - var s = net.createServer(common.fail); + const s = net.createServer(common.fail); s.listen(42, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall(function(err) { assert.strictEqual(err.code, 'EACCES'); From 1f6f4112343f8d144515aad7d513d10c5e76309f Mon Sep 17 00:00:00 2001 From: Kyle Carter Date: Thu, 1 Dec 2016 10:45:50 -0600 Subject: [PATCH 075/195] test: refactor test/parallel/test-fs-write-file.js - Updated references of var to const - Updated assert.equal to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9992 Reviewed-By: Rich Trott --- test/parallel/test-fs-write-file.js | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/parallel/test-fs-write-file.js b/test/parallel/test-fs-write-file.js index 5ec95c8219aa4f..c62993b8da3990 100644 --- a/test/parallel/test-fs-write-file.js +++ b/test/parallel/test-fs-write-file.js @@ -1,34 +1,34 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var join = require('path').join; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const join = require('path').join; common.refreshTmpDir(); -var filename = join(common.tmpDir, 'test.txt'); +const filename = join(common.tmpDir, 'test.txt'); -var n = 220; -var s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + - '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + - '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + - '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + - '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + - '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + - '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; +const n = 220; +const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + + '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + + '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + + '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + + '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + + '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + + '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; fs.writeFile(filename, s, common.mustCall(function(e) { if (e) throw e; fs.readFile(filename, common.mustCall(function(e, buffer) { if (e) throw e; - assert.equal(Buffer.byteLength(s), buffer.length); + assert.strictEqual(Buffer.byteLength(s), buffer.length); })); })); // test that writeFile accepts buffers -var filename2 = join(common.tmpDir, 'test2.txt'); -var buf = Buffer.from(s, 'utf8'); +const filename2 = join(common.tmpDir, 'test2.txt'); +const buf = Buffer.from(s, 'utf8'); fs.writeFile(filename2, buf, common.mustCall(function(e) { if (e) throw e; @@ -36,32 +36,32 @@ fs.writeFile(filename2, buf, common.mustCall(function(e) { fs.readFile(filename2, common.mustCall(function(e, buffer) { if (e) throw e; - assert.equal(buf.length, buffer.length); + assert.strictEqual(buf.length, buffer.length); })); })); // test that writeFile accepts numbers. -var filename3 = join(common.tmpDir, 'test3.txt'); +const filename3 = join(common.tmpDir, 'test3.txt'); -var m = 0o600; +const m = 0o600; fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { if (e) throw e; // windows permissions aren't unix if (!common.isWindows) { - var st = fs.statSync(filename3); - assert.equal(st.mode & 0o700, m); + const st = fs.statSync(filename3); + assert.strictEqual(st.mode & 0o700, m); } fs.readFile(filename3, common.mustCall(function(e, buffer) { if (e) throw e; - assert.equal(Buffer.byteLength('' + n), buffer.length); + assert.strictEqual(Buffer.byteLength('' + n), buffer.length); })); })); // test that writeFile accepts file descriptors -var filename4 = join(common.tmpDir, 'test4.txt'); +const filename4 = join(common.tmpDir, 'test4.txt'); fs.open(filename4, 'w+', common.mustCall(function(e, fd) { if (e) throw e; @@ -75,7 +75,7 @@ fs.open(filename4, 'w+', common.mustCall(function(e, fd) { fs.readFile(filename4, common.mustCall(function(e, buffer) { if (e) throw e; - assert.equal(Buffer.byteLength(s), buffer.length); + assert.strictEqual(Buffer.byteLength(s), buffer.length); })); })); })); From 87038bb628c4a52bd7dda97002a3d569b05b57be Mon Sep 17 00:00:00 2001 From: adelmann Date: Thu, 1 Dec 2016 11:39:38 -0600 Subject: [PATCH 076/195] test: refactor test-fs-write-file Replaced all error checks with assert.ifError(e). PR-URL: https://github.com/nodejs/node/pull/10030 Reviewed-By: Rich Trott --- test/parallel/test-fs-write-file.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-fs-write-file.js b/test/parallel/test-fs-write-file.js index c62993b8da3990..acc69764fe1425 100644 --- a/test/parallel/test-fs-write-file.js +++ b/test/parallel/test-fs-write-file.js @@ -18,10 +18,10 @@ const s = '南越国是前203年至前111年存在于岭南地区的一个国家 '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; fs.writeFile(filename, s, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength(s), buffer.length); })); })); @@ -31,10 +31,10 @@ const filename2 = join(common.tmpDir, 'test2.txt'); const buf = Buffer.from(s, 'utf8'); fs.writeFile(filename2, buf, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename2, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(buf.length, buffer.length); })); @@ -45,7 +45,7 @@ const filename3 = join(common.tmpDir, 'test3.txt'); const m = 0o600; fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); // windows permissions aren't unix if (!common.isWindows) { @@ -54,7 +54,7 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { } fs.readFile(filename3, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength('' + n), buffer.length); })); @@ -64,16 +64,16 @@ fs.writeFile(filename3, n, { mode: m }, common.mustCall(function(e) { const filename4 = join(common.tmpDir, 'test4.txt'); fs.open(filename4, 'w+', common.mustCall(function(e, fd) { - if (e) throw e; + assert.ifError(e); fs.writeFile(fd, s, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.close(fd, common.mustCall(function(e) { - if (e) throw e; + assert.ifError(e); fs.readFile(filename4, common.mustCall(function(e, buffer) { - if (e) throw e; + assert.ifError(e); assert.strictEqual(Buffer.byteLength(s), buffer.length); })); From 070370fd0a40c6b2314252e1d849dd241810f37e Mon Sep 17 00:00:00 2001 From: Ian White Date: Thu, 1 Dec 2016 10:56:23 -0600 Subject: [PATCH 077/195] test: refactor test-fs-append-file-sync Change instances of `asset.equal` to `assert.strictEqual`. PR-URL: https://github.com/nodejs/node/pull/9977 Reviewed-By: Colin Ihrig --- test/parallel/test-fs-append-file-sync.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-append-file-sync.js b/test/parallel/test-fs-append-file-sync.js index d337e6ff326995..4a252f7c89c11a 100644 --- a/test/parallel/test-fs-append-file-sync.js +++ b/test/parallel/test-fs-append-file-sync.js @@ -24,7 +24,7 @@ fs.appendFileSync(filename, data); var fileData = fs.readFileSync(filename); -assert.equal(Buffer.byteLength(data), fileData.length); +assert.strictEqual(Buffer.byteLength(data), fileData.length); // test that appends data to a non empty file var filename2 = join(common.tmpDir, 'append-sync2.txt'); @@ -34,8 +34,8 @@ fs.appendFileSync(filename2, data); var fileData2 = fs.readFileSync(filename2); -assert.equal(Buffer.byteLength(data) + currentFileData.length, - fileData2.length); +assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, + fileData2.length); // test that appendFileSync accepts buffers var filename3 = join(common.tmpDir, 'append-sync3.txt'); @@ -46,7 +46,7 @@ fs.appendFileSync(filename3, buf); var fileData3 = fs.readFileSync(filename3); -assert.equal(buf.length + currentFileData.length, fileData3.length); +assert.strictEqual(buf.length + currentFileData.length, fileData3.length); // test that appendFile accepts numbers. var filename4 = join(common.tmpDir, 'append-sync4.txt'); @@ -58,13 +58,13 @@ fs.appendFileSync(filename4, num, { mode: m }); // windows permissions aren't unix if (!common.isWindows) { var st = fs.statSync(filename4); - assert.equal(st.mode & 0o700, m); + assert.strictEqual(st.mode & 0o700, m); } var fileData4 = fs.readFileSync(filename4); -assert.equal(Buffer.byteLength('' + num) + currentFileData.length, - fileData4.length); +assert.strictEqual(Buffer.byteLength('' + num) + currentFileData.length, + fileData4.length); // test that appendFile accepts file descriptors var filename5 = join(common.tmpDir, 'append-sync5.txt'); @@ -76,8 +76,8 @@ fs.closeSync(filename5fd); var fileData5 = fs.readFileSync(filename5); -assert.equal(Buffer.byteLength(data) + currentFileData.length, - fileData5.length); +assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, + fileData5.length); //exit logic for cleanup From d2e89272d2c476c1bd080505b952528364f8d7e6 Mon Sep 17 00:00:00 2001 From: Chris Bystrek Date: Thu, 1 Dec 2016 12:12:36 -0600 Subject: [PATCH 078/195] test: refactor test-fs-append-file-sync Update var to const. PR-URL: https://github.com/nodejs/node/pull/10056 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- test/parallel/test-fs-append-file-sync.js | 57 +++++++++++------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/test/parallel/test-fs-append-file-sync.js b/test/parallel/test-fs-append-file-sync.js index 4a252f7c89c11a..c13fc8953ed5fa 100644 --- a/test/parallel/test-fs-append-file-sync.js +++ b/test/parallel/test-fs-append-file-sync.js @@ -1,80 +1,79 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var join = require('path').join; -var fs = require('fs'); - -var currentFileData = 'ABCD'; - -var num = 220; -var data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + - '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + - '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + - '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + - '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + - '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + - '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; +const common = require('../common'); +const assert = require('assert'); +const join = require('path').join; +const fs = require('fs'); + +const currentFileData = 'ABCD'; +const m = 0o600; +const num = 220; +const data = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + + '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + + '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + + '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + + '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + + '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + + '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; common.refreshTmpDir(); // test that empty file will be created and have content added -var filename = join(common.tmpDir, 'append-sync.txt'); +const filename = join(common.tmpDir, 'append-sync.txt'); fs.appendFileSync(filename, data); -var fileData = fs.readFileSync(filename); +const fileData = fs.readFileSync(filename); assert.strictEqual(Buffer.byteLength(data), fileData.length); // test that appends data to a non empty file -var filename2 = join(common.tmpDir, 'append-sync2.txt'); +const filename2 = join(common.tmpDir, 'append-sync2.txt'); fs.writeFileSync(filename2, currentFileData); fs.appendFileSync(filename2, data); -var fileData2 = fs.readFileSync(filename2); +const fileData2 = fs.readFileSync(filename2); assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, fileData2.length); // test that appendFileSync accepts buffers -var filename3 = join(common.tmpDir, 'append-sync3.txt'); +const filename3 = join(common.tmpDir, 'append-sync3.txt'); fs.writeFileSync(filename3, currentFileData); -var buf = Buffer.from(data, 'utf8'); +const buf = Buffer.from(data, 'utf8'); fs.appendFileSync(filename3, buf); -var fileData3 = fs.readFileSync(filename3); +const fileData3 = fs.readFileSync(filename3); assert.strictEqual(buf.length + currentFileData.length, fileData3.length); // test that appendFile accepts numbers. -var filename4 = join(common.tmpDir, 'append-sync4.txt'); +const filename4 = join(common.tmpDir, 'append-sync4.txt'); fs.writeFileSync(filename4, currentFileData, { mode: m }); -var m = 0o600; fs.appendFileSync(filename4, num, { mode: m }); // windows permissions aren't unix if (!common.isWindows) { - var st = fs.statSync(filename4); + const st = fs.statSync(filename4); assert.strictEqual(st.mode & 0o700, m); } -var fileData4 = fs.readFileSync(filename4); +const fileData4 = fs.readFileSync(filename4); assert.strictEqual(Buffer.byteLength('' + num) + currentFileData.length, fileData4.length); // test that appendFile accepts file descriptors -var filename5 = join(common.tmpDir, 'append-sync5.txt'); +const filename5 = join(common.tmpDir, 'append-sync5.txt'); fs.writeFileSync(filename5, currentFileData); -var filename5fd = fs.openSync(filename5, 'a+', 0o600); +const filename5fd = fs.openSync(filename5, 'a+', 0o600); fs.appendFileSync(filename5fd, data); fs.closeSync(filename5fd); -var fileData5 = fs.readFileSync(filename5); +const fileData5 = fs.readFileSync(filename5); assert.strictEqual(Buffer.byteLength(data) + currentFileData.length, fileData5.length); From eb0c1cd412bdc636fd861549025ef09c8eb03dde Mon Sep 17 00:00:00 2001 From: Christine Hong Date: Thu, 1 Dec 2016 11:09:07 -0600 Subject: [PATCH 079/195] test: refactor test-cluster-setup-master-argv Change assert.equal to assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9993 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- test/parallel/test-cluster-setup-master-argv.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-cluster-setup-master-argv.js b/test/parallel/test-cluster-setup-master-argv.js index c42291417f9e79..e570af7cd52a60 100644 --- a/test/parallel/test-cluster-setup-master-argv.js +++ b/test/parallel/test-cluster-setup-master-argv.js @@ -8,8 +8,8 @@ setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref(); cluster.on('setup', function() { var clusterArgs = cluster.settings.args; var realArgs = process.argv; - assert.equal(clusterArgs[clusterArgs.length - 1], - realArgs[realArgs.length - 1]); + assert.strictEqual(clusterArgs[clusterArgs.length - 1], + realArgs[realArgs.length - 1]); }); assert.notStrictEqual(process.argv[process.argv.length - 1], 'OMG,OMG'); From 4cc813d8b9cc0377be77320e77f03ffb776c2bd0 Mon Sep 17 00:00:00 2001 From: Oscar Martinez Date: Thu, 1 Dec 2016 10:54:07 -0600 Subject: [PATCH 080/195] test: refactor test-cluster-setup-master-argv - updated vars to const - add common.mustCall() to setup callback PR-URL: https://github.com/nodejs/node/pull/9960 Reviewed-By: Prince John Wesley Reviewed-By: Colin Ihrig --- test/parallel/test-cluster-setup-master-argv.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-cluster-setup-master-argv.js b/test/parallel/test-cluster-setup-master-argv.js index e570af7cd52a60..32c5a91b3caab4 100644 --- a/test/parallel/test-cluster-setup-master-argv.js +++ b/test/parallel/test-cluster-setup-master-argv.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref(); -cluster.on('setup', function() { +cluster.on('setup', common.mustCall(function() { var clusterArgs = cluster.settings.args; var realArgs = process.argv; assert.strictEqual(clusterArgs[clusterArgs.length - 1], realArgs[realArgs.length - 1]); -}); +})); assert.notStrictEqual(process.argv[process.argv.length - 1], 'OMG,OMG'); process.argv.push('OMG,OMG'); From f76bb2adf8ad63384c2feedcf6479ae80c3be29c Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 1 Dec 2016 10:42:32 -0600 Subject: [PATCH 081/195] test: refactor test for crypto cipher/decipher iv Replace assert.equal with assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9943 Reviewed-By: Rich Trott --- test/parallel/test-crypto-cipheriv-decipheriv.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js index a3a14738c43e73..7756ed8938ab37 100644 --- a/test/parallel/test-crypto-cipheriv-decipheriv.js +++ b/test/parallel/test-crypto-cipheriv-decipheriv.js @@ -22,7 +22,7 @@ function testCipher1(key, iv) { var txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with key and iv'); + assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv'); // streaming cipher interface // NB: In real life, it's not guaranteed that you can get all of it @@ -36,7 +36,7 @@ function testCipher1(key, iv) { dStream.end(ciph); txt = dStream.read().toString('utf8'); - assert.equal(txt, plaintext, 'streaming cipher iv'); + assert.strictEqual(txt, plaintext, 'streaming cipher iv'); } @@ -54,7 +54,7 @@ function testCipher2(key, iv) { var txt = decipher.update(ciph, 'buffer', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with key and iv'); + assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv'); } testCipher1('0123456789abcd0123456789', '12345678'); From 03b1c314cd878b0342f51d27075636accf843db6 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Mon, 21 Nov 2016 15:44:03 +0100 Subject: [PATCH 082/195] deps: cherry-pick 08377af from v8 upstream Orignial commit message: [crankshaft] No need to rely on the @@hasInstance protector. In Crankshaft we can actually do an abstract interpretation of the @@hasInstance lookup when optimizing instanceof and then use the normal machinery to protect the result instead of relying on the global @@hasInstance protector cell for optimizations. This recovers the 100x performance drop in Node.js v7 reported in https://github.com/nodejs/node/issues/9634. This patch should be easily back-mergable to Node.js v7. BUG=v8:5640 R=yangguo@chromium.org,franzih@chromium.org Committed: https://crrev.com/08377af957b1602396ebf3e11ae000f15ed09333 Cr-Commit-Position: refs/heads/master@{#41059} PR-URL: https://github.com/nodejs/node/pull/9730 Fixes: https://github.com/nodejs/node/issues/9634 Reviewed-By: Franziska Hinkelmann Reviewed-By: Matteo Collina --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/bootstrapper.cc | 1 + deps/v8/src/contexts.h | 1 + deps/v8/src/crankshaft/hydrogen.cc | 49 +++++++++++++++++++----------- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index beb8042d37b576..df187b8307a6f6 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 4 #define V8_BUILD_NUMBER 500 -#define V8_PATCH_LEVEL 43 +#define V8_PATCH_LEVEL 44 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/bootstrapper.cc b/deps/v8/src/bootstrapper.cc index 5142817986cc56..cfea3208c9d7f1 100644 --- a/deps/v8/src/bootstrapper.cc +++ b/deps/v8/src/bootstrapper.cc @@ -1206,6 +1206,7 @@ void Genesis::InitializeGlobal(Handle global_object, JSObject::kHeaderSize, MaybeHandle(), Builtins::kFunctionPrototypeHasInstance, static_cast(DONT_ENUM | DONT_DELETE | READ_ONLY)); + native_context()->set_function_has_instance(*has_instance); // Set the expected parameters for @@hasInstance to 1; required by builtin. has_instance->shared()->set_internal_formal_parameter_count(1); diff --git a/deps/v8/src/contexts.h b/deps/v8/src/contexts.h index d73135f7a44047..fd5b006192b4ad 100644 --- a/deps/v8/src/contexts.h +++ b/deps/v8/src/contexts.h @@ -78,6 +78,7 @@ enum ContextLookupFlags { V(MAP_GET_METHOD_INDEX, JSFunction, map_get) \ V(MAP_HAS_METHOD_INDEX, JSFunction, map_has) \ V(MAP_SET_METHOD_INDEX, JSFunction, map_set) \ + V(FUNCTION_HAS_INSTANCE_INDEX, JSFunction, function_has_instance) \ V(OBJECT_VALUE_OF, JSFunction, object_value_of) \ V(OBJECT_TO_STRING, JSFunction, object_to_string) \ V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \ diff --git a/deps/v8/src/crankshaft/hydrogen.cc b/deps/v8/src/crankshaft/hydrogen.cc index a33d2a61200753..f40337e645f96b 100644 --- a/deps/v8/src/crankshaft/hydrogen.cc +++ b/deps/v8/src/crankshaft/hydrogen.cc @@ -11563,24 +11563,37 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { HConstant::cast(right)->handle(isolate())->IsJSFunction()) { Handle function = Handle::cast(HConstant::cast(right)->handle(isolate())); - // Make sure the prototype of {function} is the %FunctionPrototype%, and - // it already has a meaningful initial map (i.e. we constructed at least - // one instance using the constructor {function}). - // We can only use the fast case if @@hasInstance was not used so far. - if (function->has_initial_map() && - function->map()->prototype() == - function->native_context()->closure() && - !function->map()->has_non_instance_prototype() && - isolate()->IsHasInstanceLookupChainIntact()) { - Handle initial_map(function->initial_map(), isolate()); - top_info()->dependencies()->AssumeInitialMapCantChange(initial_map); - top_info()->dependencies()->AssumePropertyCell( - isolate()->factory()->has_instance_protector()); - HInstruction* prototype = - Add(handle(initial_map->prototype(), isolate())); - HHasInPrototypeChainAndBranch* result = - New(left, prototype); - return ast_context()->ReturnControl(result, expr->id()); + // Make sure that the {function} already has a meaningful initial map + // (i.e. we constructed at least one instance using the constructor + // {function}). + if (function->has_initial_map()) { + // Lookup @@hasInstance on the {function}. + Handle function_map(function->map(), isolate()); + PropertyAccessInfo has_instance( + this, LOAD, function_map, + isolate()->factory()->has_instance_symbol()); + // Check if we are using the Function.prototype[@@hasInstance]. + if (has_instance.CanAccessMonomorphic() && + has_instance.IsDataConstant() && + has_instance.constant().is_identical_to( + isolate()->function_has_instance())) { + // Add appropriate receiver map check and prototype chain + // checks to guard the @@hasInstance lookup chain. + AddCheckMap(right, function_map); + if (has_instance.has_holder()) { + Handle prototype( + JSObject::cast(has_instance.map()->prototype()), isolate()); + BuildCheckPrototypeMaps(prototype, has_instance.holder()); + } + // Perform the prototype chain walk. + Handle initial_map(function->initial_map(), isolate()); + top_info()->dependencies()->AssumeInitialMapCantChange(initial_map); + HInstruction* prototype = + Add(handle(initial_map->prototype(), isolate())); + HHasInPrototypeChainAndBranch* result = + New(left, prototype); + return ast_context()->ReturnControl(result, expr->id()); + } } } From 3e37673d5ce8e0a7a269ace965c8c897052ec18b Mon Sep 17 00:00:00 2001 From: Aileen Date: Thu, 1 Dec 2016 11:25:35 -0600 Subject: [PATCH 083/195] test: refactor test-crypto-cipheriv-decipheriv Make change in test file from var to const/let. PR-URL: https://github.com/nodejs/node/pull/10018 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- .../test-crypto-cipheriv-decipheriv.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-crypto-cipheriv-decipheriv.js b/test/parallel/test-crypto-cipheriv-decipheriv.js index 7756ed8938ab37..6f22dbe71affb1 100644 --- a/test/parallel/test-crypto-cipheriv-decipheriv.js +++ b/test/parallel/test-crypto-cipheriv-decipheriv.js @@ -1,25 +1,25 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); function testCipher1(key, iv) { // Test encyrption and decryption with explicit key and iv - var plaintext = - '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + - 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + - 'jAfaFg**'; - var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); - var ciph = cipher.update(plaintext, 'utf8', 'hex'); + const plaintext = + '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + + 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + + 'jAfaFg**'; + const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); + let ciph = cipher.update(plaintext, 'utf8', 'hex'); ciph += cipher.final('hex'); - var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); - var txt = decipher.update(ciph, 'hex', 'utf8'); + const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); + let txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv'); @@ -28,11 +28,11 @@ function testCipher1(key, iv) { // NB: In real life, it's not guaranteed that you can get all of it // in a single read() like this. But in this case, we know it's // quite small, so there's no harm. - var cStream = crypto.createCipheriv('des-ede3-cbc', key, iv); + const cStream = crypto.createCipheriv('des-ede3-cbc', key, iv); cStream.end(plaintext); ciph = cStream.read(); - var dStream = crypto.createDecipheriv('des-ede3-cbc', key, iv); + const dStream = crypto.createDecipheriv('des-ede3-cbc', key, iv); dStream.end(ciph); txt = dStream.read().toString('utf8'); @@ -42,16 +42,16 @@ function testCipher1(key, iv) { function testCipher2(key, iv) { // Test encyrption and decryption with explicit key and iv - var plaintext = - '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + - 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + - 'jAfaFg**'; - var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); - var ciph = cipher.update(plaintext, 'utf8', 'buffer'); + const plaintext = + '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + + 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + + 'jAfaFg**'; + const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); + let ciph = cipher.update(plaintext, 'utf8', 'buffer'); ciph = Buffer.concat([ciph, cipher.final('buffer')]); - var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); - var txt = decipher.update(ciph, 'buffer', 'utf8'); + const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); + let txt = decipher.update(ciph, 'buffer', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, 'encryption/decryption with key and iv'); From 371ca03568f3387482e76b58f76e46ea36250993 Mon Sep 17 00:00:00 2001 From: David Bradford Date: Thu, 1 Dec 2016 10:02:09 -0600 Subject: [PATCH 084/195] test: refactor test-vm-static-this.js Remove console statements and prefer strictEqual() over equal() in assertions. PR-URL: https://github.com/nodejs/node/pull/9887 Reviewed-By: Colin Ihrig --- test/parallel/test-vm-static-this.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js index a3cf2d820c3423..c4f10c183b6ef2 100644 --- a/test/parallel/test-vm-static-this.js +++ b/test/parallel/test-vm-static-this.js @@ -5,21 +5,21 @@ var vm = require('vm'); common.globalCheck = false; -console.error('run a string'); +// Run a string var result = vm.runInThisContext('\'passed\';'); -assert.equal('passed', result); +assert.strictEqual('passed', result); -console.error('thrown error'); +// thrown error assert.throws(function() { vm.runInThisContext('throw new Error(\'test\');'); }, /test/); global.hello = 5; vm.runInThisContext('hello = 2'); -assert.equal(2, global.hello); +assert.strictEqual(2, global.hello); -console.error('pass values'); +// pass values var code = 'foo = 1;' + 'bar = 2;' + 'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');'; @@ -28,11 +28,11 @@ global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ var baz = vm.runInThisContext(code); /* eslint-enable no-unused-vars */ -assert.equal(0, global.obj.foo); -assert.equal(2, global.bar); -assert.equal(1, global.foo); +assert.strictEqual(0, global.obj.foo); +assert.strictEqual(2, global.bar); +assert.strictEqual(1, global.foo); -console.error('call a function'); +// call a function global.f = function() { global.foo = 100; }; vm.runInThisContext('f()'); -assert.equal(100, global.foo); +assert.strictEqual(100, global.foo); From b73f6b760ff2e3da3d7fddb3f046a20daa567cd9 Mon Sep 17 00:00:00 2001 From: stokingerl Date: Thu, 1 Dec 2016 10:39:06 -0600 Subject: [PATCH 085/195] test: refactor test-child-process-spawn-error Change instances of assert.equal to assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9937 Reviewed-By: Colin Ihrig --- test/parallel/test-child-process-spawn-error.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-spawn-error.js b/test/parallel/test-child-process-spawn-error.js index eaf9c1303966a5..1a9de1e18b523b 100644 --- a/test/parallel/test-child-process-spawn-error.js +++ b/test/parallel/test-child-process-spawn-error.js @@ -5,13 +5,13 @@ var assert = require('assert'); var enoentPath = 'foo123'; var spawnargs = ['bar']; -assert.equal(common.fileExists(enoentPath), false); +assert.strictEqual(common.fileExists(enoentPath), false); var enoentChild = spawn(enoentPath, spawnargs); enoentChild.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'ENOENT'); - assert.equal(err.errno, 'ENOENT'); - assert.equal(err.syscall, 'spawn ' + enoentPath); - assert.equal(err.path, enoentPath); + assert.strictEqual(err.code, 'ENOENT'); + assert.strictEqual(err.errno, 'ENOENT'); + assert.strictEqual(err.syscall, 'spawn ' + enoentPath); + assert.strictEqual(err.path, enoentPath); assert.deepStrictEqual(err.spawnargs, spawnargs); })); From 8f550df25285e4b67a90814a46a5e295c3999a30 Mon Sep 17 00:00:00 2001 From: Johnny Reading Date: Thu, 1 Dec 2016 10:43:40 -0600 Subject: [PATCH 086/195] test: refactor child-process-spawn-error Use const instead of var for assignments. PR-URL: https://github.com/nodejs/node/pull/9951 Reviewed-By: Prince John Wesley Reviewed-By: Colin Ihrig --- test/parallel/test-child-process-spawn-error.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-child-process-spawn-error.js b/test/parallel/test-child-process-spawn-error.js index 1a9de1e18b523b..6cd3c47eef46ad 100644 --- a/test/parallel/test-child-process-spawn-error.js +++ b/test/parallel/test-child-process-spawn-error.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var spawn = require('child_process').spawn; -var assert = require('assert'); +const common = require('../common'); +const spawn = require('child_process').spawn; +const assert = require('assert'); -var enoentPath = 'foo123'; -var spawnargs = ['bar']; +const enoentPath = 'foo123'; +const spawnargs = ['bar']; assert.strictEqual(common.fileExists(enoentPath), false); -var enoentChild = spawn(enoentPath, spawnargs); +const enoentChild = spawn(enoentPath, spawnargs); enoentChild.on('error', common.mustCall(function(err) { assert.strictEqual(err.code, 'ENOENT'); assert.strictEqual(err.errno, 'ENOENT'); From fb4b6501591bec2bc831451d68aacd88b17783c5 Mon Sep 17 00:00:00 2001 From: Mitchell Stoutin Date: Thu, 1 Dec 2016 10:28:14 -0600 Subject: [PATCH 087/195] test: crypto-hash-stream-pipe use strict equal Replaces the use of assert.equal() with assert.strictEqual in test code. PR-URL: https://github.com/nodejs/node/pull/9935 Reviewed-By: Colin Ihrig --- test/parallel/test-crypto-hash-stream-pipe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-crypto-hash-stream-pipe.js b/test/parallel/test-crypto-hash-stream-pipe.js index 0ad9f18b0b45d8..5a0e409bada218 100644 --- a/test/parallel/test-crypto-hash-stream-pipe.js +++ b/test/parallel/test-crypto-hash-stream-pipe.js @@ -14,7 +14,7 @@ var h = crypto.createHash('sha1'); var expect = '15987e60950cf22655b9323bc1e281f9c4aff47e'; s.pipe(h).on('data', common.mustCall(function(c) { - assert.equal(c, expect); + assert.strictEqual(c, expect); })).setEncoding('hex'); s.end('aoeu'); From 63fafb8acae548bed576efb4d678fa3e4fe3efd6 Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Thu, 1 Dec 2016 12:07:32 -0600 Subject: [PATCH 088/195] test: refactor test-crypto-hash-stream-pipe Change var to const. PR-URL: https://github.com/nodejs/node/pull/10055 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- test/parallel/test-crypto-hash-stream-pipe.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-crypto-hash-stream-pipe.js b/test/parallel/test-crypto-hash-stream-pipe.js index 5a0e409bada218..33aa0f74566be0 100644 --- a/test/parallel/test-crypto-hash-stream-pipe.js +++ b/test/parallel/test-crypto-hash-stream-pipe.js @@ -1,17 +1,18 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); -var stream = require('stream'); -var s = new stream.PassThrough(); -var h = crypto.createHash('sha1'); -var expect = '15987e60950cf22655b9323bc1e281f9c4aff47e'; +const assert = require('assert'); +const crypto = require('crypto'); + +const stream = require('stream'); +const s = new stream.PassThrough(); +const h = crypto.createHash('sha1'); +const expect = '15987e60950cf22655b9323bc1e281f9c4aff47e'; s.pipe(h).on('data', common.mustCall(function(c) { assert.strictEqual(c, expect); From dc76a20474ddee2f32147a2264e1ec99e3beb040 Mon Sep 17 00:00:00 2001 From: Matt Webb Date: Thu, 1 Dec 2016 09:49:13 -0600 Subject: [PATCH 089/195] test: Updating vars to const and tsl server test PR-URL: https://github.com/nodejs/node/pull/9874 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-tls-timeout-server.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-tls-timeout-server.js b/test/parallel/test-tls-timeout-server.js index f72f39b392e297..72ee6d01629429 100644 --- a/test/parallel/test-tls-timeout-server.js +++ b/test/parallel/test-tls-timeout-server.js @@ -1,28 +1,28 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var net = require('net'); -var fs = require('fs'); +const net = require('net'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), handshakeTimeout: 50 }; -var server = tls.createServer(options, common.fail); +const server = tls.createServer(options, common.fail); server.on('tlsClientError', common.mustCall(function(err, conn) { conn.destroy(); server.close(); })); -server.listen(0, function() { +server.listen(0, common.mustCall(function() { net.connect({ host: '127.0.0.1', port: this.address().port }); -}); +})); From f3eb8b1bea4590e5cda142d4b26638f492d9acfa Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Thu, 1 Dec 2016 09:49:49 -0600 Subject: [PATCH 090/195] test: refactor test-tls-timeout-server-2 * Use `common.mustCall` for all callbacks * Use `const` instead of `var` PR-URL: https://github.com/nodejs/node/pull/9876 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-tls-timeout-server-2.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-tls-timeout-server-2.js b/test/parallel/test-tls-timeout-server-2.js index a054f41f623455..1613e9fc4e06d6 100644 --- a/test/parallel/test-tls-timeout-server-2.js +++ b/test/parallel/test-tls-timeout-server-2.js @@ -1,32 +1,32 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.createServer(options, function(cleartext) { - var s = cleartext.setTimeout(50, function() { +const server = tls.createServer(options, common.mustCall(function(cleartext) { + const s = cleartext.setTimeout(50, function() { cleartext.destroy(); server.close(); }); assert.ok(s instanceof tls.TLSSocket); -}); +})); -server.listen(0, function() { +server.listen(0, common.mustCall(function() { tls.connect({ host: '127.0.0.1', port: this.address().port, rejectUnauthorized: false }); -}); +})); From 13cc6a005bbf8525c25c4a5216a6845b9ad8f52a Mon Sep 17 00:00:00 2001 From: rajatk Date: Thu, 1 Dec 2016 09:47:46 -0600 Subject: [PATCH 091/195] test: var to const/let in test-tls-set-ciphers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this change is part of code and learn (NINA-2016) PR-URL: https://github.com/nodejs/node/pull/9877 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-tls-set-ciphers.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js index 4d9274b184232d..5a85e3b22e4c62 100644 --- a/test/parallel/test-tls-set-ciphers.js +++ b/test/parallel/test-tls-set-ciphers.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -11,25 +11,25 @@ if (!common.hasCrypto) { return; } -var assert = require('assert'); -var exec = require('child_process').exec; -var tls = require('tls'); -var fs = require('fs'); +const assert = require('assert'); +const exec = require('child_process').exec; +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), ciphers: 'DES-CBC3-SHA' }; -var reply = 'I AM THE WALRUS'; // something recognizable -var response = ''; +const reply = 'I AM THE WALRUS'; // something recognizable +let response = ''; process.on('exit', function() { assert.notEqual(response.indexOf(reply), -1); }); -var server = tls.createServer(options, common.mustCall(function(conn) { +const server = tls.createServer(options, common.mustCall(function(conn) { conn.end(reply); })); From 3d35930b2c0c9a152cab8cdf476b108d2645e5c2 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 1 Dec 2016 09:56:23 -0600 Subject: [PATCH 092/195] test: replace equal with strictEqual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace assert.equal with assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9879 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-child-process-validate-stdio.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js index 09d000467404b6..384efdf15a1425 100644 --- a/test/parallel/test-child-process-validate-stdio.js +++ b/test/parallel/test-child-process-validate-stdio.js @@ -19,10 +19,10 @@ assert.throws(function() { { const stdio1 = []; const result = _validateStdio(stdio1, false); - assert.equal(stdio1.length, 3); - assert.equal(result.hasOwnProperty('stdio'), true); - assert.equal(result.hasOwnProperty('ipc'), true); - assert.equal(result.hasOwnProperty('ipcFd'), true); + assert.strictEqual(stdio1.length, 3); + assert.strictEqual(result.hasOwnProperty('stdio'), true); + assert.strictEqual(result.hasOwnProperty('ipc'), true); + assert.strictEqual(result.hasOwnProperty('ipcFd'), true); } // should throw if stdio has ipc and sync is true From 57f060c495cd76866801b1db415fd03823e9f7cb Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 1 Dec 2016 10:05:31 -0600 Subject: [PATCH 093/195] test: replace equal with strictEqual in crypto Replace assert.equal with assert.strictEqual in crypto cipher-decipher test PR-URL: https://github.com/nodejs/node/pull/9886 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- test/parallel/test-crypto-cipher-decipher.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-crypto-cipher-decipher.js b/test/parallel/test-crypto-cipher-decipher.js index be03eee86022f5..c63bcd6f9e2695 100644 --- a/test/parallel/test-crypto-cipher-decipher.js +++ b/test/parallel/test-crypto-cipher-decipher.js @@ -27,7 +27,7 @@ function testCipher1(key) { var txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption'); + assert.strictEqual(txt, plaintext, 'encryption and decryption'); // streaming cipher interface // NB: In real life, it's not guaranteed that you can get all of it @@ -41,7 +41,7 @@ function testCipher1(key) { dStream.end(ciph); txt = dStream.read().toString('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with streams'); + assert.strictEqual(txt, plaintext, 'encryption and decryption with streams'); } @@ -63,7 +63,7 @@ function testCipher2(key) { var txt = decipher.update(ciph, 'base64', 'utf8'); txt += decipher.final('utf8'); - assert.equal(txt, plaintext, 'encryption and decryption with Base64'); + assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64'); } testCipher1('MySecretKey123'); From 295eb5a3b69cc2cc61a537d668fde469eb08a9d8 Mon Sep 17 00:00:00 2001 From: Peter Masucci Date: Thu, 1 Dec 2016 11:01:54 -0500 Subject: [PATCH 094/195] test: swap var->const/let and equal->strictEqual Change instances of var with const/let. Change assert.equal to assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9888 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-tls-no-sslv3.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/parallel/test-tls-no-sslv3.js b/test/parallel/test-tls-no-sslv3.js index c284356ce37bb6..16a722ef85b9da 100644 --- a/test/parallel/test-tls-no-sslv3.js +++ b/test/parallel/test-tls-no-sslv3.js @@ -1,30 +1,30 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const fs = require('fs'); +const spawn = require('child_process').spawn; if (common.opensslCli === false) { common.skip('node compiled without OpenSSL CLI.'); return; } -var cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem'); -var key = fs.readFileSync(common.fixturesDir + '/test_key.pem'); -var server = tls.createServer({ cert: cert, key: key }, common.fail); -var errors = []; -var stderr = ''; +const cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem'); +const key = fs.readFileSync(common.fixturesDir + '/test_key.pem'); +const server = tls.createServer({ cert: cert, key: key }, common.fail); +const errors = []; +let stderr = ''; server.listen(0, '127.0.0.1', function() { - var address = this.address().address + ':' + this.address().port; - var args = ['s_client', + const address = this.address().address + ':' + this.address().port; + const args = ['s_client', '-ssl3', '-connect', address]; @@ -32,14 +32,14 @@ server.listen(0, '127.0.0.1', function() { if (common.isWindows) args.push('-no_rand_screen'); - var client = spawn(common.opensslCli, args, { stdio: 'pipe' }); + const client = spawn(common.opensslCli, args, { stdio: 'pipe' }); client.stdout.pipe(process.stdout); client.stderr.pipe(process.stderr); client.stderr.setEncoding('utf8'); client.stderr.on('data', (data) => stderr += data); client.once('exit', common.mustCall(function(exitCode) { - assert.equal(exitCode, 1); + assert.strictEqual(exitCode, 1); server.close(); })); }); @@ -50,7 +50,7 @@ process.on('exit', function() { if (/unknown option -ssl3/.test(stderr)) { common.skip('`openssl s_client -ssl3` not supported.'); } else { - assert.equal(errors.length, 1); + assert.strictEqual(errors.length, 1); assert(/:wrong version number/.test(errors[0].message)); } }); From 2a8d29339d5c801fb465f40d2068e5a3fdb7aa3c Mon Sep 17 00:00:00 2001 From: Daniel Flores Date: Thu, 1 Dec 2016 10:12:47 -0600 Subject: [PATCH 095/195] test: Update to const and use regex for assertions Use const over var. Assert error message with regex. PR-URL: https://github.com/nodejs/node/pull/9891 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-net-localerror.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-net-localerror.js b/test/parallel/test-net-localerror.js index ed7c9471e0397f..184e55c890b2bb 100644 --- a/test/parallel/test-net-localerror.js +++ b/test/parallel/test-net-localerror.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); connect({ host: 'localhost', port: common.PORT, localPort: 'foobar', -}, 'localPort should be a number: foobar'); +}, /^TypeError: "localPort" option should be a number: foobar$/); connect({ host: 'localhost', port: common.PORT, localAddress: 'foobar', -}, 'localAddress should be a valid IP: foobar'); +}, /^TypeError: "localAddress" option must be a valid IP: foobar$/); function connect(opts, msg) { assert.throws(function() { From 22b15f2ab66cadef393b385225c1f08d5097d880 Mon Sep 17 00:00:00 2001 From: Harish Tejwani Date: Thu, 1 Dec 2016 10:14:12 -0600 Subject: [PATCH 096/195] test: change var to const for require and strict equality checks PR-URL: https://github.com/nodejs/node/pull/9892 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- .../test-require-extensions-same-filename-as-dir.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-require-extensions-same-filename-as-dir.js b/test/parallel/test-require-extensions-same-filename-as-dir.js index 41051dad45e10f..ff95a47b9a83bf 100644 --- a/test/parallel/test-require-extensions-same-filename-as-dir.js +++ b/test/parallel/test-require-extensions-same-filename-as-dir.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var content = require(common.fixturesDir + +const content = require(common.fixturesDir + '/json-with-directory-name-module/module-stub/one/two/three.js'); -assert.notEqual(content.rocko, 'artischocko'); -assert.equal(content, 'hello from module-stub!'); +assert.notStrictEqual(content.rocko, 'artischocko'); +assert.strictEqual(content, 'hello from module-stub!'); From e070588a8a1fcb74d2f4753d9e49987bd27a80ed Mon Sep 17 00:00:00 2001 From: Wes Tyler Date: Thu, 1 Dec 2016 10:06:40 -0600 Subject: [PATCH 097/195] test: refactor test-child-process-stdio-inherit assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9893 Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-child-process-stdio-inherit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-child-process-stdio-inherit.js b/test/parallel/test-child-process-stdio-inherit.js index 409c0af7ca0d31..dc3bb3e9aa9391 100644 --- a/test/parallel/test-child-process-stdio-inherit.js +++ b/test/parallel/test-child-process-stdio-inherit.js @@ -22,10 +22,10 @@ function grandparent() { child.stdin.end(input); child.on('close', function(code, signal) { - assert.equal(code, 0); - assert.equal(signal, null); + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); // cat on windows adds a \r\n at the end. - assert.equal(output.trim(), input.trim()); + assert.strictEqual(output.trim(), input.trim()); }); } From 55b58baed16e900142fb266b9d62d79ff9cfe96e Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 1 Dec 2016 11:05:31 -0600 Subject: [PATCH 098/195] test: use assert.strictEqual in test-crypto-ecb Updated test-crypto-ecb.js to change assert.equal to assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/9980 Reviewed-By: Rich Trott --- test/parallel/test-crypto-ecb.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-ecb.js b/test/parallel/test-crypto-ecb.js index dbdb486e9bcf7f..d423a386b30a19 100644 --- a/test/parallel/test-crypto-ecb.js +++ b/test/parallel/test-crypto-ecb.js @@ -21,7 +21,7 @@ crypto.DEFAULT_ENCODING = 'buffer'; var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); var hex = encrypt.update('Hello World!', 'ascii', 'hex'); hex += encrypt.final('hex'); - assert.equal(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71'); + assert.strictEqual(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71'); }()); (function() { @@ -29,5 +29,5 @@ crypto.DEFAULT_ENCODING = 'buffer'; ''); var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii'); msg += decrypt.final('ascii'); - assert.equal(msg, 'Hello World!'); + assert.strictEqual(msg, 'Hello World!'); }()); From cdc2909882fab75eb2da04f3d775b2176f0985f2 Mon Sep 17 00:00:00 2001 From: Jonathan Darling Date: Thu, 1 Dec 2016 09:50:25 -0600 Subject: [PATCH 099/195] test: refactor test-fs-read-stream-inherit.js * convert assert.equal to assert.strictEqual * convert var to const/let PR-URL: https://github.com/nodejs/node/pull/9894 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-fs-read-stream-inherit.js | 92 ++++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/test/parallel/test-fs-read-stream-inherit.js b/test/parallel/test-fs-read-stream-inherit.js index c4216f4e13905b..40ec5ed883829b 100644 --- a/test/parallel/test-fs-read-stream-inherit.js +++ b/test/parallel/test-fs-read-stream-inherit.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var fn = path.join(common.fixturesDir, 'elipses.txt'); -var rangeFile = path.join(common.fixturesDir, 'x.txt'); +const path = require('path'); +const fs = require('fs'); +const fn = path.join(common.fixturesDir, 'elipses.txt'); +const rangeFile = path.join(common.fixturesDir, 'x.txt'); -var callbacks = { open: 0, end: 0, close: 0 }; +const callbacks = { open: 0, end: 0, close: 0 }; -var paused = false; +let paused = false; -var file = fs.ReadStream(fn); +const file = fs.ReadStream(fn); file.on('open', function(fd) { file.length = 0; callbacks.open++; - assert.equal('number', typeof fd); + assert.strictEqual(typeof fd, 'number'); assert.ok(file.readable); // GH-535 @@ -48,19 +48,17 @@ file.on('end', function(chunk) { file.on('close', function() { callbacks.close++; - - //assert.equal(fs.readFileSync(fn), fileContent); }); -var file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'})); +const file3 = fs.createReadStream(fn, Object.create({encoding: 'utf8'})); file3.length = 0; file3.on('data', function(data) { - assert.equal('string', typeof data); + assert.strictEqual(typeof data, 'string'); file3.length += data.length; - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { // http://www.fileformat.info/info/unicode/char/2026/index.htm - assert.equal('\u2026', data[i]); + assert.strictEqual(data[i], '\u2026'); } }); @@ -69,57 +67,57 @@ file3.on('close', function() { }); process.on('exit', function() { - assert.equal(1, callbacks.open); - assert.equal(1, callbacks.end); - assert.equal(2, callbacks.close); - assert.equal(30000, file.length); - assert.equal(10000, file3.length); + assert.strictEqual(callbacks.open, 1); + assert.strictEqual(callbacks.end, 1); + assert.strictEqual(callbacks.close, 2); + assert.strictEqual(file.length, 30000); + assert.strictEqual(file3.length, 10000); console.error('ok'); }); -var file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, - start: 1, end: 2})); -assert.equal(file4.start, 1); -assert.equal(file4.end, 2); -var contentRead = ''; +const file4 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, + start: 1, end: 2})); +assert.strictEqual(file4.start, 1); +assert.strictEqual(file4.end, 2); +let contentRead = ''; file4.on('data', function(data) { contentRead += data.toString('utf-8'); }); file4.on('end', function(data) { - assert.equal(contentRead, 'yz'); + assert.strictEqual(contentRead, 'yz'); }); -var file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, - start: 1})); -assert.equal(file5.start, 1); +const file5 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1, + start: 1})); +assert.strictEqual(file5.start, 1); file5.data = ''; file5.on('data', function(data) { file5.data += data.toString('utf-8'); }); file5.on('end', function() { - assert.equal(file5.data, 'yz\n'); + assert.strictEqual(file5.data, 'yz\n'); }); // https://github.com/joyent/node/issues/2320 -var file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23, - start: 1})); -assert.equal(file6.start, 1); +const file6 = fs.createReadStream(rangeFile, Object.create({bufferSize: 1.23, + start: 1})); +assert.strictEqual(file6.start, 1); file6.data = ''; file6.on('data', function(data) { file6.data += data.toString('utf-8'); }); file6.on('end', function() { - assert.equal(file6.data, 'yz\n'); + assert.strictEqual(file6.data, 'yz\n'); }); assert.throws(function() { fs.createReadStream(rangeFile, Object.create({start: 10, end: 2})); }, /"start" option must be <= "end" option/); -var stream = fs.createReadStream(rangeFile, Object.create({ start: 0, - end: 0 })); -assert.equal(stream.start, 0); -assert.equal(stream.end, 0); +const stream = fs.createReadStream(rangeFile, Object.create({ start: 0, + end: 0 })); +assert.strictEqual(stream.start, 0); +assert.strictEqual(stream.end, 0); stream.data = ''; stream.on('data', function(chunk) { @@ -127,16 +125,16 @@ stream.on('data', function(chunk) { }); stream.on('end', function() { - assert.equal('x', stream.data); + assert.strictEqual(stream.data, 'x'); }); // pause and then resume immediately. -var pauseRes = fs.createReadStream(rangeFile); +const pauseRes = fs.createReadStream(rangeFile); pauseRes.pause(); pauseRes.resume(); -var file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false })); -assert.equal(file7.autoClose, false); +let file7 = fs.createReadStream(rangeFile, Object.create({autoClose: false })); +assert.strictEqual(file7.autoClose, false); file7.on('data', function() {}); file7.on('end', function() { process.nextTick(function() { @@ -154,18 +152,18 @@ function file7Next() { file7.data += data; }); file7.on('end', function(err) { - assert.equal(file7.data, 'xyz\n'); + assert.strictEqual(file7.data, 'xyz\n'); }); } // Just to make sure autoClose won't close the stream because of error. -var file8 = fs.createReadStream(null, Object.create({fd: 13337, - autoClose: false })); +const file8 = fs.createReadStream(null, Object.create({fd: 13337, + autoClose: false })); file8.on('data', function() {}); file8.on('error', common.mustCall(function() {})); // Make sure stream is destroyed when file does not exist. -var file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); +const file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); file9.on('data', function() {}); file9.on('error', common.mustCall(function() {})); From 7697aee7da032c0df53b6c54d40e21e5307811c7 Mon Sep 17 00:00:00 2001 From: JDHarmon Date: Thu, 1 Dec 2016 12:56:32 -0500 Subject: [PATCH 100/195] test: use strictEqual in cwd-enoent Changed all references from assert.Equal() to assert.strictEqual(). PR-URL: https://github.com/nodejs/node/pull/10077 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-cwd-enoent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js index f5c04fe068e945..c671ef2be4619e 100644 --- a/test/parallel/test-cwd-enoent.js +++ b/test/parallel/test-cwd-enoent.js @@ -21,6 +21,6 @@ proc.stdout.pipe(process.stdout); proc.stderr.pipe(process.stderr); proc.once('exit', common.mustCall(function(exitCode, signalCode) { - assert.equal(exitCode, 0); - assert.equal(signalCode, null); + assert.strictEqual(exitCode, 0); + assert.strictEqual(signalCode, null); })); From c4fbdfa7854485dc44d2489026a6f22e77a33e23 Mon Sep 17 00:00:00 2001 From: iamchenxin Date: Fri, 2 Dec 2016 00:14:26 -0700 Subject: [PATCH 101/195] doc: fix typo for `decipher.final`. The `output_encoding` parameter should be as the same as `decipher.update`. PR-URL: https://github.com/nodejs/node/pull/10086 Reviewed-By: Anna Henningsen --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 4dec3e0aca17f8..17d5a5c0faf2c7 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -317,7 +317,7 @@ added: v0.1.94 --> Returns any remaining deciphered contents. If `output_encoding` -parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned. +parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned. If an `output_encoding` is not provided, a [`Buffer`][] is returned. Once the `decipher.final()` method has been called, the `Decipher` object can From 9b9fe8c5acc3f4ef50621f51a350100e2cc8a7f0 Mon Sep 17 00:00:00 2001 From: bjdelro Date: Thu, 1 Dec 2016 10:17:17 -0600 Subject: [PATCH 102/195] test: change var to const in test-tls-key-mismatch.js PR-URL: https://github.com/nodejs/node/pull/9897 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-tls-key-mismatch.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-tls-key-mismatch.js b/test/parallel/test-tls-key-mismatch.js index f0eb8121bd68e5..65cac6f07a296c 100644 --- a/test/parallel/test-tls-key-mismatch.js +++ b/test/parallel/test-tls-key-mismatch.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); +const assert = require('assert'); +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; From c4902e44ad6c6dd5415d3adc1b679ae362d26c4b Mon Sep 17 00:00:00 2001 From: Hitesh Kanwathirtha Date: Fri, 2 Dec 2016 07:22:55 +0000 Subject: [PATCH 103/195] test: polish test-net-better-error-messages-listen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleans up test-net-better-error-messages-list.js with following: - var -> const - assert.equal -> assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/10087 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso --- .../test-net-better-error-messages-listen.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-better-error-messages-listen.js b/test/parallel/test-net-better-error-messages-listen.js index 44adce71a7d541..15ef4036aaa89a 100644 --- a/test/parallel/test-net-better-error-messages-listen.js +++ b/test/parallel/test-net-better-error-messages-listen.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(common.fail); +const server = net.createServer(common.fail); server.listen(1, '1.1.1.1', common.fail); server.on('error', common.mustCall(function(e) { - assert.equal(e.address, '1.1.1.1'); - assert.equal(e.port, 1); - assert.equal(e.syscall, 'listen'); + assert.strictEqual(e.address, '1.1.1.1'); + assert.strictEqual(e.port, 1); + assert.strictEqual(e.syscall, 'listen'); })); From ea1c4e12126a962c1393aa0512bd046b2c707307 Mon Sep 17 00:00:00 2001 From: joyeecheung Date: Thu, 1 Dec 2016 19:11:43 -0600 Subject: [PATCH 104/195] test,url: improve escaping in url.parse - rename variables in autoEscapeStr so they are easier to understand - comment the escaping algorithm - increase coverage for autoEscapeStr PR-URL: https://github.com/nodejs/node/pull/10083 Reviewed-By: Anna Henningsen --- lib/url.js | 136 ++++++++++++++++++++------------------ test/parallel/test-url.js | 14 ++++ 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/lib/url.js b/lib/url.js index 5f87c0c36c43e5..03a9fb03dfcca7 100644 --- a/lib/url.js +++ b/lib/url.js @@ -437,105 +437,111 @@ function validateHostname(self, rest, hostname) { } } +// Automatically escape all delimiters and unwise characters from RFC 2396. +// Also escape single quotes in case of an XSS attack. +// Return undefined if the string doesn't need escaping, +// otherwise return the escaped string. function autoEscapeStr(rest) { - var newRest = ''; - var lastPos = 0; + var escaped = ''; + var lastEscapedPos = 0; for (var i = 0; i < rest.length; ++i) { - // Automatically escape all delimiters and unwise characters from RFC 2396 - // Also escape single quotes in case of an XSS attack + // Manual switching is faster than using a Map/Object. + // `escaped` contains substring up to the last escaped cahracter. switch (rest.charCodeAt(i)) { case 9: // '\t' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%09'; - lastPos = i + 1; + // Concat if there are ordinary characters in the middle. + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%09'; + lastEscapedPos = i + 1; break; case 10: // '\n' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%0A'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%0A'; + lastEscapedPos = i + 1; break; case 13: // '\r' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%0D'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%0D'; + lastEscapedPos = i + 1; break; case 32: // ' ' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%20'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%20'; + lastEscapedPos = i + 1; break; case 34: // '"' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%22'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%22'; + lastEscapedPos = i + 1; break; case 39: // '\'' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%27'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%27'; + lastEscapedPos = i + 1; break; case 60: // '<' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%3C'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%3C'; + lastEscapedPos = i + 1; break; case 62: // '>' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%3E'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%3E'; + lastEscapedPos = i + 1; break; case 92: // '\\' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%5C'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%5C'; + lastEscapedPos = i + 1; break; case 94: // '^' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%5E'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%5E'; + lastEscapedPos = i + 1; break; case 96: // '`' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%60'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%60'; + lastEscapedPos = i + 1; break; case 123: // '{' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%7B'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%7B'; + lastEscapedPos = i + 1; break; case 124: // '|' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%7C'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%7C'; + lastEscapedPos = i + 1; break; case 125: // '}' - if (i - lastPos > 0) - newRest += rest.slice(lastPos, i); - newRest += '%7D'; - lastPos = i + 1; + if (i > lastEscapedPos) + escaped += rest.slice(lastEscapedPos, i); + escaped += '%7D'; + lastEscapedPos = i + 1; break; } } - if (lastPos === 0) + if (lastEscapedPos === 0) // Nothing has been escaped. return; - if (lastPos < rest.length) - return newRest + rest.slice(lastPos); - else - return newRest; + // There are ordinary characters at the end. + if (lastEscapedPos < rest.length) + return escaped + rest.slice(lastEscapedPos); + else // The last character is escaped. + return escaped; } // format a parsed object into a url string diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index 8bbc7194732368..c97caa36429a9c 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -834,6 +834,20 @@ var parseTests = { query: '@c' }, + 'http://a.b/\tbc\ndr\ref g"hq\'j?mn\\op^q=r`99{st|uv}wz': { + protocol: 'http:', + slashes: true, + host: 'a.b', + port: null, + hostname: 'a.b', + hash: null, + pathname: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E', + path: '/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', + search: '?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', + query: 'mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz', + href: 'http://a.b/%09bc%0Adr%0Def%20g%22hq%27j%3Ckl%3E?mn%5Cop%5Eq=r%6099%7Bst%7Cuv%7Dwz' + }, + 'http://a\r" \t\n<\'b:b@c\r\nd/e?f': { protocol: 'http:', slashes: true, From d87926ae34a01552a4b1e34b3756585557540e18 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 1 Dec 2016 13:35:05 -0600 Subject: [PATCH 105/195] test: assert.equal -> assert.strictEqual changes assert.equal to assert.strictEqual to ensure specificity PR-URL: https://github.com/nodejs/node/pull/10067 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-crypto-domain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-crypto-domain.js b/test/parallel/test-crypto-domain.js index 9bb6c0229648e7..ec9985719933d3 100644 --- a/test/parallel/test-crypto-domain.js +++ b/test/parallel/test-crypto-domain.js @@ -13,7 +13,7 @@ function test(fn) { var ex = new Error('BAM'); var d = domain.create(); d.on('error', common.mustCall(function(err) { - assert.equal(err, ex); + assert.strictEqual(err, ex); })); var cb = common.mustCall(function() { throw ex; From a34e19532ca8e033d78d3f3dde007360b8b1c778 Mon Sep 17 00:00:00 2001 From: Cesar Hernandez Date: Thu, 1 Dec 2016 13:31:53 -0600 Subject: [PATCH 106/195] test: refactor test-dgram-exclusive-implicit-bind * assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/10066 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Santiago Gimeno --- test/parallel/test-dgram-exclusive-implicit-bind.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js index 9a3cb91b3ac105..c8799cf058b99e 100644 --- a/test/parallel/test-dgram-exclusive-implicit-bind.js +++ b/test/parallel/test-dgram-exclusive-implicit-bind.js @@ -45,7 +45,7 @@ if (cluster.isMaster) { var ports = {}; process.on('exit', function() { - assert.equal(pass, true); + assert.strictEqual(pass, true); }); var target = dgram.createSocket('udp4'); @@ -55,12 +55,12 @@ if (cluster.isMaster) { ports[rinfo.port] = true; if (common.isWindows && messages === 2) { - assert.equal(Object.keys(ports).length, 2); + assert.strictEqual(Object.keys(ports).length, 2); done(); } if (!common.isWindows && messages === 4) { - assert.equal(Object.keys(ports).length, 3); + assert.strictEqual(Object.keys(ports).length, 3); done(); } From baa1accdb160f52509e36340dd2872a8ce35b296 Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 1 Dec 2016 13:24:40 -0600 Subject: [PATCH 107/195] test: assert.equal -> assert.strictEqual changes assert.equal to assert.strictEqual to ensure specificity PR-URL: https://github.com/nodejs/node/pull/10065 Reviewed-By: Colin Ihrig --- test/parallel/test-crypto-stream.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js index 10271e27da4191..1720cc7c4e0aea 100644 --- a/test/parallel/test-crypto-stream.js +++ b/test/parallel/test-crypto-stream.js @@ -30,8 +30,10 @@ if (!common.hasFipsCrypto) { // Create an md5 hash of "Hallo world" var hasher1 = crypto.createHash('md5'); hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { - assert.equal(err, null); - assert.equal(hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07'); + assert.strictEqual(err, null); + assert.strictEqual( + hash.toString('hex'), '06460dadb35d3d503047ce750ceb2d07' + ); }))); hasher1.end('Hallo world'); From 69077a13bf048a23621e99ac70026d45549b6b9e Mon Sep 17 00:00:00 2001 From: adelmann Date: Sat, 3 Dec 2016 23:05:27 -0800 Subject: [PATCH 108/195] test: refactor test-fs-append-file.js - Replaced var with either const or let. - Replaced assert.equal() with assert.strictEqual(). - Replaced all error checks with assert.ifError(e). PR-URL: https://github.com/nodejs/node/pull/10110 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- test/parallel/test-fs-append-file.js | 87 ++++++++++++++-------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/test/parallel/test-fs-append-file.js b/test/parallel/test-fs-append-file.js index 5970c8cec1515d..00691b1e74e6fe 100644 --- a/test/parallel/test-fs-append-file.js +++ b/test/parallel/test-fs-append-file.js @@ -1,129 +1,130 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var join = require('path').join; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const join = require('path').join; -var filename = join(common.tmpDir, 'append.txt'); +const filename = join(common.tmpDir, 'append.txt'); -var currentFileData = 'ABCD'; +const currentFileData = 'ABCD'; -var n = 220; -var s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + - '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + - '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + - '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + - '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + - '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + - '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; +const n = 220; +const s = '南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、' + + '广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。' + + '南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。' + + '前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + + '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,' + + '历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,' + + '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; -var ncallbacks = 0; +let ncallbacks = 0; common.refreshTmpDir(); // test that empty file will be created and have content added fs.appendFile(filename, s, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.readFile(filename, function(e, buffer) { - if (e) throw e; + assert.ifError(e); ncallbacks++; - assert.equal(Buffer.byteLength(s), buffer.length); + assert.strictEqual(Buffer.byteLength(s), buffer.length); }); }); // test that appends data to a non empty file -var filename2 = join(common.tmpDir, 'append2.txt'); +const filename2 = join(common.tmpDir, 'append2.txt'); fs.writeFileSync(filename2, currentFileData); fs.appendFile(filename2, s, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.readFile(filename2, function(e, buffer) { - if (e) throw e; + assert.ifError(e); ncallbacks++; - assert.equal(Buffer.byteLength(s) + currentFileData.length, buffer.length); + assert.strictEqual(Buffer.byteLength(s) + currentFileData.length, + buffer.length); }); }); // test that appendFile accepts buffers -var filename3 = join(common.tmpDir, 'append3.txt'); +const filename3 = join(common.tmpDir, 'append3.txt'); fs.writeFileSync(filename3, currentFileData); -var buf = Buffer.from(s, 'utf8'); +const buf = Buffer.from(s, 'utf8'); fs.appendFile(filename3, buf, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.readFile(filename3, function(e, buffer) { - if (e) throw e; + assert.ifError(e); ncallbacks++; - assert.equal(buf.length + currentFileData.length, buffer.length); + assert.strictEqual(buf.length + currentFileData.length, buffer.length); }); }); // test that appendFile accepts numbers. -var filename4 = join(common.tmpDir, 'append4.txt'); +const filename4 = join(common.tmpDir, 'append4.txt'); fs.writeFileSync(filename4, currentFileData); -var m = 0o600; +const m = 0o600; fs.appendFile(filename4, n, { mode: m }, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; // windows permissions aren't unix if (!common.isWindows) { - var st = fs.statSync(filename4); - assert.equal(st.mode & 0o700, m); + const st = fs.statSync(filename4); + assert.strictEqual(st.mode & 0o700, m); } fs.readFile(filename4, function(e, buffer) { - if (e) throw e; + assert.ifError(e); ncallbacks++; - assert.equal(Buffer.byteLength('' + n) + currentFileData.length, - buffer.length); + assert.strictEqual(Buffer.byteLength('' + n) + currentFileData.length, + buffer.length); }); }); // test that appendFile accepts file descriptors -var filename5 = join(common.tmpDir, 'append5.txt'); +const filename5 = join(common.tmpDir, 'append5.txt'); fs.writeFileSync(filename5, currentFileData); fs.open(filename5, 'a+', function(e, fd) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.appendFile(fd, s, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.close(fd, function(e) { - if (e) throw e; + assert.ifError(e); ncallbacks++; fs.readFile(filename5, function(e, buffer) { - if (e) throw e; + assert.ifError(e); ncallbacks++; - assert.equal(Buffer.byteLength(s) + currentFileData.length, - buffer.length); + assert.strictEqual(Buffer.byteLength(s) + currentFileData.length, + buffer.length); }); }); }); }); process.on('exit', function() { - assert.equal(12, ncallbacks); + assert.strictEqual(12, ncallbacks); fs.unlinkSync(filename); fs.unlinkSync(filename2); From 3253954e6226687c2c1eb5041ea6cf517ab288c9 Mon Sep 17 00:00:00 2001 From: Claudio Rodriguez Date: Mon, 8 Aug 2016 17:55:16 +0100 Subject: [PATCH 109/195] meta: whitelist dotfiles in .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of excluding IDE-specific dotfiles, exclude all and then whitelist those the project needs to track. Refs: https://github.com/nodejs/node/pull/8010 Refs: https://github.com/nodejs/node/pull/9111 Refs: https://github.com/nodejs/node/pull/10052 Fixes: https://github.com/nodejs/node/issues/8012 PR-URL: https://github.com/nodejs/node/pull/8016 Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann Reviewed-By: Jeremiah Senkpiel Reviewed-By: Michaël Zasso Reviewed-By: Roman Reiss Reviewed-By: Josh Gavant --- .gitignore | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b6790e116cd6b5..4f129c4581ba8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,19 @@ +# Whitelist dotfiles +.* +!deps/**/.* +!test/fixtures/**/.* +!tools/eslint/**/.* +!tools/doc/node_modules/**/.* +!.editorconfig +!.eslintignore +!.eslintrc +!.gitattributes +!.github +!.gitignore +!.gitkeep +!.mailmap +!.remarkrc + core vgcore.* v8*.log @@ -16,8 +32,6 @@ node node_g *.swp .benchmark_reports -/.project -/.cproject icu_config.gypi .eslintcache From e1394eeb162abb5668a9342406986cc89c11a171 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Thu, 1 Dec 2016 10:54:34 -0600 Subject: [PATCH 110/195] test: refactor test-tls-friendly-error-message.js Replaces var with const and adds common.mustCall(). PR-URL: https://github.com/nodejs/node/pull/9967 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- .../test-tls-friendly-error-message.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-tls-friendly-error-message.js b/test/parallel/test-tls-friendly-error-message.js index c53dd7cbc07205..9ae69f4016e319 100644 --- a/test/parallel/test-tls-friendly-error-message.js +++ b/test/parallel/test-tls-friendly-error-message.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); -var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); +const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); -tls.createServer({ key: key, cert: cert }, function(conn) { +tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) { conn.end(); this.close(); -}).listen(0, function() { +})).listen(0, common.mustCall(function() { var options = { port: this.address().port, rejectUnauthorized: true }; tls.connect(options).on('error', common.mustCall(function(err) { - assert.equal(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); - assert.equal(err.message, 'unable to verify the first certificate'); + assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); + assert.strictEqual(err.message, 'unable to verify the first certificate'); this.destroy(); })); -}); +})); From a771f2181caec71e3a1a398efc3add170cb3636b Mon Sep 17 00:00:00 2001 From: Richard Karmazin Date: Thu, 1 Dec 2016 10:56:07 -0600 Subject: [PATCH 111/195] test: use strictEqual in test-cli-eval-event.js PR-URL: https://github.com/nodejs/node/pull/9964 Reviewed-By: Colin Ihrig --- test/parallel/test-cli-eval-event.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-cli-eval-event.js b/test/parallel/test-cli-eval-event.js index b19bdd38680f79..df356e50d37b66 100644 --- a/test/parallel/test-cli-eval-event.js +++ b/test/parallel/test-cli-eval-event.js @@ -10,6 +10,6 @@ const child = spawn(process.execPath, ['-e', ` `]); child.once('exit', common.mustCall(function(exitCode, signalCode) { - assert.equal(exitCode, 0); - assert.equal(signalCode, null); + assert.strictEqual(exitCode, 0); + assert.strictEqual(signalCode, null); })); From 38ec8e44fa01fc52c2493b475356c35a78777c27 Mon Sep 17 00:00:00 2001 From: Julian Duque Date: Thu, 1 Dec 2016 10:21:00 -0600 Subject: [PATCH 112/195] test: improve test for crypto padding Replace assert.equal with assert.strictEqual and use RegExp in assert.throws PR-URL: https://github.com/nodejs/node/pull/9906 Reviewed-By: Colin Ihrig --- test/parallel/test-crypto-padding.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js index 7822df64d9e2de..eeb41f278ac6fc 100644 --- a/test/parallel/test-crypto-padding.js +++ b/test/parallel/test-crypto-padding.js @@ -74,16 +74,18 @@ function dec(encd, pad) { * Test encryption */ -assert.equal(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED); -assert.equal(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED); +assert.strictEqual(enc(ODD_LENGTH_PLAIN, true), ODD_LENGTH_ENCRYPTED); +assert.strictEqual(enc(EVEN_LENGTH_PLAIN, true), EVEN_LENGTH_ENCRYPTED); assert.throws(function() { // input must have block length % enc(ODD_LENGTH_PLAIN, false); -}); +}, /data not multiple of block length/); assert.doesNotThrow(function() { - assert.equal(enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD); + assert.strictEqual( + enc(EVEN_LENGTH_PLAIN, false), EVEN_LENGTH_ENCRYPTED_NOPAD + ); }); @@ -91,21 +93,25 @@ assert.doesNotThrow(function() { * Test decryption */ -assert.equal(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN); -assert.equal(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN); +assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, true), ODD_LENGTH_PLAIN); +assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, true), EVEN_LENGTH_PLAIN); assert.doesNotThrow(function() { // returns including original padding - assert.equal(dec(ODD_LENGTH_ENCRYPTED, false).length, 32); - assert.equal(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48); + assert.strictEqual(dec(ODD_LENGTH_ENCRYPTED, false).length, 32); + assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED, false).length, 48); }); assert.throws(function() { // must have at least 1 byte of padding (PKCS): - assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN); -}); + assert.strictEqual( + dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN + ); +}, /bad decrypt/); assert.doesNotThrow(function() { // no-pad encrypted string should return the same: - assert.equal(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN); + assert.strictEqual( + dec(EVEN_LENGTH_ENCRYPTED_NOPAD, false), EVEN_LENGTH_PLAIN + ); }); From 36b8dd3b0732899bb5c362680ffe680393fcab10 Mon Sep 17 00:00:00 2001 From: Konstantin Likhter Date: Thu, 1 Dec 2016 08:52:38 -0800 Subject: [PATCH 113/195] test: refactor test-crypto-padding.js - Replaced var with const and let. - Replaced assert.equal() with assert.strictEqual(). - Added error message checking for assert.throws(). PR-URL: https://github.com/nodejs/node/pull/9971 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Anna Henningsen --- test/parallel/test-crypto-padding.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-crypto-padding.js b/test/parallel/test-crypto-padding.js index eeb41f278ac6fc..70905a8a9bd1e7 100644 --- a/test/parallel/test-crypto-padding.js +++ b/test/parallel/test-crypto-padding.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; @@ -21,7 +21,7 @@ const EVEN_LENGTH_PLAIN = 'Hello node world!AbC09876dDeFgHi'; const KEY_PLAIN = 'S3c.r.e.t.K.e.Y!'; const IV_PLAIN = 'blahFizz2011Buzz'; -var CIPHER_NAME = 'aes-128-cbc'; +const CIPHER_NAME = 'aes-128-cbc'; /* @@ -31,20 +31,20 @@ var CIPHER_NAME = 'aes-128-cbc'; // echo -n 'Hello node world!' | \ // openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \ // -iv 626c616846697a7a3230313142757a7a | xxd -p -c256 -var ODD_LENGTH_ENCRYPTED = +const ODD_LENGTH_ENCRYPTED = '7f57859550d4d2fdb9806da2a750461a9fe77253cd1cbd4b07beee4e070d561f'; // echo -n 'Hello node world!AbC09876dDeFgHi' | \ // openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \ // -iv 626c616846697a7a3230313142757a7a | xxd -p -c256 -var EVEN_LENGTH_ENCRYPTED = +const EVEN_LENGTH_ENCRYPTED = '7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b988' + '6119866912cb8c7bcaf76c5ebc2378'; // echo -n 'Hello node world!AbC09876dDeFgHi' | \ // openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \ // -iv 626c616846697a7a3230313142757a7a -nopad | xxd -p -c256 -var EVEN_LENGTH_ENCRYPTED_NOPAD = +const EVEN_LENGTH_ENCRYPTED_NOPAD = '7f57859550d4d2fdb9806da2a750461ab46e' + '71b3d78ebe2d9684dfc87f7575b9'; @@ -54,17 +54,17 @@ var EVEN_LENGTH_ENCRYPTED_NOPAD = */ function enc(plain, pad) { - var encrypt = crypto.createCipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN); + const encrypt = crypto.createCipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN); encrypt.setAutoPadding(pad); - var hex = encrypt.update(plain, 'ascii', 'hex'); + let hex = encrypt.update(plain, 'ascii', 'hex'); hex += encrypt.final('hex'); return hex; } function dec(encd, pad) { - var decrypt = crypto.createDecipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN); + const decrypt = crypto.createDecipheriv(CIPHER_NAME, KEY_PLAIN, IV_PLAIN); decrypt.setAutoPadding(pad); - var plain = decrypt.update(encd, 'hex'); + let plain = decrypt.update(encd, 'hex'); plain += decrypt.final('latin1'); return plain; } @@ -104,9 +104,7 @@ assert.doesNotThrow(function() { assert.throws(function() { // must have at least 1 byte of padding (PKCS): - assert.strictEqual( - dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN - ); + assert.strictEqual(dec(EVEN_LENGTH_ENCRYPTED_NOPAD, true), EVEN_LENGTH_PLAIN); }, /bad decrypt/); assert.doesNotThrow(function() { From 14c03889457a14d85fac39a9dfd57560c3b6e9dc Mon Sep 17 00:00:00 2001 From: Hutson Betts Date: Thu, 1 Dec 2016 10:27:39 -0600 Subject: [PATCH 114/195] test: refactor test-tls-server-verify Refactored `test-tls-server-verify.js` to replace uses of `var` with `const` and `let`. Also replaced uses of `assert.equal` with `assert.strictEqual`. PR-URL: https://github.com/nodejs/node/pull/10076 Reviewed-By: Michael Dawson --- test/parallel/test-tls-server-verify.js | 60 ++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index a51aef51564690..04c1547384c61e 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -14,7 +14,7 @@ if (!common.opensslCli) { // - accepted and "unauthorized", or // - accepted and "authorized". -var testCases = +const testCases = [{ title: 'Do not request certs. Everyone is unauthorized.', requestCert: false, rejectUnauthorized: false, @@ -102,14 +102,14 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = require('crypto').constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; -var assert = require('assert'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const fs = require('fs'); +const spawn = require('child_process').spawn; function filenamePEM(n) { @@ -122,8 +122,8 @@ function loadPEM(n) { } -var serverKey = loadPEM('agent2-key'); -var serverCert = loadPEM('agent2-cert'); +const serverKey = loadPEM('agent2-key'); +const serverCert = loadPEM('agent2-cert'); function runClient(prefix, port, options, cb) { @@ -133,7 +133,7 @@ function runClient(prefix, port, options, cb) { // - Certificate, but not signed by CA. // - Certificate signed by CA. - var args = ['s_client', '-connect', '127.0.0.1:' + port]; + const args = ['s_client', '-connect', '127.0.0.1:' + port]; // for the performance issue in s_client on Windows if (common.isWindows) @@ -184,13 +184,13 @@ function runClient(prefix, port, options, cb) { } // To test use: openssl s_client -connect localhost:8000 - var client = spawn(common.opensslCli, args); + const client = spawn(common.opensslCli, args); - var out = ''; + let out = ''; - var rejected = true; - var authed = false; - var goodbye = false; + let rejected = true; + let authed = false; + let goodbye = false; client.stdout.setEncoding('utf8'); client.stdout.on('data', function(d) { @@ -219,12 +219,12 @@ function runClient(prefix, port, options, cb) { //assert.equal(0, code, prefix + options.name + // ": s_client exited with error code " + code); if (options.shouldReject) { - assert.equal(true, rejected, prefix + options.name + + assert.strictEqual(true, rejected, prefix + options.name + ' NOT rejected, but should have been'); } else { - assert.equal(false, rejected, prefix + options.name + + assert.strictEqual(false, rejected, prefix + options.name + ' rejected, but should NOT have been'); - assert.equal(options.shouldAuth, authed, prefix + + assert.strictEqual(options.shouldAuth, authed, prefix + options.name + ' authed is ' + authed + ' but should have been ' + options.shouldAuth); } @@ -235,19 +235,19 @@ function runClient(prefix, port, options, cb) { // Run the tests -var successfulTests = 0; +let successfulTests = 0; function runTest(port, testIndex) { - var prefix = testIndex + ' '; - var tcase = testCases[testIndex]; + const prefix = testIndex + ' '; + const tcase = testCases[testIndex]; if (!tcase) return; console.error(prefix + "Running '%s'", tcase.title); - var cas = tcase.CAs.map(loadPEM); + const cas = tcase.CAs.map(loadPEM); - var crl = tcase.crl ? loadPEM(tcase.crl) : null; + const crl = tcase.crl ? loadPEM(tcase.crl) : null; - var serverOptions = { + const serverOptions = { key: serverKey, cert: serverCert, ca: cas, @@ -265,8 +265,8 @@ function runTest(port, testIndex) { SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; } - var renegotiated = false; - var server = tls.Server(serverOptions, function handleConnection(c) { + let renegotiated = false; + const server = tls.Server(serverOptions, function handleConnection(c) { c.on('error', function(e) { // child.kill() leads ECONNRESET errro in the TLS connection of // openssl s_client via spawn(). A Test result is already @@ -301,7 +301,7 @@ function runTest(port, testIndex) { }); function runNextClient(clientIndex) { - var options = tcase.clients[clientIndex]; + const options = tcase.clients[clientIndex]; if (options) { runClient(prefix + clientIndex + ' ', port, options, function() { runNextClient(clientIndex + 1); @@ -321,8 +321,8 @@ function runTest(port, testIndex) { if (tcase.renegotiate) { runNextClient(0); } else { - var clientsCompleted = 0; - for (var i = 0; i < tcase.clients.length; i++) { + let clientsCompleted = 0; + for (let i = 0; i < tcase.clients.length; i++) { runClient(prefix + i + ' ', port, tcase.clients[i], function() { clientsCompleted++; if (clientsCompleted === tcase.clients.length) { @@ -338,11 +338,11 @@ function runTest(port, testIndex) { } -var nextTest = 0; +let nextTest = 0; runTest(0, nextTest++); runTest(0, nextTest++); process.on('exit', function() { - assert.equal(successfulTests, testCases.length); + assert.strictEqual(successfulTests, testCases.length); }); From cf3c635dbae8e8dc84106adeffab4645af88cccc Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 1 Dec 2016 14:23:55 -0600 Subject: [PATCH 115/195] test: refactor test-https-truncate Changes assert.equal to assert.strictEqual to ensure specificity. Changes var declarations to const/let where appropriate. PR-URL: https://github.com/nodejs/node/pull/10074 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- test/parallel/test-https-truncate.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-https-truncate.js b/test/parallel/test-https-truncate.js index 26f133b4a5b48a..4101a8c974e736 100644 --- a/test/parallel/test-https-truncate.js +++ b/test/parallel/test-https-truncate.js @@ -1,34 +1,34 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); -var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); -var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); +const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); // number of bytes discovered empirically to trigger the bug -var data = Buffer.allocUnsafe(1024 * 32 + 1); +const data = Buffer.allocUnsafe(1024 * 32 + 1); httpsTest(); function httpsTest() { - var sopt = { key: key, cert: cert }; + const sopt = { key: key, cert: cert }; - var server = https.createServer(sopt, function(req, res) { + const server = https.createServer(sopt, function(req, res) { res.setHeader('content-length', data.length); res.end(data); server.close(); }); server.listen(0, function() { - var opts = { port: this.address().port, rejectUnauthorized: false }; + const opts = { port: this.address().port, rejectUnauthorized: false }; https.get(opts).on('response', function(res) { test(res); }); @@ -38,14 +38,14 @@ function httpsTest() { function test(res) { res.on('end', function() { - assert.equal(res._readableState.length, 0); - assert.equal(bytes, data.length); + assert.strictEqual(res._readableState.length, 0); + assert.strictEqual(bytes, data.length); console.log('ok'); }); // Pause and then resume on each chunk, to ensure that there will be // a lone byte hanging out at the very end. - var bytes = 0; + let bytes = 0; res.on('data', function(chunk) { bytes += chunk.length; this.pause(); From fd17ca7710a142793016ccce9009caa993eaa6d0 Mon Sep 17 00:00:00 2001 From: "Kent.Fan" Date: Thu, 1 Dec 2016 14:08:44 -0600 Subject: [PATCH 116/195] test: refactor test-net-dns-custom-lookup Use asssert.strictEqual to disallow coersion. PR-URL: https://github.com/nodejs/node/pull/10071 Reviewed-By: Santiago Gimeno Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-net-dns-custom-lookup.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js index 8d91bcba6687ea..07eb71c5ed5811 100644 --- a/test/parallel/test-net-dns-custom-lookup.js +++ b/test/parallel/test-net-dns-custom-lookup.js @@ -18,9 +18,9 @@ function check(addressType, cb) { family: addressType, lookup: lookup }).on('lookup', common.mustCall(function(err, ip, type) { - assert.equal(err, null); - assert.equal(address, ip); - assert.equal(type, addressType); + assert.strictEqual(err, null); + assert.strictEqual(address, ip); + assert.strictEqual(type, addressType); })); })); From c456ca3601c12fbc6ff1d22e5af1e36502b57094 Mon Sep 17 00:00:00 2001 From: Chris Bystrek Date: Thu, 1 Dec 2016 13:18:50 -0600 Subject: [PATCH 117/195] test: refactor test-tls-destroy-whilst-write Update var to let/const and replace arbitrary timeout. PR-URL: https://github.com/nodejs/node/pull/10064 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Gibson Fahnestock --- test/parallel/test-tls-destroy-whilst-write.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-tls-destroy-whilst-write.js b/test/parallel/test-tls-destroy-whilst-write.js index 4f6ede968be408..b4f9766d998630 100644 --- a/test/parallel/test-tls-destroy-whilst-write.js +++ b/test/parallel/test-tls-destroy-whilst-write.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var stream = require('stream'); +const tls = require('tls'); +const stream = require('stream'); -var delay = new stream.Duplex({ +const delay = new stream.Duplex({ read: function read() { }, write: function write(data, enc, cb) { console.log('pending'); - setTimeout(function() { + setImmediate(function() { console.log('done'); cb(); - }, 200); + }); } }); -var secure = tls.connect({ +const secure = tls.connect({ socket: delay }); setImmediate(function() { From 1eb581779db54311d969b7a0ebb7659ad5f2fc3f Mon Sep 17 00:00:00 2001 From: Jay Brownlee Date: Thu, 1 Dec 2016 10:06:21 -0600 Subject: [PATCH 118/195] test: refactor test-vm-syntax-error-stderr.js use common.fail instead of assert(false) change var to let or const as appropriate PR-URL: https://github.com/nodejs/node/pull/9900 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-vm-syntax-error-stderr.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-vm-syntax-error-stderr.js b/test/parallel/test-vm-syntax-error-stderr.js index 7c3c5ff1351da2..43ed8d882804ca 100644 --- a/test/parallel/test-vm-syntax-error-stderr.js +++ b/test/parallel/test-vm-syntax-error-stderr.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var child_process = require('child_process'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const child_process = require('child_process'); -var wrong_script = path.join(common.fixturesDir, 'cert.pem'); +const wrong_script = path.join(common.fixturesDir, 'cert.pem'); -var p = child_process.spawn(process.execPath, [ +const p = child_process.spawn(process.execPath, [ '-e', 'require(process.argv[1]);', wrong_script ]); p.stdout.on('data', function(data) { - assert(false, 'Unexpected stdout data: ' + data); + common.fail('Unexpected stdout data: ' + data); }); -var output = ''; +let output = ''; p.stderr.on('data', function(data) { output += data; From ae2bf0a761422a77be0bd07da19fab521638b902 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 1 Dec 2016 10:18:45 -0600 Subject: [PATCH 119/195] test: Changed assert.equal to assert.strictEqual Updated test-cluster-send-deadlock.js to change assert.equal to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9902 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-cluster-send-deadlock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-cluster-send-deadlock.js b/test/parallel/test-cluster-send-deadlock.js index 90b8c91695359b..fa3e1138248221 100644 --- a/test/parallel/test-cluster-send-deadlock.js +++ b/test/parallel/test-cluster-send-deadlock.js @@ -10,7 +10,7 @@ var net = require('net'); if (cluster.isMaster) { var worker = cluster.fork(); worker.on('exit', function(code, signal) { - assert.equal(code, 0, 'Worker exited with an error code'); + assert.strictEqual(code, 0, 'Worker exited with an error code'); assert(!signal, 'Worker exited by a signal'); server.close(); }); From 5f3f54d4bb0919f2913f8930427927bef3f50b2e Mon Sep 17 00:00:00 2001 From: Outsider Date: Thu, 1 Dec 2016 13:08:04 -0600 Subject: [PATCH 120/195] test: refactor test-http-dns-error Replace var with const and use strictEqual(). PR-URL: https://github.com/nodejs/node/pull/10062 Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno --- test/parallel/test-http-dns-error.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-http-dns-error.js b/test/parallel/test-http-dns-error.js index f1f144a60a24c0..5e15ab9a3fa0da 100644 --- a/test/parallel/test-http-dns-error.js +++ b/test/parallel/test-http-dns-error.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); if (common.hasCrypto) { var https = require('https'); @@ -10,7 +10,7 @@ if (common.hasCrypto) { common.skip('missing crypto'); } -var host = '*'.repeat(256); +const host = '*'.repeat(256); function do_not_call() { throw new Error('This function should not have been called.'); @@ -20,15 +20,15 @@ function test(mod) { // Bad host name should not throw an uncatchable exception. // Ensure that there is time to attach an error listener. - var req1 = mod.get({host: host, port: 42}, do_not_call); + const req1 = mod.get({host: host, port: 42}, do_not_call); req1.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'ENOTFOUND'); + assert.strictEqual(err.code, 'ENOTFOUND'); })); // http.get() called req1.end() for us - var req2 = mod.request({method: 'GET', host: host, port: 42}, do_not_call); + const req2 = mod.request({method: 'GET', host: host, port: 42}, do_not_call); req2.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'ENOTFOUND'); + assert.strictEqual(err.code, 'ENOTFOUND'); })); req2.end(); } From f62567b7f831a4bbe61050ecc7425f96dfa2fb04 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Thu, 1 Dec 2016 10:16:53 -0600 Subject: [PATCH 121/195] test: use const instead of var in test-require-json.js PR-URL: https://github.com/nodejs/node/pull/9904 Reviewed-By: Colin Ihrig Reviewed-By: Myles Borins Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-require-json.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-require-json.js b/test/parallel/test-require-json.js index 75cdb98855e6ee..f2c74dc57d743d 100644 --- a/test/parallel/test-require-json.js +++ b/test/parallel/test-require-json.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var path = require('path'); -var assert = require('assert'); +const common = require('../common'); +const path = require('path'); +const assert = require('assert'); try { require(path.join(common.fixturesDir, 'invalid.json')); } catch (err) { - var re = /test[/\\]fixtures[/\\]invalid.json: Unexpected string/; - var i = err.message.match(re); + const re = /test[/\\]fixtures[/\\]invalid.json: Unexpected string/; + const i = err.message.match(re); assert.notStrictEqual(null, i, 'require() json error should include path'); } From ef7cbde0a2c96a5155b02e21efae8fde4987cb24 Mon Sep 17 00:00:00 2001 From: anoff Date: Thu, 1 Dec 2016 10:05:40 -0600 Subject: [PATCH 122/195] test: changed vars to const in test-net-better-error-messages-listen-path.js * `var` to `const` * use `assert.strictEqual` PR-URL: https://github.com/nodejs/node/pull/9905 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: James M Snell --- .../test-net-better-error-messages-listen-path.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-net-better-error-messages-listen-path.js b/test/parallel/test-net-better-error-messages-listen-path.js index 41d22c3fb9a4b5..50ed80a5e3cd1e 100644 --- a/test/parallel/test-net-better-error-messages-listen-path.js +++ b/test/parallel/test-net-better-error-messages-listen-path.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var fp = '/blah/fadfa'; -var server = net.createServer(common.fail); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const fp = '/blah/fadfa'; +const server = net.createServer(common.fail); server.listen(fp, common.fail); server.on('error', common.mustCall(function(e) { - assert.equal(e.address, fp); + assert.strictEqual(e.address, fp); })); From 65c44830c2aa9049a28efe67bc8e212b34f2333c Mon Sep 17 00:00:00 2001 From: Sean Villars Date: Thu, 1 Dec 2016 10:15:40 -0600 Subject: [PATCH 123/195] test: var to const, assert.equal to assert.strictEqual in net * var -> const * assert.equal -> assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9907 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- ...test-net-better-error-messages-port-hostname.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-better-error-messages-port-hostname.js b/test/parallel/test-net-better-error-messages-port-hostname.js index 23089baf448a39..b08c35f3e63ea5 100644 --- a/test/parallel/test-net-better-error-messages-port-hostname.js +++ b/test/parallel/test-net-better-error-messages-port-hostname.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); -var assert = require('assert'); +const common = require('../common'); +const net = require('net'); +const assert = require('assert'); -var c = net.createConnection(common.PORT, '***'); +const c = net.createConnection(common.PORT, '***'); c.on('connect', common.fail); c.on('error', common.mustCall(function(e) { - assert.equal(e.code, 'ENOTFOUND'); - assert.equal(e.port, common.PORT); - assert.equal(e.hostname, '***'); + assert.strictEqual(e.code, 'ENOTFOUND'); + assert.strictEqual(e.port, common.PORT); + assert.strictEqual(e.hostname, '***'); })); From 9fddf29f53d6e3ad7c30ce4bd9fe6d34612c2316 Mon Sep 17 00:00:00 2001 From: Cesar Hernandez Date: Thu, 1 Dec 2016 10:21:35 -0600 Subject: [PATCH 124/195] test: refactor test-repl-mode.js * var -> const/let * assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/10061 Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel --- test/parallel/test-repl-mode.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/parallel/test-repl-mode.js b/test/parallel/test-repl-mode.js index 08b296c2c341a4..00e9cd577ece90 100644 --- a/test/parallel/test-repl-mode.js +++ b/test/parallel/test-repl-mode.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var Stream = require('stream'); -var repl = require('repl'); +const common = require('../common'); +const assert = require('assert'); +const Stream = require('stream'); +const repl = require('repl'); common.globalCheck = false; -var tests = [ +const tests = [ testSloppyMode, testStrictMode, testAutoMode @@ -17,22 +17,22 @@ tests.forEach(function(test) { }); function testSloppyMode() { - var cli = initRepl(repl.REPL_MODE_SLOPPY); + const cli = initRepl(repl.REPL_MODE_SLOPPY); cli.input.emit('data', ` x = 3 `.trim() + '\n'); - assert.equal(cli.output.accumulator.join(''), '> 3\n> '); + assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> '); cli.output.accumulator.length = 0; cli.input.emit('data', ` let y = 3 `.trim() + '\n'); - assert.equal(cli.output.accumulator.join(''), 'undefined\n> '); + assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> '); } function testStrictMode() { - var cli = initRepl(repl.REPL_MODE_STRICT); + const cli = initRepl(repl.REPL_MODE_STRICT); cli.input.emit('data', ` x = 3 @@ -44,30 +44,30 @@ function testStrictMode() { cli.input.emit('data', ` let y = 3 `.trim() + '\n'); - assert.equal(cli.output.accumulator.join(''), 'undefined\n> '); + assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> '); } function testAutoMode() { - var cli = initRepl(repl.REPL_MODE_MAGIC); + const cli = initRepl(repl.REPL_MODE_MAGIC); cli.input.emit('data', ` x = 3 `.trim() + '\n'); - assert.equal(cli.output.accumulator.join(''), '> 3\n> '); + assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> '); cli.output.accumulator.length = 0; cli.input.emit('data', ` let y = 3 `.trim() + '\n'); - assert.equal(cli.output.accumulator.join(''), 'undefined\n> '); + assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> '); } function initRepl(mode) { - var input = new Stream(); + const input = new Stream(); input.write = input.pause = input.resume = function() {}; input.readable = true; - var output = new Stream(); + const output = new Stream(); output.write = output.pause = output.resume = function(buf) { output.accumulator.push(buf); }; From da8e3d946ad96f5a0e54757cc654a90d12c89496 Mon Sep 17 00:00:00 2001 From: k3kathy Date: Thu, 1 Dec 2016 11:22:07 -0600 Subject: [PATCH 125/195] test: refactor test-child-process-constructor Change all assert.equal() to use assert.strictEqual(). PR-URL: https://github.com/nodejs/node/pull/10060 Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas --- test/parallel/test-child-process-constructor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js index 6980810485c964..0abf1289f0737d 100644 --- a/test/parallel/test-child-process-constructor.js +++ b/test/parallel/test-child-process-constructor.js @@ -4,7 +4,7 @@ require('../common'); var assert = require('assert'); var child_process = require('child_process'); var ChildProcess = child_process.ChildProcess; -assert.equal(typeof ChildProcess, 'function'); +assert.strictEqual(typeof ChildProcess, 'function'); // test that we can call spawn var child = new ChildProcess(); @@ -15,11 +15,11 @@ child.spawn({ stdio: 'pipe' }); -assert.equal(child.hasOwnProperty('pid'), true); +assert.strictEqual(child.hasOwnProperty('pid'), true); // try killing with invalid signal assert.throws(function() { child.kill('foo'); }, /Unknown signal: foo/); -assert.equal(child.kill(), true); +assert.strictEqual(child.kill(), true); From 318a2dbea44296eccbf0dd7fb661238a8fec59a8 Mon Sep 17 00:00:00 2001 From: Exlipse7 Date: Thu, 1 Dec 2016 18:20:35 +0000 Subject: [PATCH 126/195] test: refactor test-cli-syntax Switch assert.equal to assert.strictEqual. PR-URL: https://github.com/nodejs/node/pull/10057 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig --- test/parallel/test-cli-syntax.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js index 7718c42f31fa25..839e50d7d94b40 100644 --- a/test/parallel/test-cli-syntax.js +++ b/test/parallel/test-cli-syntax.js @@ -29,9 +29,9 @@ var syntaxArgs = [ var c = spawnSync(node, _args, {encoding: 'utf8'}); // no output should be produced - assert.equal(c.stdout, '', 'stdout produced'); - assert.equal(c.stderr, '', 'stderr produced'); - assert.equal(c.status, 0, 'code == ' + c.status); + assert.strictEqual(c.stdout, '', 'stdout produced'); + assert.strictEqual(c.stderr, '', 'stderr produced'); + assert.strictEqual(c.status, 0, 'code == ' + c.status); }); }); @@ -50,13 +50,13 @@ var syntaxArgs = [ var c = spawnSync(node, _args, {encoding: 'utf8'}); // no stdout should be produced - assert.equal(c.stdout, '', 'stdout produced'); + assert.strictEqual(c.stdout, '', 'stdout produced'); // stderr should have a syntax error message var match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m); assert(match, 'stderr incorrect'); - assert.equal(c.status, 1, 'code == ' + c.status); + assert.strictEqual(c.status, 1, 'code == ' + c.status); }); }); @@ -73,12 +73,12 @@ var syntaxArgs = [ var c = spawnSync(node, _args, {encoding: 'utf8'}); // no stdout should be produced - assert.equal(c.stdout, '', 'stdout produced'); + assert.strictEqual(c.stdout, '', 'stdout produced'); // stderr should have a module not found error message var match = c.stderr.match(/^Error: Cannot find module/m); assert(match, 'stderr incorrect'); - assert.equal(c.status, 1, 'code == ' + c.status); + assert.strictEqual(c.status, 1, 'code == ' + c.status); }); }); From 6d5ded508e504d90cdd1058fce6f04a4433dd86c Mon Sep 17 00:00:00 2001 From: Johnny Reading Date: Thu, 1 Dec 2016 10:11:46 -0600 Subject: [PATCH 127/195] test: refactor test-domain Use assert.strictEqual() instead of assert.equal(). PR-URL: https://github.com/nodejs/node/pull/9890 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-domain.js | 67 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index 19cd964a28923a..69521108f6e47b 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -31,67 +31,67 @@ d.on('error', function(er) { switch (er_message) { case 'emitted': - assert.equal(er.domain, d); - assert.equal(er.domainEmitter, e); - assert.equal(er.domainThrown, false); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainEmitter, e); + assert.strictEqual(er.domainThrown, false); break; case 'bound': assert.ok(!er.domainEmitter); - assert.equal(er.domain, d); - assert.equal(er.domainBound, fn); - assert.equal(er.domainThrown, false); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainBound, fn); + assert.strictEqual(er.domainThrown, false); break; case 'thrown': assert.ok(!er.domainEmitter); - assert.equal(er.domain, d); - assert.equal(er.domainThrown, true); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainThrown, true); break; case "ENOENT: no such file or directory, open 'this file does not exist'": - assert.equal(er.domain, d); - assert.equal(er.domainThrown, false); - assert.equal(typeof er.domainBound, 'function'); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainThrown, false); + assert.strictEqual(typeof er.domainBound, 'function'); assert.ok(!er.domainEmitter); - assert.equal(er.code, 'ENOENT'); - assert.equal(er_path, 'this file does not exist'); - assert.equal(typeof er.errno, 'number'); + assert.strictEqual(er.code, 'ENOENT'); + assert.strictEqual(er_path, 'this file does not exist'); + assert.strictEqual(typeof er.errno, 'number'); break; case "ENOENT: no such file or directory, open 'stream for nonexistent file'": - assert.equal(typeof er.errno, 'number'); - assert.equal(er.code, 'ENOENT'); - assert.equal(er_path, 'stream for nonexistent file'); - assert.equal(er.domain, d); - assert.equal(er.domainEmitter, fst); + assert.strictEqual(typeof er.errno, 'number'); + assert.strictEqual(er.code, 'ENOENT'); + assert.strictEqual(er_path, 'stream for nonexistent file'); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainEmitter, fst); assert.ok(!er.domainBound); - assert.equal(er.domainThrown, false); + assert.strictEqual(er.domainThrown, false); break; case 'implicit': - assert.equal(er.domainEmitter, implicit); - assert.equal(er.domain, d); - assert.equal(er.domainThrown, false); + assert.strictEqual(er.domainEmitter, implicit); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainThrown, false); assert.ok(!er.domainBound); break; case 'implicit timer': - assert.equal(er.domain, d); - assert.equal(er.domainThrown, true); + assert.strictEqual(er.domain, d); + assert.strictEqual(er.domainThrown, true); assert.ok(!er.domainEmitter); assert.ok(!er.domainBound); break; case 'Cannot read property \'isDirectory\' of undefined': - assert.equal(er.domain, d); + assert.strictEqual(er.domain, d); assert.ok(!er.domainEmitter); assert.ok(!er.domainBound); break; case 'nextTick execution loop': - assert.equal(er.domain, d); + assert.strictEqual(er.domain, d); assert.ok(!er.domainEmitter); assert.ok(!er.domainBound); break; @@ -107,7 +107,8 @@ d.on('error', function(er) { process.on('exit', function() { console.error('exit', caught, expectCaught); - assert.equal(caught, expectCaught, 'caught the expected number of errors'); + assert.strictEqual(caught, expectCaught, + 'caught the expected number of errors'); console.log('ok'); }); @@ -172,7 +173,7 @@ expectCaught++; // intercepted should never pass first argument to callback function fn2(data) { - assert.equal(data, 'data', 'should not be null err argument'); + assert.strictEqual(data, 'data', 'should not be null err argument'); } bound = d.intercept(fn2); @@ -181,8 +182,8 @@ bound(null, 'data'); // intercepted should never pass first argument to callback // even if arguments length is more than 2. function fn3(data, data2) { - assert.equal(data, 'data', 'should not be null err argument'); - assert.equal(data2, 'data2', 'should not be data argument'); + assert.strictEqual(data, 'data', 'should not be null err argument'); + assert.strictEqual(data2, 'data2', 'should not be data argument'); } bound = d.intercept(fn3); @@ -225,14 +226,14 @@ expectCaught++; var result = d.run(function() { return 'return value'; }); -assert.equal(result, 'return value'); +assert.strictEqual(result, 'return value'); // check if the executed function take in count the applied parameters result = d.run(function(a, b) { return a + ' ' + b; }, 'return', 'value'); -assert.equal(result, 'return value'); +assert.strictEqual(result, 'return value'); var fst = fs.createReadStream('stream for nonexistent file'); From 278772a5df114b09acb614813cbef24913732cbc Mon Sep 17 00:00:00 2001 From: Konstantin Likhter Date: Thu, 1 Dec 2016 08:05:59 -0800 Subject: [PATCH 128/195] test: refactor dgram-send-multi-buffer-copy assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9909 Reviewed-By: Colin Ihrig --- test/parallel/test-dgram-send-multi-buffer-copy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-dgram-send-multi-buffer-copy.js b/test/parallel/test-dgram-send-multi-buffer-copy.js index 0b7f003335b545..2ee87494b02836 100644 --- a/test/parallel/test-dgram-send-multi-buffer-copy.js +++ b/test/parallel/test-dgram-send-multi-buffer-copy.js @@ -7,7 +7,7 @@ const dgram = require('dgram'); const client = dgram.createSocket('udp4'); const onMessage = common.mustCall(function(err, bytes) { - assert.equal(bytes, buf1.length + buf2.length); + assert.strictEqual(bytes, buf1.length + buf2.length); }); const buf1 = Buffer.alloc(256, 'x'); From bca587bdb38ae2191d117dc8f59ded24bb09064a Mon Sep 17 00:00:00 2001 From: Josh Mays Date: Thu, 1 Dec 2016 10:09:05 -0600 Subject: [PATCH 129/195] test: refactor test-crypto-certificate assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9911 Reviewed-By: Prince John Wesley Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-crypto-certificate.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index 66a5da04073825..1dfb2c73b0eca5 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/test/parallel/test-crypto-certificate.js @@ -19,20 +19,20 @@ var spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem'); var certificate = new crypto.Certificate(); -assert.equal(certificate.verifySpkac(spkacValid), true); -assert.equal(certificate.verifySpkac(spkacFail), false); +assert.strictEqual(certificate.verifySpkac(spkacValid), true); +assert.strictEqual(certificate.verifySpkac(spkacFail), false); -assert.equal( +assert.strictEqual( stripLineEndings(certificate.exportPublicKey(spkacValid).toString('utf8')), stripLineEndings(spkacPem.toString('utf8')) ); -assert.equal(certificate.exportPublicKey(spkacFail), ''); +assert.strictEqual(certificate.exportPublicKey(spkacFail), ''); -assert.equal( +assert.strictEqual( certificate.exportChallenge(spkacValid).toString('utf8'), 'fb9ab814-6677-42a4-a60c-f905d1a6924d' ); -assert.equal(certificate.exportChallenge(spkacFail), ''); +assert.strictEqual(certificate.exportChallenge(spkacFail), ''); function stripLineEndings(obj) { return obj.replace(/\n/g, ''); From a801ffb1ee53ff40d173eee22f8622c1c1f685d0 Mon Sep 17 00:00:00 2001 From: Matt Crummey Date: Thu, 1 Dec 2016 15:43:15 +0000 Subject: [PATCH 130/195] test: refactor test-console assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9873 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-console.js | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index 2c8a498a331b55..ee7170bd9101ac 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -5,8 +5,8 @@ const assert = require('assert'); assert.ok(process.stdout.writable); assert.ok(process.stderr.writable); // Support legacy API -assert.equal('number', typeof process.stdout.fd); -assert.equal('number', typeof process.stderr.fd); +assert.strictEqual('number', typeof process.stdout.fd); +assert.strictEqual('number', typeof process.stderr.fd); assert.doesNotThrow(function() { process.once('warning', common.mustCall((warning) => { @@ -35,28 +35,28 @@ global.process.stderr.write = function(string) { errStrings.push(string); }; -// test console.log() +// test console.log() goes to stdout console.log('foo'); console.log('foo', 'bar'); console.log('%s %s', 'foo', 'bar', 'hop'); console.log({slashes: '\\\\'}); console.log(custom_inspect); -// test console.info() +// test console.info() goes to stdout console.info('foo'); console.info('foo', 'bar'); console.info('%s %s', 'foo', 'bar', 'hop'); console.info({slashes: '\\\\'}); console.info(custom_inspect); -// test console.error() +// test console.error() goes to stderr console.error('foo'); console.error('foo', 'bar'); console.error('%s %s', 'foo', 'bar', 'hop'); console.error({slashes: '\\\\'}); console.error(custom_inspect); -// test console.warn() +// test console.warn() goes to stderr console.warn('foo'); console.warn('foo', 'bar'); console.warn('%s %s', 'foo', 'bar', 'hop'); @@ -102,29 +102,31 @@ const expectedStrings = [ ]; for (const expected of expectedStrings) { - assert.equal(expected + '\n', strings.shift()); // console.log (stdout) - assert.equal(expected + '\n', errStrings.shift()); // console.error (stderr) + assert.strictEqual(expected + '\n', strings.shift()); + assert.strictEqual(expected + '\n', errStrings.shift()); } for (const expected of expectedStrings) { - assert.equal(expected + '\n', strings.shift()); // console.info (stdout) - assert.equal(expected + '\n', errStrings.shift()); // console.warn (stderr) + assert.strictEqual(expected + '\n', strings.shift()); + assert.strictEqual(expected + '\n', errStrings.shift()); } -assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); -assert.equal("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); +assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", + strings.shift()); +assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", + strings.shift()); assert.notEqual(-1, strings.shift().indexOf('foo: [Object]')); -assert.equal(-1, strings.shift().indexOf('baz')); +assert.strictEqual(-1, strings.shift().indexOf('baz')); assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim())); -assert.equal('Trace: This is a {"formatted":"trace"} 10 foo', - errStrings.shift().split('\n').shift()); +assert.strictEqual('Trace: This is a {"formatted":"trace"} 10 foo', + errStrings.shift().split('\n').shift()); -assert.equal(strings.length, 0); -assert.equal(errStrings.length, 0); +assert.strictEqual(strings.length, 0); +assert.strictEqual(errStrings.length, 0); assert.throws(() => { console.assert(false, 'should throw'); From 6502427761801ef34d77a67aa0efd899f9c58488 Mon Sep 17 00:00:00 2001 From: Oscar Martinez Date: Thu, 1 Dec 2016 10:01:11 -0600 Subject: [PATCH 131/195] test: refactor test-require-exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated regex for error assertion. PR-URL: https://github.com/nodejs/node/pull/9882 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-require-exceptions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-require-exceptions.js b/test/parallel/test-require-exceptions.js index 0e61ad2f3fd703..e6b7977b48770b 100644 --- a/test/parallel/test-require-exceptions.js +++ b/test/parallel/test-require-exceptions.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // A module with an error in it should throw assert.throws(function() { require(common.fixturesDir + '/throws_error'); -}); +}, /^Error: blah$/); // Requiring the same module again should throw as well assert.throws(function() { require(common.fixturesDir + '/throws_error'); -}); +}, /^Error: blah$/); // Requiring a module that does not exist should throw an // error with its `code` set to MODULE_NOT_FOUND From f900753eeb4c507fce04836b5a0c9a67429ad363 Mon Sep 17 00:00:00 2001 From: michael6 Date: Thu, 1 Dec 2016 11:18:33 -0600 Subject: [PATCH 132/195] test: refactor test-crypto-ecb * var -> const/let * IIFE to blocks PR-URL: https://github.com/nodejs/node/pull/10029 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- test/parallel/test-crypto-ecb.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-crypto-ecb.js b/test/parallel/test-crypto-ecb.js index d423a386b30a19..655246d0586cbf 100644 --- a/test/parallel/test-crypto-ecb.js +++ b/test/parallel/test-crypto-ecb.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); @@ -10,24 +10,25 @@ if (common.hasFipsCrypto) { common.skip('BF-ECB is not FIPS 140-2 compatible'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; // Testing whether EVP_CipherInit_ex is functioning correctly. // Reference: bug#1997 -(function() { - var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); - var hex = encrypt.update('Hello World!', 'ascii', 'hex'); +{ + const encrypt = + crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); + let hex = encrypt.update('Hello World!', 'ascii', 'hex'); hex += encrypt.final('hex'); assert.strictEqual(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71'); -}()); +} -(function() { - var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', - ''); - var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii'); +{ + const decrypt = + crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', ''); + let msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii'); msg += decrypt.final('ascii'); assert.strictEqual(msg, 'Hello World!'); -}()); +} From 346204d77e36520c58b5d5d422228b9ecb7b1660 Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Sat, 3 Dec 2016 22:43:44 -0800 Subject: [PATCH 133/195] doc: add link to `net.Server` in tls.md PR-URL: https://github.com/nodejs/node/pull/10109 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Roman Reiss --- doc/api/tls.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/tls.md b/doc/api/tls.md index 9ef2c90ad40939..488337a0764e4c 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -402,7 +402,7 @@ connections on the specified `port` and `hostname`. This function operates asynchronously. If the `callback` is given, it will be called when the server has started listening. -See `net.Server` for more information. +See [`net.Server`][] for more information. ### server.setTicketKeys(keys) `const`/`let` * `assert.equal` --> `assert.strictEqual` * `assert.ok(a === b)` --> `assert.strictEqual(a, b)` PR-URL: https://github.com/nodejs/node/pull/10014 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-by: Michael Dawson --- test/parallel/test-tls-peer-certificate.js | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index 59d1a4fdbccc9e..ddbbf72a6309e7 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -1,32 +1,32 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var util = require('util'); -var join = require('path').join; +const fs = require('fs'); +const util = require('util'); +const join = require('path').join; -var options = { +const options = { key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-key.pem')), cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-cert.pem')), ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca1-cert.pem')) ] }; -var server = tls.createServer(options, function(cleartext) { +const server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); server.listen(0, common.mustCall(function() { - var socket = tls.connect({ + const socket = tls.connect({ port: this.address().port, rejectUnauthorized: false }, common.mustCall(function() { - var peerCert = socket.getPeerCertificate(); + let peerCert = socket.getPeerCertificate(); assert.ok(!peerCert.issuerCertificate); // Verify that detailed return value has all certs @@ -34,17 +34,19 @@ server.listen(0, common.mustCall(function() { assert.ok(peerCert.issuerCertificate); console.error(util.inspect(peerCert)); - assert.equal(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); - assert.equal(peerCert.serialNumber, '9A84ABCFB8A72AC0'); - assert.equal(peerCert.exponent, '0x10001'); - assert.equal(peerCert.fingerprint, - '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA'); + assert.strictEqual(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); + assert.strictEqual(peerCert.serialNumber, '9A84ABCFB8A72AC0'); + assert.strictEqual(peerCert.exponent, '0x10001'); + assert.strictEqual( + peerCert.fingerprint, + '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA' + ); assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'], [ 'http://ocsp.nodejs.org/' ]); - var issuer = peerCert.issuerCertificate; - assert.ok(issuer.issuerCertificate === issuer); - assert.equal(issuer.serialNumber, '8DF21C01468AF393'); + const issuer = peerCert.issuerCertificate; + assert.strictEqual(issuer.issuerCertificate, issuer); + assert.strictEqual(issuer.serialNumber, '8DF21C01468AF393'); server.close(); })); socket.end('Hello'); From 51b77aa44afd39ab575c61e78de3c746c074f5a7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 4 Nov 2016 21:46:39 +0100 Subject: [PATCH 163/195] doc: add people to cc for async_wrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a group of people to the “Who to CC in issues” list as the maintainers of `async_hooks`. Ref: https://github.com/nodejs/node/pull/9467#issuecomment-258541560 PR-URL: https://github.com/nodejs/node/pull/9471 Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sam Roberts Reviewed-By: Stephen Belanger Reviewed-By: Josh Gavant --- doc/onboarding-extras.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index 476e0046138279..7b7f60fd00705b 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -24,6 +24,7 @@ | `src/node_crypto.*` | @nodejs/crypto | | `test/*` | @nodejs/testing | | `tools/eslint`, `.eslintrc` | @silverwind, @trott | +| async_hooks | @nodejs/diagnostics | | upgrading V8 | @nodejs/v8, @nodejs/post-mortem | | upgrading npm | @fishrock123, @thealphanerd | | upgrading c-ares | @jbergstroem | From b9bd9a2fcbdf4b0ddc5384f28eedb201b9c159bd Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 30 Nov 2016 17:18:48 -0600 Subject: [PATCH 164/195] doc: remove Sam Roberts from release team MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, remove my key, since I never did a release. PR-URL: https://github.com/nodejs/node/pull/9862 Reviewed-By: Colin Ihrig Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Evan Lucas Reviewed-By: Anna Henningsen Reviewed-By: Myles Borins Reviewed-By: Jeremiah Senkpiel Reviewed-By: Johan Bergström --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index e21f07a25afd17..68ffbb90598d0f 100644 --- a/README.md +++ b/README.md @@ -358,15 +358,12 @@ Releases of Node.js and io.js will be signed with one of the following GPG keys: `C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8` * **Rod Vagg** <rod@vagg.org> `DD8F2338BAE7501E3DD5AC78C273792F7D83545D` -* **Sam Roberts** <octetcloud@keybase.io> -`0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93` The full set of trusted release keys can be imported by running: ```shell gpg --keyserver pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 -gpg --keyserver pool.sks-keyservers.net --recv-keys 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273792F7D83545D From 446bcbea4eb08a67418e1623daa4a96c5dbe73e5 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 2 Dec 2016 16:42:19 -0600 Subject: [PATCH 165/195] doc: correct it's vs. its usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a few instances where `it's` was being used where the possessive `its` was called for. Some additional minor copy-editing of nearby text (adding a comma and fixing a comma splice) was also performed. PR-URL: https://github.com/nodejs/node/pull/10098 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- doc/api/crypto.md | 4 ++-- doc/api/process.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 17d5a5c0faf2c7..ef9db7ffc65420 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -232,7 +232,7 @@ added: v0.1.94 --> Updates the cipher with `data`. If the `input_encoding` argument is given, -it's value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` +its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` argument is a string using the specified encoding. If the `input_encoding` argument is not given, `data` must be a [`Buffer`][]. If `data` is a [`Buffer`][] then `input_encoding` is ignored. @@ -371,7 +371,7 @@ added: v0.1.94 --> Updates the decipher with `data`. If the `input_encoding` argument is given, -it's value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` +its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` argument is a string using the specified encoding. If the `input_encoding` argument is not given, `data` must be a [`Buffer`][]. If `data` is a [`Buffer`][] then `input_encoding` is ignored. diff --git a/doc/api/process.md b/doc/api/process.md index 18c23dda2de193..23759a5674cef6 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -869,7 +869,7 @@ pending* that have not yet completed fully, *including* I/O operations to `process.stdout` and `process.stderr`. In most situations, it is not actually necessary to call `process.exit()` -explicitly. The Node.js process will exit on it's own *if there is no additional +explicitly. The Node.js process will exit on its own *if there is no additional work pending* in the event loop. The `process.exitCode` property can be set to tell the process which exit code to use when the process exits gracefully. @@ -1120,7 +1120,7 @@ added: v0.1.17 The `process.mainModule` property provides an alternative way of retrieving [`require.main`][]. The difference is that if the main module changes at runtime, [`require.main`][] may still refer to the original main module in -modules that were required before the change occurred. Generally it's +modules that were required before the change occurred. Generally, it's safe to assume that the two refer to the same module. As with [`require.main`][], `process.mainModule` will be `undefined` if there @@ -1173,7 +1173,7 @@ The `process.nextTick()` method adds the `callback` to the "next tick queue". Once the current turn of the event loop turn runs to completion, all callbacks currently in the next tick queue will be called. -This is *not* a simple alias to [`setTimeout(fn, 0)`][], it's much more +This is *not* a simple alias to [`setTimeout(fn, 0)`][]. It is much more efficient. It runs before any additional I/O events (including timers) fire in subsequent ticks of the event loop. From bb677d41ce992c4139d2bb95137cc67fc15d3a7f Mon Sep 17 00:00:00 2001 From: J Scott Chapman Date: Thu, 1 Dec 2016 10:17:46 -0600 Subject: [PATCH 166/195] test: strictEqual() and RegExp in test-buffer-fill.js Used assert.strictEqual() instead of assert.equal() Passed a RegExp to assert.throws() Broke lines to satisfy linting PR-URL: https://github.com/nodejs/node/pull/9895 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-buffer-fill.js | 48 ++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-buffer-fill.js b/test/parallel/test-buffer-fill.js index c61ad59d7e9cfe..4272d686940cc7 100644 --- a/test/parallel/test-buffer-fill.js +++ b/test/parallel/test-buffer-fill.js @@ -49,7 +49,7 @@ testBufs('\u0222aa', 8, 1, 'utf8'); testBufs('a\u0234b\u0235c\u0236', 4, -1, 'utf8'); testBufs('a\u0234b\u0235c\u0236', 4, 1, 'utf8'); testBufs('a\u0234b\u0235c\u0236', 12, 1, 'utf8'); -assert.equal(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8); +assert.strictEqual(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8); // BINARY @@ -112,8 +112,8 @@ testBufs('\u0222aa', 8, 1, 'ucs2'); testBufs('a\u0234b\u0235c\u0236', 4, -1, 'ucs2'); testBufs('a\u0234b\u0235c\u0236', 4, 1, 'ucs2'); testBufs('a\u0234b\u0235c\u0236', 12, 1, 'ucs2'); -assert.equal(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0], - os.endianness() === 'LE' ? 0x22 : 0x02); +assert.strictEqual(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0], + os.endianness() === 'LE' ? 0x22 : 0x02); // HEX @@ -137,7 +137,8 @@ testBufs('61c8b462c8b563c8b6', 4, 1, 'hex'); testBufs('61c8b462c8b563c8b6', 12, 1, 'hex'); // Make sure this operation doesn't go on forever buf1.fill('yKJh', 'hex'); -assert.throws(() => buf1.fill('\u0222', 'hex')); +assert.throws(() => + buf1.fill('\u0222', 'hex'), /^TypeError: Invalid hex string$/); // BASE64 @@ -183,14 +184,25 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]); // Check exceptions -assert.throws(() => buf1.fill(0, -1)); -assert.throws(() => buf1.fill(0, 0, buf1.length + 1)); -assert.throws(() => buf1.fill('', -1)); -assert.throws(() => buf1.fill('', 0, buf1.length + 1)); -assert.throws(() => buf1.fill('a', 0, buf1.length, 'node rocks!')); -assert.throws(() => buf1.fill('a', 0, 0, NaN)); -assert.throws(() => buf1.fill('a', 0, 0, null)); -assert.throws(() => buf1.fill('a', 0, 0, 'foo')); +assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/); +assert.throws(() => + buf1.fill(0, 0, buf1.length + 1), + /^RangeError: Out of range index$/); +assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/); +assert.throws(() => + buf1.fill('', 0, buf1.length + 1), + /^RangeError: Out of range index$/); +assert.throws(() => + buf1.fill('a', 0, buf1.length, 'node rocks!'), + /^TypeError: Unknown encoding: node rocks!$/); +assert.throws(() => + buf1.fill('a', 0, 0, NaN), + /^TypeError: encoding must be a string$/); +assert.throws(() => + buf1.fill('a', 0, 0, null), + /^TypeError: encoding must be a string$/); +assert.throws(() => + buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/); function genBuffer(size, args) { @@ -269,8 +281,12 @@ function testBufs(string, offset, length, encoding) { } // Make sure these throw. -assert.throws(() => Buffer.allocUnsafe(8).fill('a', -1)); -assert.throws(() => Buffer.allocUnsafe(8).fill('a', 0, 9)); +assert.throws(() => + Buffer.allocUnsafe(8).fill('a', -1), + /^RangeError: Out of range index$/); +assert.throws(() => + Buffer.allocUnsafe(8).fill('a', 0, 9), + /^RangeError: Out of range index$/); // Make sure this doesn't hang indefinitely. Buffer.allocUnsafe(8).fill(''); @@ -369,7 +385,7 @@ assert.throws(() => { } }; Buffer.alloc(1).fill(Buffer.alloc(1), 0, end); - }); + }, /^RangeError: out of range index$/); // Make sure -1 is making it to Buffer::Fill(). assert.ok(elseWasLast, 'internal API changed, -1 no longer in correct location'); @@ -389,4 +405,4 @@ assert.throws(() => { enumerable: true }); buf.fill(''); -}); +}, /^RangeError: out of range index$/); From 7c902446772663619e5463c81e9e8255292bd4de Mon Sep 17 00:00:00 2001 From: Erez Weiss Date: Sat, 3 Dec 2016 20:32:28 +0200 Subject: [PATCH 167/195] test: implemented es6 conventions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit implemented arrow functions and changed var to const where appropriate. PR-URL: https://github.com/nodejs/node/pull/9669 Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-fs-read-stream-err.js | 41 ++++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-fs-read-stream-err.js b/test/parallel/test-fs-read-stream-err.js index 1bc2b6f0b0239c..32e9b02455e20a 100644 --- a/test/parallel/test-fs-read-stream-err.js +++ b/test/parallel/test-fs-read-stream-err.js @@ -1,43 +1,42 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); -var stream = fs.createReadStream(__filename, { +const stream = fs.createReadStream(__filename, { bufferSize: 64 }); -var err = new Error('BAM'); +const err = new Error('BAM'); -stream.on('error', common.mustCall(function errorHandler(err_) { - console.error('error event'); - process.nextTick(function() { - assert.equal(stream.fd, null); - assert.equal(err_, err); - }); +stream.on('error', common.mustCall((err_) => { + process.nextTick(common.mustCall(() => { + assert.strictEqual(stream.fd, null); + assert.strictEqual(err_, err); + })); })); -fs.close = common.mustCall(function(fd_, cb) { - assert.equal(fd_, stream.fd); +fs.close = common.mustCall((fd_, cb) => { + assert.strictEqual(fd_, stream.fd); process.nextTick(cb); }); -var read = fs.read; +const read = fs.read; fs.read = function() { // first time is ok. read.apply(fs, arguments); // then it breaks - fs.read = function() { - var cb = arguments[arguments.length - 1]; - process.nextTick(function() { + fs.read = common.mustCall(function() { + const cb = arguments[arguments.length - 1]; + process.nextTick(() => { cb(err); }); // and should not be called again! - fs.read = function() { + fs.read = () => { throw new Error('BOOM!'); }; - }; + }); }; -stream.on('data', function(buf) { - stream.on('data', common.fail); // no more 'data' events should follow +stream.on('data', (buf) => { + stream.on('data', () => common.fail("no more 'data' events should follow")); }); From cbdc64e026d2ec62caa798432403bf04d252b1a6 Mon Sep 17 00:00:00 2001 From: Richard Karmazin Date: Thu, 1 Dec 2016 11:19:28 -0600 Subject: [PATCH 168/195] test: test-file-write-stream3.js refactor PR-URL: https://github.com/nodejs/node/pull/10035 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/parallel/test-file-write-stream3.js | 36 +++++++++++------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-file-write-stream3.js b/test/parallel/test-file-write-stream3.js index 1243460f9f314f..961f51ba82be7a 100644 --- a/test/parallel/test-file-write-stream3.js +++ b/test/parallel/test-file-write-stream3.js @@ -9,7 +9,7 @@ const filepath = path.join(common.tmpDir, 'write_pos.txt'); const cb_expected = 'write open close write open close write open close '; -var cb_occurred = ''; +let cb_occurred = ''; const fileDataInitial = 'abcdefghijklmnopqrstuvwxyz'; @@ -34,10 +34,8 @@ common.refreshTmpDir(); function run_test_1() { - var file, buffer, options; - - options = {}; - file = fs.createWriteStream(filepath, options); + const options = {}; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -51,10 +49,10 @@ function run_test_1() { console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); assert.strictEqual(file.bytesWritten, buffer.length); - var fileData = fs.readFileSync(filepath, 'utf8'); + const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_1); - assert.equal(fileData, fileDataExpected_1); + assert.strictEqual(fileData, fileDataExpected_1); run_test_2(); }); @@ -65,7 +63,7 @@ function run_test_1() { throw err; }); - buffer = Buffer.from(fileDataInitial); + const buffer = Buffer.from(fileDataInitial); file.write(buffer); cb_occurred += 'write '; @@ -74,13 +72,12 @@ function run_test_1() { function run_test_2() { - var file, buffer, options; - buffer = Buffer.from('123456'); + const buffer = Buffer.from('123456'); - options = { start: 10, - flags: 'r+' }; - file = fs.createWriteStream(filepath, options); + const options = { start: 10, + flags: 'r+' }; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -94,10 +91,10 @@ function run_test_2() { console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); assert.strictEqual(file.bytesWritten, buffer.length); - var fileData = fs.readFileSync(filepath, 'utf8'); + const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_2); - assert.equal(fileData, fileDataExpected_2); + assert.strictEqual(fileData, fileDataExpected_2); run_test_3(); }); @@ -116,13 +113,12 @@ function run_test_2() { function run_test_3() { - var file, options; const data = '\u2026\u2026'; // 3 bytes * 2 = 6 bytes in UTF-8 - options = { start: 10, - flags: 'r+' }; - file = fs.createWriteStream(filepath, options); + const options = { start: 10, + flags: 'r+' }; + const file = fs.createWriteStream(filepath, options); console.log(' (debug: start ', file.start); console.log(' (debug: pos ', file.pos); @@ -139,7 +135,7 @@ function run_test_3() { const fileData = fs.readFileSync(filepath, 'utf8'); console.log(' (debug: file data ', fileData); console.log(' (debug: expected ', fileDataExpected_3); - assert.equal(fileData, fileDataExpected_3); + assert.strictEqual(fileData, fileDataExpected_3); run_test_4(); }); From 328cd93036ef97419932cd864c0afb5ddf7602c4 Mon Sep 17 00:00:00 2001 From: Scott Smereka Date: Thu, 1 Dec 2016 10:32:32 -0600 Subject: [PATCH 169/195] test: changed assert.equal to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9936 Reviewed-By: Teddy Katz Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-exception-handler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-exception-handler.js b/test/parallel/test-exception-handler.js index d163fb18916faa..e0e1b0086d9a7f 100644 --- a/test/parallel/test-exception-handler.js +++ b/test/parallel/test-exception-handler.js @@ -6,12 +6,12 @@ var MESSAGE = 'catch me if you can'; process.on('uncaughtException', common.mustCall(function(e) { console.log('uncaught exception! 1'); - assert.equal(MESSAGE, e.message); + assert.strictEqual(MESSAGE, e.message); })); process.on('uncaughtException', common.mustCall(function(e) { console.log('uncaught exception! 2'); - assert.equal(MESSAGE, e.message); + assert.strictEqual(MESSAGE, e.message); })); setTimeout(function() { From 8e27254594988f35e502272f75465b1294043278 Mon Sep 17 00:00:00 2001 From: Jonathan Darling Date: Thu, 1 Dec 2016 10:28:44 -0600 Subject: [PATCH 170/195] test: convert assert.equal to assert.strictEqual converts an instance of assert.equal in a file already mostly updated to use assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9925 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-buffer-slow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js index cecc01a95923c3..7d27a9be111569 100644 --- a/test/parallel/test-buffer-slow.js +++ b/test/parallel/test-buffer-slow.js @@ -35,7 +35,7 @@ try { assert.strictEqual( SlowBuffer(buffer.kMaxLength).length, buffer.kMaxLength); } catch (e) { - assert.equal(e.message, 'Array buffer allocation failed'); + assert.strictEqual(e.message, 'Array buffer allocation failed'); } // should work with number-coercible values From 2e36b2ef496affe82a6756e265f3ba773ea00248 Mon Sep 17 00:00:00 2001 From: Fabrice Tatieze Date: Thu, 1 Dec 2016 10:21:41 -0600 Subject: [PATCH 171/195] test: using const and strictEqual PR-URL: https://github.com/nodejs/node/pull/9926 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-console-instance.js | 10 +++++----- test/parallel/test-dgram-msgsize.js | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index b8d9880865530b..4d2727d96b1a55 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -15,7 +15,7 @@ process.stdout.write = process.stderr.write = function() { }; // make sure that the "Console" function exists -assert.equal('function', typeof Console); +assert.strictEqual('function', typeof Console); // make sure that the Console constructor throws // when not given a writable stream instance @@ -35,7 +35,7 @@ out.write = err.write = function(d) {}; var c = new Console(out, err); out.write = err.write = function(d) { - assert.equal(d, 'test\n'); + assert.strictEqual(d, 'test\n'); called = true; }; @@ -48,7 +48,7 @@ c.error('test'); assert(called); out.write = function(d) { - assert.equal('{ foo: 1 }\n', d); + assert.strictEqual('{ foo: 1 }\n', d); called = true; }; @@ -60,10 +60,10 @@ assert(called); called = 0; out.write = function(d) { called++; - assert.equal(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n'); + assert.strictEqual(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n'); }; [1, 2, 3].forEach(c.log); -assert.equal(3, called); +assert.strictEqual(3, called); // Console() detects if it is called without `new` keyword assert.doesNotThrow(function() { diff --git a/test/parallel/test-dgram-msgsize.js b/test/parallel/test-dgram-msgsize.js index ec4021b99fd899..6cc415e83c00ca 100644 --- a/test/parallel/test-dgram-msgsize.js +++ b/test/parallel/test-dgram-msgsize.js @@ -1,18 +1,18 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); // Send a too big datagram. The destination doesn't matter because it's // not supposed to get sent out anyway. -var buf = Buffer.allocUnsafe(256 * 1024); -var sock = dgram.createSocket('udp4'); +const buf = Buffer.allocUnsafe(256 * 1024); +const sock = dgram.createSocket('udp4'); sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb)); function cb(err) { assert(err instanceof Error); - assert.equal(err.code, 'EMSGSIZE'); - assert.equal(err.address, '127.0.0.1'); - assert.equal(err.port, 12345); - assert.equal(err.message, 'send EMSGSIZE 127.0.0.1:12345'); + assert.strictEqual(err.code, 'EMSGSIZE'); + assert.strictEqual(err.address, '127.0.0.1'); + assert.strictEqual(err.port, 12345); + assert.strictEqual(err.message, 'send EMSGSIZE 127.0.0.1:12345'); sock.close(); } From c0eb08adbe4c2878e30bcc40c5ac920661c5a08f Mon Sep 17 00:00:00 2001 From: Uttam Pawar Date: Thu, 1 Dec 2016 08:19:10 -0800 Subject: [PATCH 172/195] test: use strictEqual instead of equal PR-URL: https://github.com/nodejs/node/pull/9921 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-debugger-util-regression.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-debugger-util-regression.js b/test/parallel/test-debugger-util-regression.js index 6378ea3e9b171c..07e52545814b14 100644 --- a/test/parallel/test-debugger-util-regression.js +++ b/test/parallel/test-debugger-util-regression.js @@ -46,8 +46,8 @@ proc.stdout.on('data', (data) => { proc.stderr.on('data', (data) => stderr += data); process.on('exit', (code) => { - assert.equal(code, 0, 'the program should exit cleanly'); - assert.equal(stdout.includes('{ a: \'b\' }'), true, - 'the debugger should print the result of util.inspect'); - assert.equal(stderr, '', 'stderr should be empty'); + assert.strictEqual(code, 0, 'the program should exit cleanly'); + assert.strictEqual(stdout.includes('{ a: \'b\' }'), true, + 'the debugger should print the result of util.inspect'); + assert.strictEqual(stderr, '', 'stderr should be empty'); }); From f68bfc5bde09423d746799083cd93d11308683d9 Mon Sep 17 00:00:00 2001 From: Tracy Hinds Date: Thu, 1 Dec 2016 11:24:13 -0600 Subject: [PATCH 173/195] test: replace equal with strictEqual PR-URL: https://github.com/nodejs/node/pull/10011 Reviewed-By: Roman Reiss Reviewed-By: Myles Borins Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-domain-abort-on-uncaught.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js index 2a5eb804bc34ec..d61debc06067f6 100644 --- a/test/parallel/test-domain-abort-on-uncaught.js +++ b/test/parallel/test-domain-abort-on-uncaught.js @@ -227,7 +227,7 @@ if (process.argv[2] === 'child') { tests[testIndex](); process.on('exit', function onExit() { - assert.equal(errorHandlerCalled, true); + assert.strictEqual(errorHandlerCalled, true); }); } else { @@ -248,7 +248,7 @@ if (process.argv[2] === 'child') { var child = child_process.exec(testCmd); child.on('exit', function onExit(code, signal) { - assert.equal(code, 0, 'Test at index ' + testIndex + + assert.strictEqual(code, 0, 'Test at index ' + testIndex + ' should have exited with exit code 0 but instead exited with code ' + code + ' and signal ' + signal); }); From 84813fdaf8078bc9149e2866b1e7e254898cc728 Mon Sep 17 00:00:00 2001 From: Matt Webb Date: Thu, 1 Dec 2016 10:36:05 -0600 Subject: [PATCH 174/195] test: refactor test-fs-read-stream-resume Update vars to const/let & equal to strictEqual. PR-URL: https://github.com/nodejs/node/pull/9927 Reviewed-By: Teddy Katz Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-fs-read-stream-resume.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-fs-read-stream-resume.js b/test/parallel/test-fs-read-stream-resume.js index abac0686c11944..3ff89644e5c018 100644 --- a/test/parallel/test-fs-read-stream-resume.js +++ b/test/parallel/test-fs-read-stream-resume.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var file = path.join(common.fixturesDir, 'x.txt'); -var data = ''; -var first = true; +const file = path.join(common.fixturesDir, 'x.txt'); +let data = ''; +let first = true; var stream = fs.createReadStream(file); stream.setEncoding('utf8'); @@ -27,5 +27,5 @@ process.nextTick(function() { }); process.on('exit', function() { - assert.equal(data, 'xyz\n'); + assert.strictEqual(data, 'xyz\n'); }); From 1877ba33847ef3d50646288cac904f89f54075f0 Mon Sep 17 00:00:00 2001 From: Walter Beller-Morales Date: Thu, 1 Dec 2016 10:34:49 -0600 Subject: [PATCH 175/195] test: refactor test-fs-symlink-dir-junction * var -> const * assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9928 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- test/parallel/test-fs-symlink-dir-junction.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-symlink-dir-junction.js b/test/parallel/test-fs-symlink-dir-junction.js index 1dd3a903034102..58ddb7ca38ae1c 100644 --- a/test/parallel/test-fs-symlink-dir-junction.js +++ b/test/parallel/test-fs-symlink-dir-junction.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); // test creating and reading symbolic link -var linkData = path.join(common.fixturesDir, 'cycles/'); -var linkPath = path.join(common.tmpDir, 'cycles_link'); +const linkData = path.join(common.fixturesDir, 'cycles/'); +const linkPath = path.join(common.tmpDir, 'cycles_link'); common.refreshTmpDir(); @@ -22,7 +22,7 @@ fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) { fs.readlink(linkPath, common.mustCall(function(err, destination) { if (err) throw err; - assert.equal(destination, linkData); + assert.strictEqual(destination, linkData); fs.unlink(linkPath, common.mustCall(function(err) { if (err) throw err; From ba7d1cf4bc87ea23d8c22c5d3dacdcb5ee108fbb Mon Sep 17 00:00:00 2001 From: blugavere Date: Mon, 5 Dec 2016 00:03:15 -0500 Subject: [PATCH 176/195] test: refactor test-require-resolve * var => const * assert.equal() => assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/10120 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-require-resolve.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-require-resolve.js b/test/parallel/test-require-resolve.js index 13897c74da1752..202f3c5ef87f3d 100644 --- a/test/parallel/test-require-resolve.js +++ b/test/parallel/test-require-resolve.js @@ -1,18 +1,18 @@ 'use strict'; -var common = require('../common'); -var fixturesDir = common.fixturesDir; -var assert = require('assert'); -var path = require('path'); +const common = require('../common'); +const fixturesDir = common.fixturesDir; +const assert = require('assert'); +const path = require('path'); -assert.equal( +assert.strictEqual( path.join(__dirname, '../fixtures/a.js').toLowerCase(), require.resolve('../fixtures/a').toLowerCase()); -assert.equal( +assert.strictEqual( path.join(fixturesDir, 'a.js').toLowerCase(), require.resolve(path.join(fixturesDir, 'a')).toLowerCase()); -assert.equal( +assert.strictEqual( path.join(fixturesDir, 'nested-index', 'one', 'index.js').toLowerCase(), require.resolve('../fixtures/nested-index/one').toLowerCase()); -assert.equal('path', require.resolve('path')); +assert.strictEqual('path', require.resolve('path')); console.log('ok'); From 79b36e927cf51cfa28dd19c8a97db546919235a5 Mon Sep 17 00:00:00 2001 From: Punit Buch Date: Thu, 1 Dec 2016 10:16:49 -0600 Subject: [PATCH 177/195] test: update test-net-connect-handle-econnrefused * var -> const * assert.equal() -> assert.strictEqual() * assert.ok(false) -> common.fail() PR-URL: https://github.com/nodejs/node/pull/9932 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- .../test-net-connect-handle-econnrefused.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-connect-handle-econnrefused.js b/test/parallel/test-net-connect-handle-econnrefused.js index bbfb5c1bec1836..09b17ad29deb5e 100644 --- a/test/parallel/test-net-connect-handle-econnrefused.js +++ b/test/parallel/test-net-connect-handle-econnrefused.js @@ -1,18 +1,17 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); -var assert = require('assert'); +const common = require('../common'); +const net = require('net'); +const assert = require('assert'); // Hopefully nothing is running on common.PORT -var c = net.createConnection(common.PORT); +const c = net.createConnection(common.PORT); c.on('connect', function() { - console.error('connected?!'); - assert.ok(false); + common.fail('connected?!'); }); c.on('error', common.mustCall(function(e) { console.error('couldn\'t connect.'); - assert.equal('ECONNREFUSED', e.code); + assert.strictEqual('ECONNREFUSED', e.code); })); From 371a785f6d9ffc952485f4f78a23173d7bfc3e1f Mon Sep 17 00:00:00 2001 From: mark hughes Date: Thu, 1 Dec 2016 10:24:08 -0600 Subject: [PATCH 178/195] test: refactor test-signal-unregister * var -> const * assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/9920 Reviewed-By: Colin Ihrig Reviewed-By: Prince John Wesley Reviewed-By: Luigi Pinca --- test/parallel/test-signal-unregister.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-signal-unregister.js b/test/parallel/test-signal-unregister.js index b65ade73db9422..88c6a367a9cb37 100644 --- a/test/parallel/test-signal-unregister.js +++ b/test/parallel/test-signal-unregister.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']); +const child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']); child.stdout.once('data', function() { child.kill('SIGINT'); }); child.on('exit', common.mustCall(function(exitCode, signalCode) { - assert.equal(exitCode, null); - assert.equal(signalCode, 'SIGINT'); + assert.strictEqual(exitCode, null); + assert.strictEqual(signalCode, 'SIGINT'); })); From 0a07bccc5ce10955008045f4290be5aae505383d Mon Sep 17 00:00:00 2001 From: Russell Sherman Date: Thu, 1 Dec 2016 10:15:03 -0600 Subject: [PATCH 179/195] test: refactor test-tls-connect-simple refactor var -> const/let refactor process.on('exit') into common.mustCall PR-URL: https://github.com/nodejs/node/pull/9934 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-tls-connect-simple.js | 51 +++++++++--------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/test/parallel/test-tls-connect-simple.js b/test/parallel/test-tls-connect-simple.js index 5b18f7693ff7df..a6bcfcab519fdf 100644 --- a/test/parallel/test-tls-connect-simple.js +++ b/test/parallel/test-tls-connect-simple.js @@ -1,58 +1,43 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var clientConnected = 0; -var serverConnected = 0; -var serverCloseCallbacks = 0; -var serverCloseEvents = 0; +let serverConnected = 0; -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.Server(options, function(socket) { +const server = tls.Server(options, common.mustCall(function(socket) { if (++serverConnected === 2) { - server.close(function() { - ++serverCloseCallbacks; - }); - server.on('close', function() { - ++serverCloseEvents; - }); + server.close(common.mustCall(function() {})); + server.on('close', common.mustCall(function() {})); } -}); +}, 2)); server.listen(0, function() { - var client1 = tls.connect({ + const client1options = { port: this.address().port, rejectUnauthorized: false - }, function() { - ++clientConnected; + }; + const client1 = tls.connect(client1options, common.mustCall(function() { client1.end(); - }); + })); - var client2 = tls.connect({ + const client2options = { port: this.address().port, rejectUnauthorized: false - }); - client2.on('secureConnect', function() { - ++clientConnected; + }; + const client2 = tls.connect(client2options); + client2.on('secureConnect', common.mustCall(function() { client2.end(); - }); -}); - -process.on('exit', function() { - assert.equal(clientConnected, 2); - assert.equal(serverConnected, 2); - assert.equal(serverCloseCallbacks, 1); - assert.equal(serverCloseEvents, 1); + })); }); From d697ac404f3b8d880d6c80ac4a5503c7942ece1a Mon Sep 17 00:00:00 2001 From: Nigel Kibodeaux Date: Thu, 1 Dec 2016 10:18:15 -0600 Subject: [PATCH 180/195] test: use assert.strictEqual in test-cli-eval PR-URL: https://github.com/nodejs/node/pull/9919 Reviewed-By: Teddy Katz Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-cli-eval.js | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 3c38afd2ac4524..0198a0f1beda48 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -19,15 +19,15 @@ var filename = __filename.replace(/\\/g, '/'); // assert that nothing is written to stdout child.exec(nodejs + ' --eval 42', function(err, stdout, stderr) { - assert.equal(stdout, ''); - assert.equal(stderr, ''); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); // assert that "42\n" is written to stderr child.exec(nodejs + ' --eval "console.error(42)"', function(err, stdout, stderr) { - assert.equal(stdout, ''); - assert.equal(stderr, '42\n'); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, '42\n'); }); // assert that the expected output is written to stdout @@ -36,21 +36,21 @@ child.exec(nodejs + ' --eval "console.error(42)"', child.exec(cmd + '42', function(err, stdout, stderr) { - assert.equal(stdout, '42\n'); - assert.equal(stderr, ''); + assert.strictEqual(stdout, '42\n'); + assert.strictEqual(stderr, ''); }); child.exec(cmd + "'[]'", common.mustCall( function(err, stdout, stderr) { - assert.equal(stdout, '[]\n'); - assert.equal(stderr, ''); + assert.strictEqual(stdout, '[]\n'); + assert.strictEqual(stderr, ''); })); }); // assert that module loading works child.exec(nodejs + ' --eval "require(\'' + filename + '\')"', function(status, stdout, stderr) { - assert.equal(status.code, 42); + assert.strictEqual(status.code, 42); }); // Check that builtin modules are pre-defined. @@ -63,7 +63,7 @@ child.exec(nodejs + ' --print "os.platform()"', // module path resolve bug, regression test child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"', function(status, stdout, stderr) { - assert.equal(status.code, 42); + assert.strictEqual(status.code, 42); }); // Missing argument should not crash @@ -74,28 +74,29 @@ child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) { // empty program should do nothing child.exec(nodejs + ' -e ""', function(status, stdout, stderr) { - assert.equal(stdout, ''); - assert.equal(stderr, ''); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); // "\\-42" should be interpreted as an escaped expression, not a switch child.exec(nodejs + ' -p "\\-42"', function(err, stdout, stderr) { - assert.equal(stdout, '-42\n'); - assert.equal(stderr, ''); + assert.strictEqual(stdout, '-42\n'); + assert.strictEqual(stderr, ''); }); child.exec(nodejs + ' --use-strict -p process.execArgv', function(status, stdout, stderr) { - assert.equal(stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n"); + assert.strictEqual(stdout, + "[ '--use-strict', '-p', 'process.execArgv' ]\n"); }); // Regression test for https://github.com/nodejs/node/issues/3574 const emptyFile = path.join(common.fixturesDir, 'empty.js'); child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`, function(status, stdout, stderr) { - assert.equal(stdout, ''); - assert.equal(stderr, ''); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); // Regression test for https://github.com/nodejs/node/issues/8534. From 2f731e5b5df6dfd4a0cbfde304d71e2adf137c87 Mon Sep 17 00:00:00 2001 From: hirabhullar Date: Thu, 1 Dec 2016 09:01:51 -0800 Subject: [PATCH 181/195] test: refactor test-child-fork-exec-path.js Changed equal to strictEqual PR-URL: https://github.com/nodejs/node/pull/9982 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-child-process-fork-exec-path.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js index e42b72f2b85886..e2f7e4b4d20eef 100644 --- a/test/parallel/test-child-process-fork-exec-path.js +++ b/test/parallel/test-child-process-fork-exec-path.js @@ -9,7 +9,7 @@ var copyPath = path.join(common.tmpDir, 'node-copy.exe'); if (process.env.FORK) { assert(process.send); - assert.equal(process.argv[0], copyPath); + assert.strictEqual(process.argv[0], copyPath); process.send(msg); process.exit(); } else { @@ -34,6 +34,6 @@ if (process.env.FORK) { })); child.on('exit', common.mustCall(function(code) { fs.unlinkSync(copyPath); - assert.equal(code, 0); + assert.strictEqual(code, 0); })); } From 8936d835c160ae2a3f690af3307bc1d8ac2bc7e5 Mon Sep 17 00:00:00 2001 From: hirabhullar Date: Thu, 1 Dec 2016 09:34:21 -0800 Subject: [PATCH 182/195] test: refactor test-fs-write.js Changed var to const and equal to strictEqual PR-URL: https://github.com/nodejs/node/pull/9982 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-fs-write.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index 766cb0b2cea1d2..9960a91a4f7515 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var Buffer = require('buffer').Buffer; -var fs = require('fs'); -var fn = path.join(common.tmpDir, 'write.txt'); -var fn2 = path.join(common.tmpDir, 'write2.txt'); -var expected = 'ümlaut.'; -var constants = fs.constants; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); +const fn = path.join(common.tmpDir, 'write.txt'); +const fn2 = path.join(common.tmpDir, 'write2.txt'); +const expected = 'ümlaut.'; +const constants = fs.constants; common.refreshTmpDir(); @@ -15,12 +15,12 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { if (err) throw err; console.log('open done'); fs.write(fd, '', 0, 'utf8', function(err, written) { - assert.equal(0, written); + assert.strictEqual(0, written); }); fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) { console.log('write done'); if (err) throw err; - assert.equal(Buffer.byteLength(expected), written); + assert.strictEqual(Buffer.byteLength(expected), written); fs.closeSync(fd); const found = fs.readFileSync(fn, 'utf8'); console.log('expected: "%s"', expected); @@ -36,12 +36,12 @@ fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644, if (err) throw err; console.log('open done'); fs.write(fd, '', 0, 'utf8', (err, written) => { - assert.equal(0, written); + assert.strictEqual(0, written); }); fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => { console.log('write done'); if (err) throw err; - assert.equal(Buffer.byteLength(expected), written); + assert.strictEqual(Buffer.byteLength(expected), written); fs.closeSync(fd); const found = fs.readFileSync(fn2, 'utf8'); console.log('expected: "%s"', expected); From a0f6cc718aed0be42bb8bf0cf4856ba477d8e0ba Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Sat, 3 Dec 2016 03:03:27 -0500 Subject: [PATCH 183/195] repl: avoid parsing division operator as regex This improves the heuristic used in multiline-prompt mode to determine whether a given slash character is at the beginning of a regular expression. PR-URL: https://github.com/nodejs/node/pull/10103 Reviewed-By: Prince John Wesley Reviewed-By: James M Snell Fixes: https://github.com/nodejs/node/issues/9300 --- lib/repl.js | 9 ++++++++- test/parallel/test-repl.js | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index f9b1b7e4a9710f..2bb25e8ca3391b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -93,6 +93,7 @@ class LineParser { this.shouldFail = false; this.blockComment = false; this.regExpLiteral = false; + this.prevTokenChar = null; } parseLine(line) { @@ -132,7 +133,11 @@ class LineParser { if (previous === '/') { if (current === '*') { this.blockComment = true; - } else { + } else if ( + // Distinguish between a division operator and the start of a regex + // by examining the non-whitespace character that precedes the / + [null, '(', '[', '{', '}', ';'].includes(this.prevTokenChar) + ) { this.regExpLiteral = true; } previous = null; @@ -147,6 +152,8 @@ class LineParser { this._literal = this._literal || current; } + if (current.trim() && current !== '/') this.prevTokenChar = current; + previous = current; } diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 4342910d5dac03..70aac915f6b594 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -352,6 +352,16 @@ function error_test() { { client: client_unix, send: 'function * foo() {}; foo().next()', expect: '{ value: undefined, done: true }' }, + + // https://github.com/nodejs/node/issues/9300 + { client: client_unix, send: 'function foo() {\nvar bar = 1 / 1; // "/"\n}', + expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix }, + + { client: client_unix, send: '(function() {\nreturn /foo/ / /bar/;\n}())', + expect: prompt_multiline + prompt_multiline + 'NaN\n' + prompt_unix }, + + { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', + expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix } ]); } From 843b8c1658e5274c3b7bab5cc401f1cae0bee065 Mon Sep 17 00:00:00 2001 From: Wes Tyler Date: Thu, 1 Dec 2016 10:56:14 -0600 Subject: [PATCH 184/195] test: refactor test-domain-multi Replace assert.equal() with assert.strictEqual(). PR-URL: https://github.com/nodejs/node/pull/9963 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- test/parallel/test-domain-multi.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index 1b0af1dd3f438f..cf85dbca460146 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -70,8 +70,8 @@ var server = http.createServer(function(req, res) { }); process.on('exit', function() { - assert.equal(caughtA, false); - assert.equal(caughtB, true); - assert.equal(caughtC, true); + assert.strictEqual(caughtA, false); + assert.strictEqual(caughtB, true); + assert.strictEqual(caughtC, true); console.log('ok - Errors went where they were supposed to go'); }); From f531c96846a57f351a912037f9683a207d1e6d8a Mon Sep 17 00:00:00 2001 From: Paul Chin Date: Thu, 1 Dec 2016 10:59:49 -0600 Subject: [PATCH 185/195] test: changed assert.Equal to asset.strictEqual test-dgram-send-callback-recursive.js PR-URL: https://github.com/nodejs/node/pull/9973 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- test/parallel/test-dgram-send-callback-recursive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-dgram-send-callback-recursive.js b/test/parallel/test-dgram-send-callback-recursive.js index c54b05c3f86ba1..bca888a46785e9 100644 --- a/test/parallel/test-dgram-send-callback-recursive.js +++ b/test/parallel/test-dgram-send-callback-recursive.js @@ -37,7 +37,7 @@ client.on('message', function(buf, info) { }); client.on('close', common.mustCall(function() { - assert.equal(received, limit); + assert.strictEqual(received, limit); })); client.bind(0); From a3a664a321364ecc5be9b6579c2554a7e351b251 Mon Sep 17 00:00:00 2001 From: scalkpdev Date: Thu, 1 Dec 2016 10:42:27 -0600 Subject: [PATCH 186/195] test: update test-stdout-to-file * changed vars to const * changed assert.equal to assert.strictEqual * added a common.mustCall in the childProcess.exec callback * replaced 2 console.log strings with template strings for readability * had to break up line 9 because it was causing a line max length (80) listing err PR-URL: https://github.com/nodejs/node/pull/9939 Reviewed-By: Prince John Wesley Reviewed-By: James M Snell --- test/parallel/test-stdout-to-file.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-stdout-to-file.js b/test/parallel/test-stdout-to-file.js index 5dce369aadb52e..10391c481a826d 100644 --- a/test/parallel/test-stdout-to-file.js +++ b/test/parallel/test-stdout-to-file.js @@ -1,13 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var childProcess = require('child_process'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const childProcess = require('child_process'); +const fs = require('fs'); -var scriptString = path.join(common.fixturesDir, 'print-chars.js'); -var scriptBuffer = path.join(common.fixturesDir, 'print-chars-from-buffer.js'); -var tmpFile = path.join(common.tmpDir, 'stdout.txt'); +const scriptString = path.join(common.fixturesDir, 'print-chars.js'); +const scriptBuffer = path.join(common.fixturesDir, + 'print-chars-from-buffer.js'); +const tmpFile = path.join(common.tmpDir, 'stdout.txt'); common.refreshTmpDir(); @@ -24,22 +25,22 @@ function test(size, useBuffer, cb) { fs.unlinkSync(tmpFile); } catch (e) {} - console.log(size + ' chars to ' + tmpFile + '...'); + console.log(`${size} chars to ${tmpFile}...`); - childProcess.exec(cmd, function(err) { + childProcess.exec(cmd, common.mustCall(function(err) { if (err) throw err; console.log('done!'); var stat = fs.statSync(tmpFile); - console.log(tmpFile + ' has ' + stat.size + ' bytes'); + console.log(`${tmpFile} has ${stat.size} bytes`); - assert.equal(size, stat.size); + assert.strictEqual(size, stat.size); fs.unlinkSync(tmpFile); cb(); - }); + })); } test(1024 * 1024, false, common.mustCall(function() { From 0a4fc64c3f23154fc8a8d28147ee16d168dae01f Mon Sep 17 00:00:00 2001 From: Danny Guo Date: Thu, 1 Dec 2016 10:41:38 -0600 Subject: [PATCH 187/195] test: clean up tls junk test PR-URL: https://github.com/nodejs/node/pull/9940 Reviewed-By: James M Snell --- test/parallel/test-tls-junk-closes-server.js | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-tls-junk-closes-server.js b/test/parallel/test-tls-junk-closes-server.js index f12393515cbe47..38f90498f84e92 100644 --- a/test/parallel/test-tls-junk-closes-server.js +++ b/test/parallel/test-tls-junk-closes-server.js @@ -1,34 +1,30 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); -var net = require('net'); +const tls = require('tls'); +const fs = require('fs'); +const net = require('net'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; -var server = tls.createServer(options, function(s) { - s.write('welcome!\n'); - s.pipe(s); -}); +const server = tls.createServer(options, common.fail); -server.listen(0, function() { - var c = net.createConnection(this.address().port); +server.listen(0, common.mustCall(function() { + const c = net.createConnection(this.address().port); - c.on('connect', function() { + c.on('connect', common.mustCall(function() { c.write('blah\nblah\nblah\n'); - }); + })); - c.on('end', function() { + c.on('end', common.mustCall(function() { server.close(); - }); - -}); + })); +})); From f5e622ea531070ef602cd4c65ba939e39eb9ff42 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Thu, 1 Dec 2016 10:38:53 -0600 Subject: [PATCH 188/195] test: use assert.strictEqual and fix setTimeout Changes assert.equal to assert.strictEqual in two places and adds a second argument of 0 to setTimeout PR-URL: https://github.com/nodejs/node/pull/9957 Reviewed-By: James M Snell --- test/parallel/test-domain-timers.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js index faa57df1277083..d42afa7471791a 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -8,21 +8,22 @@ var timeout; var timeoutd = domain.create(); timeoutd.on('error', common.mustCall(function(e) { - assert.equal(e.message, 'Timeout UNREFd', 'Domain should catch timer error'); + assert.strictEqual(e.message, 'Timeout UNREFd', + 'Domain should catch timer error'); clearTimeout(timeout); })); timeoutd.run(function() { setTimeout(function() { throw new Error('Timeout UNREFd'); - }).unref(); + }, 0).unref(); }); var immediated = domain.create(); immediated.on('error', common.mustCall(function(e) { - assert.equal(e.message, 'Immediate Error', - 'Domain should catch immediate error'); + assert.strictEqual(e.message, 'Immediate Error', + 'Domain should catch immediate error'); })); immediated.run(function() { From e718f2051ca156618a4aaa3f5d59b173fcfd92e9 Mon Sep 17 00:00:00 2001 From: k3kathy Date: Thu, 1 Dec 2016 10:16:42 -0600 Subject: [PATCH 189/195] test: refactor test-tls-ocsp-callback refactor all var to either const/let change all assert.equal to assert.strictEqual change all assert.ok(...===...) to assert.strictEqual PR-URL: https://github.com/nodejs/node/pull/9970 Reviewed-By: Prince John Wesley Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-tls-ocsp-callback.js | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/test/parallel/test-tls-ocsp-callback.js b/test/parallel/test-tls-ocsp-callback.js index 442f54791a0f54..c008613c2ccf9f 100644 --- a/test/parallel/test-tls-ocsp-callback.js +++ b/test/parallel/test-tls-ocsp-callback.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!process.features.tls_ocsp) { common.skip('node compiled without OpenSSL or ' + @@ -15,33 +15,33 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var assert = require('assert'); -var fs = require('fs'); -var join = require('path').join; +const assert = require('assert'); +const fs = require('fs'); +const join = require('path').join; const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET; -var pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem')); +const pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem')); function test(testOptions, cb) { - var keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem'); - var certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem'); - var caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem'); - var key = fs.readFileSync(keyFile); - var cert = fs.readFileSync(certFile); - var ca = fs.readFileSync(caFile); - var options = { + const keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem'); + const certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem'); + const caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem'); + const key = fs.readFileSync(keyFile); + const cert = fs.readFileSync(certFile); + const ca = fs.readFileSync(caFile); + const options = { key: key, cert: cert, ca: [ca] }; - var requestCount = 0; - var clientSecure = 0; - var ocspCount = 0; - var ocspResponse; + let requestCount = 0; + let clientSecure = 0; + let ocspCount = 0; + let ocspResponse; if (testOptions.pfx) { delete options.key; @@ -50,7 +50,7 @@ function test(testOptions, cb) { options.passphrase = testOptions.passphrase; } - var server = tls.createServer(options, function(cleartext) { + const server = tls.createServer(options, function(cleartext) { cleartext.on('error', function(er) { // We're ok with getting ECONNRESET in this test, but it's // timing-dependent, and thus unreliable. Any other errors @@ -73,7 +73,7 @@ function test(testOptions, cb) { }, 100); }); server.listen(0, function() { - var client = tls.connect({ + const client = tls.connect({ port: this.address().port, requestOCSP: testOptions.ocsp !== false, secureOptions: testOptions.ocsp === false ? @@ -94,23 +94,23 @@ function test(testOptions, cb) { process.on('exit', function() { if (testOptions.ocsp === false) { - assert.equal(requestCount, clientSecure); - assert.equal(requestCount, 1); + assert.strictEqual(requestCount, clientSecure); + assert.strictEqual(requestCount, 1); return; } if (testOptions.response) { - assert.equal(ocspResponse.toString(), testOptions.response); + assert.strictEqual(ocspResponse.toString(), testOptions.response); } else { - assert.ok(ocspResponse === null); + assert.strictEqual(ocspResponse, null); } - assert.equal(requestCount, testOptions.response ? 0 : 1); - assert.equal(clientSecure, requestCount); - assert.equal(ocspCount, 1); + assert.strictEqual(requestCount, testOptions.response ? 0 : 1); + assert.strictEqual(clientSecure, requestCount); + assert.strictEqual(ocspCount, 1); }); } -var tests = [ +const tests = [ { response: false }, { response: 'hello world' }, { ocsp: false } From 2f6d0c7e61475aa4f5898b277179d6a7da2a4ed1 Mon Sep 17 00:00:00 2001 From: Daryl Thayil Date: Thu, 1 Dec 2016 10:20:41 -0600 Subject: [PATCH 190/195] test: refactor test-require-extensions-main * var => const * assert test fixtures PR-URL: https://github.com/nodejs/node/pull/9912 Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann --- test/parallel/test-require-extensions-main.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-require-extensions-main.js b/test/parallel/test-require-extensions-main.js index 0376082262dd78..e8420cd26cd512 100644 --- a/test/parallel/test-require-extensions-main.js +++ b/test/parallel/test-require-extensions-main.js @@ -1,4 +1,10 @@ 'use strict'; -var common = require('../common'); +const assert = require('assert'); +const common = require('../common'); +const fixturesRequire = require(`${common.fixturesDir}/require-bin/bin/req.js`); -require(common.fixturesDir + '/require-bin/bin/req.js'); +assert.strictEqual( + fixturesRequire, + '', + 'test-require-extensions-main failed to import fixture requirements' +); From 7144f811a6165bddf5a2b670377902f40e13e899 Mon Sep 17 00:00:00 2001 From: Daryl Thayil Date: Thu, 1 Dec 2016 11:47:27 -0600 Subject: [PATCH 191/195] test: add test for url module domainToAscii and domainToUnicode PR-URL: https://github.com/nodejs/node/pull/10031 Reviewed-By: James M Snell --- .../parallel/test-url-domain-ascii-unicode.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/parallel/test-url-domain-ascii-unicode.js diff --git a/test/parallel/test-url-domain-ascii-unicode.js b/test/parallel/test-url-domain-ascii-unicode.js new file mode 100644 index 00000000000000..f9a6be462504c2 --- /dev/null +++ b/test/parallel/test-url-domain-ascii-unicode.js @@ -0,0 +1,27 @@ +'use strict'; + +require('../common'); +const strictEqual = require('assert').strictEqual; +const url = require('url'); + +const domainToASCII = url.URL.domainToASCII; +const domainToUnicode = url.URL.domainToUnicode; + +const domainWithASCII = [ + ['ıídيٴ', 'xn--d-iga7ro0q9f'], + ['www.ϧƽəʐ.com', 'www.xn--cja62apfr6c.com'], + ['новини.com', 'xn--b1amarcd.com'], + ['名がドメイン.com', 'xn--v8jxj3d1dzdz08w.com'], + ['افغانستا.icom.museum', 'xn--mgbaal8b0b9b2b.icom.museum'], + ['الجزائر.icom.fake', 'xn--lgbbat1ad8j.icom.fake'], + ['भारत.org', 'xn--h2brj9c.org'] +]; + +domainWithASCII.forEach((pair) => { + const domain = pair[0]; + const ascii = pair[1]; + const domainConvertedToASCII = domainToASCII(domain); + strictEqual(domainConvertedToASCII, ascii); + const asciiConvertedToUnicode = domainToUnicode(ascii); + strictEqual(asciiConvertedToUnicode, domain); +}); From 9726c8271e16dece2b579b70e08faaf5477bb414 Mon Sep 17 00:00:00 2001 From: Deepti Agrawal Date: Thu, 1 Dec 2016 10:37:13 -0600 Subject: [PATCH 192/195] test: update parallel/test-crypto-hash.js changed equal to strictEqual in parallel/test-crypto-hash.js. Added a second regex argument to the assert.throws function. PR-URL: https://github.com/nodejs/node/pull/10009 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- test/parallel/test-crypto-hash.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index 81ee1d60c53977..9e212443453203 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -39,15 +39,15 @@ a8 = a8.read(); if (!common.hasFipsCrypto) { var a0 = crypto.createHash('md5').update('Test123').digest('latin1'); - assert.equal( + assert.strictEqual( a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c', 'Test MD5 as latin1' ); } -assert.equal(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); -assert.equal(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', - 'Test SHA256 as base64'); +assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1'); +assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=', + 'Test SHA256 as base64'); assert.deepStrictEqual( a3, Buffer.from( @@ -73,7 +73,7 @@ assert.notEqual(a8, undefined, 'empty string should generate data'); // Test multiple updates to same hash var h1 = crypto.createHash('sha1').update('Test123').digest('hex'); var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); -assert.equal(h1, h2, 'multipled updates'); +assert.strictEqual(h1, h2, 'multipled updates'); // Test hashing for binary files var fn = path.join(common.fixturesDir, 'sample.png'); @@ -83,19 +83,19 @@ fileStream.on('data', function(data) { sha1Hash.update(data); }); fileStream.on('close', function() { - assert.equal(sha1Hash.digest('hex'), - '22723e553129a336ad96e10f6aecdf0f45e4149e', - 'Test SHA1 of sample.png'); + assert.strictEqual(sha1Hash.digest('hex'), + '22723e553129a336ad96e10f6aecdf0f45e4149e', + 'Test SHA1 of sample.png'); }); // Issue #2227: unknown digest method should throw an error. assert.throws(function() { crypto.createHash('xyzzy'); -}); +}, /Digest method not supported/); // Default UTF-8 encoding var hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex'); -assert.equal( +assert.strictEqual( hutf8, '4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' + '43a821af66afa9a45b6a78c712fecf0e56dc7f43aef4bcfc8eb5b4d8dca6ea5b'); From 3bc40ce7259fb2954fd366d90038ae6554d01427 Mon Sep 17 00:00:00 2001 From: BethGriggs Date: Tue, 15 Nov 2016 17:47:58 +0000 Subject: [PATCH 193/195] doc: remove repeated info onboarding.md COLLABORATOR_GUIDE.md and onboarding.md cover some of the same information. The aim of this commit is to remove duplicated information. PR-URL: https://github.com/nodejs/node/pull/9635 Reviewed-By: James M Snell Reviewed-By: Sam Roberts --- COLLABORATOR_GUIDE.md | 74 +++++++++++----- doc/onboarding.md | 192 ++++++++++++------------------------------ 2 files changed, 110 insertions(+), 156 deletions(-) diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 214f262fdc61d5..702d539d460301 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -36,6 +36,8 @@ Collaborators or additional evidence that the issue has relevance, the issue may be closed. Remember that issues can always be re-opened if necessary. +[**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) + ## Accepting Modifications All modifications to the Node.js code and documentation should be @@ -60,19 +62,20 @@ and work schedules. Trivial changes (e.g. those which fix minor bugs or improve performance without affecting API or causing other wide-reaching impact) may be landed after a shorter delay. -For non-breaking changes, if there is no disagreement amongst Collaborators, a -pull request may be landed given appropriate review. Where there is discussion -amongst Collaborators, consensus should be sought if possible. The -lack of consensus may indicate the need to elevate discussion to the -CTC for resolution (see below). - -Breaking changes (that is, pull requests that require an increase in the -major version number, known as `semver-major` changes) must be elevated for -review by the CTC. This does not necessarily mean that the PR must be put onto -the CTC meeting agenda. If multiple CTC members approve (`LGTM`) the PR and no -Collaborators oppose the PR, it can be landed. Where there is disagreement among -CTC members or objections from one or more Collaborators, `semver-major` pull -requests should be put on the CTC meeting agenda. +For non-breaking changes, if there is no disagreement amongst +Collaborators, a pull request may be landed given appropriate review. +Where there is discussion amongst Collaborators, consensus should be +sought if possible. The lack of consensus may indicate the need to +elevate discussion to the CTC for resolution (see below). + +Breaking changes (that is, pull requests that require an increase in +the major version number, known as `semver-major` changes) must be +elevated for review by the CTC. This does not necessarily mean that the +PR must be put onto the CTC meeting agenda. If multiple CTC members +approve (`LGTM`) the PR and no Collaborators oppose the PR, it can be +landed. Where there is disagreement among CTC members or objections +from one or more Collaborators, `semver-major` pull requests should be +put on the CTC meeting agenda. All bugfixes require a test case which demonstrates the defect. The test should *fail* before the change, and *pass* after the change. @@ -96,13 +99,20 @@ The CTC should serve as the final arbiter where required. ## Landing Pull Requests +* Please never use GitHub's green ["Merge Pull Request"](https://help.github.com/articles/merging-a-pull-request/#merging-a-pull-request-using-the-github-web-interface) button. + * If you do, please force-push removing the merge. + * Reasons for not using the web interface button: + * The merge method will add an unnecessary merge commit. + * The rebase & merge method adds metadata to the commit title. + * The rebase method changes the author. + * The squash & merge method has been known to add metadata to the + commit title. + * If more than one author has contributed to the PR, only the + latest author will be considered during the squashing. + Always modify the original commit message to include additional meta information regarding the change process: -- A `Reviewed-By: Name ` line for yourself and any - other Collaborators who have reviewed the change. - - Useful for @mentions / contact list if something goes wrong in the PR. - - Protects against the assumption that GitHub will be around forever. - A `PR-URL:` line that references the *full* GitHub URL of the original pull request being merged so it's easy to trace a commit back to the conversation that led up to that change. @@ -110,6 +120,10 @@ information regarding the change process: for an issue, and/or the hash and commit message if the commit fixes a bug in a previous commit. Multiple `Fixes:` lines may be added if appropriate. +- A `Reviewed-By: Name ` line for yourself and any + other Collaborators who have reviewed the change. + - Useful for @mentions / contact list if something goes wrong in the PR. + - Protects against the assumption that GitHub will be around forever. Review the commit message to ensure that it adheres to the guidelines outlined in the [contributing](https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#step-3-commit) guide. @@ -119,7 +133,6 @@ See the commit log for examples such as exactly how to format your commit messages. Additionally: - - Double check PRs to make sure the person's _full name_ and email address are correct before merging. - Except when updating dependencies, all commits should be self @@ -224,16 +237,36 @@ Save the file and close the editor. You'll be asked to enter a new commit message for that commit. This is a good moment to fix incorrect commit logs, ensure that they are properly formatted, and add `Reviewed-By` lines. +* The commit message text must conform to the [commit message guidelines](../CONTRIBUTING.md#step-3-commit). Time to push it: ```text $ git push origin master ``` +* Optional: Force push the amended commit to the branch you used to +open the pull request. If your branch is called `bugfix`, then the +command would be `git push --force-with-lease origin master:bugfix`. +When the pull request is closed, this will cause the pull request to +show the purple merged status rather than the red closed status that is +usually used for pull requests that weren't merged. Only do this when +landing your own contributions. + +* Close the pull request with a "Landed in ``" comment. If +your pull request shows the purple merged status then you should still +add the "Landed in .." comment if you added +multiple commits. + +* `./configure && make -j8 test` + * `-j8` builds node in parallel with 8 threads. Adjust to the number + of cores or processor-level threads your processor has (or slightly + more) for best results. ### I Just Made a Mistake -With `git`, there's a way to override remote trees by force pushing +* Ping a CTC member. +* `#node-dev` on freenode +* With `git`, there's a way to override remote trees by force pushing (`git push -f`). This should generally be seen as forbidden (since you're rewriting history on a repository other people are working against) but is allowed for simpler slip-ups such as typos in commit @@ -241,6 +274,9 @@ messages. However, you are only allowed to force push to any Node.js branch within 10 minutes from your original push. If someone else pushes to the branch or the 10 minute period passes, consider the commit final. + * Use `--force-with-lease` to minimize the chance of overwriting + someone else's change. + * Post to `#node-dev` (IRC) if you force push. ### Long Term Support diff --git a/doc/onboarding.md b/doc/onboarding.md index 5d0560e176e7ba..665890da968699 100644 --- a/doc/onboarding.md +++ b/doc/onboarding.md @@ -14,107 +14,98 @@ onboarding session. * Prior to the onboarding session, add the new Collaborators to [the Collaborators team](https://github.com/orgs/nodejs/teams/collaborators). -## **thank you** for doing this +## Onboarding session - * going to cover four things: - * local setup - * some project goals & values - * issues, labels, and reviewing code - * merging code - -## setup - - * notifications setup - * use https://github.com/notifications or set up email - * watching the main repo will flood your inbox, so be prepared +* **thank you** for doing this +* will cover: + * [local setup](#local-setup) + * [project goals & values](#project-goals--values) + * [managing the issue tracker](#managing-the-issue-tracker) + * [reviewing PRs](#reviewing-prs) + * [landing PRs](#landing-prs) +## Local setup * git: * make sure you have whitespace=fix: `git config --global --add core.whitespace fix` * usually PR from your own github fork - * [**See "Updating Node.js from Upstream"**](./onboarding-extras.md#updating-nodejs-from-upstream) + * [See "Updating Node.js from Upstream"](./onboarding-extras.md#updating-nodejs-from-upstream) * make new branches for all commits you make! + * notifications: + * use [https://github.com/notifications](https://github.com/notifications) or set up email + * watching the main repo will flood your inbox, so be prepared - * `#node-dev` on `chat.freenode.net` is the best place to interact with the CTC / other collaborators + * `#node-dev` on [webchat.freenode.net](https://webchat.freenode.net/) is the best place to interact with the CTC / other collaborators -## a little deeper about the project +## Project goals & values * collaborators are effectively part owners * the project has the goals of its contributors - * but, there are some higher-level goals and values * not everything belongs in core (if it can be done reasonably in userland, let it stay in userland) * empathy towards users matters (this is in part why we onboard people) * generally: try to be nice to people - -## managing the issue tracker +## Managing the issue tracker * you have (mostly) free rein – don't hesitate to close an issue if you are confident that it should be closed - * this will come more naturally over time - * IMPORTANT: be nice about closing issues, let people know why, and that issues and PRs can be reopened if necessary - * Still need to follow the Code of Conduct. - + * **IMPORTANT**: be nice about closing issues, let people know why, and that issues and PRs can be reopened if necessary + * Still need to follow the Code of Conduct - * Labels: + * [**See "Labels"**](./onboarding-extras.md#labels) * There is [a bot](https://github.com/nodejs-github-bot/github-bot) that applies subsystem labels (for example, `doc`, `test`, `assert`, or `buffer`) so that we know what parts of the code base the pull request modifies. It is not perfect, of course. Feel free to apply relevant labels and remove irrelevant labels from pull requests and issues. - * [**See "Labels"**](./onboarding-extras.md#labels) * Use the `ctc-review` label if a topic is controversial or isn't coming to a conclusion after an extended time. * `semver-{minor,major}`: - * If a change has the remote *chance* of breaking something, use `semver-major` + * If a change has the remote *chance* of breaking something, use the `semver-major` label * When adding a semver label, add a comment explaining why you're adding it. Do it right away so you don't forget! - * Notifying humans - * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) + * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) * will also come more naturally over time - - * Reviewing: - * The primary goal is for the codebase to improve. - * Secondary (but not far off) is for the person submitting code to succeed. +## Reviewing PRs + * The primary goal is for the codebase to improve. + * Secondary (but not far off) is for the person submitting code to succeed. A pull request from a new contributor is an opportunity to grow the community. - * Review a bit at a time. Do not overwhelm new contributors. - * It is tempting to micro-optimize and make everything about relative + * Review a bit at a time. Do not overwhelm new contributors. + * It is tempting to micro-optimize and make everything about relative performance. Don't succumb to that temptation. We change V8 often. Techniques that provide improved performance today may be unnecessary in the future. - * Be aware: Your opinion carries a lot of weight! - * Nits (requests for small changes that are not essential) are fine, but try - to avoid stalling the pull request. - * Note that they are nits when you comment: `Nit: change foo() to bar().` - * If they are stalling the pull request, fix them yourself on merge. - * Minimum wait for comments time - * There is a minimum waiting time which we try to respect for non-trivial + * Be aware: Your opinion carries a lot of weight! + * Nits (requests for small changes that are not essential) are fine, but try + to avoid stalling the pull request. + * Note that they are nits when you comment: `Nit: change foo() to bar().` + * If they are stalling the pull request, fix them yourself on merge. + * Minimum wait for comments time + * There is a minimum waiting time which we try to respect for non-trivial changes, so that people who may have important input in such a distributed project are able to respond. - * For non-trivial changes, leave the pull request open for at least 48 + * For non-trivial changes, leave the pull request open for at least 48 hours (72 hours on a weekend). - * If a pull request is abandoned, check if they'd mind if you took it over + * If a pull request is abandoned, check if they'd mind if you took it over (especially if it just has nits left). - * Approving a change - * Collaborators indicate that they have reviewed and approve of the + * Approving a change + * Collaborators indicate that they have reviewed and approve of the the changes in a pull request by commenting with `LGTM`, which stands for "looks good to me". - * You have the power to `LGTM` another collaborator's (including TSC/CTC + * You have the power to `LGTM` another collaborator's (including TSC/CTC members) work. - * You may not `LGTM` your own pull requests. - * You have the power to `LGTM` anyone else's pull requests. - + * You may not `LGTM` your own pull requests. + * You have the power to `LGTM` anyone else's pull requests. - * what belongs in node: + * What belongs in node: * opinions vary, but I find the following helpful: * if node itself needs it (due to historic reasons), then it belongs in node * that is to say, url is there because of http, freelist is there because of http, et al * also, things that cannot be done outside of core, or only with significant pain (example: async-wrap) - * Continuous Integration (CI) Testing: - * https://ci.nodejs.org/ + * [https://ci.nodejs.org/](https://ci.nodejs.org/) * It is not automatically run. You need to start it manually. * Log in on CI is integrated with GitHub. Try to log in now! * You will be using `node-test-pull-request` most of the time. Go there now! @@ -130,85 +121,13 @@ onboarding session. * Use the [Build WG repo](https://github.com/nodejs/build) to file issues for the Build WG members who maintain the CI infrastructure. -## Landing PRs: Overview - - * The [Collaborator Guide](https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#technical-howto) is a great resource. - - - * No one (including TSC or CTC members) pushes directly to master without review. - * An exception is made for release commits only. - - - * One `LGTM` is sufficient, except for semver-major changes. - * More than one is better. - * Breaking changes must be LGTM'ed by at least two CTC members. - * If one or more Collaborators object to a change, it should not land until - the objection is addressed. The options for such a situation include: - * Engaging those with objections to determine a viable path forward; - * Altering the pull request to address the objections; - * Escalating the discussion to the CTC using the `ctc-review` label. This - should only be done after the previous options have been exhausted. - - * Wait before merging non-trivial changes. - * 48 hours during the week and 72 hours on weekends. - * An example of a trivial change would be correcting the misspelling of a single word in a documentation file. This sort of change still needs to receive at least one `LGTM` but it does not need to wait 48 hours before landing. - - * **Run the PR through CI before merging!** - * An exception can be made for documentation-only PRs as long as it does not include the `addons.md` documentation file. (Example code from that document is extracted and built as part of the tests!) - - * What if something goes wrong? - * Ping a CTC member. - * `#node-dev` on freenode - * Force-pushing to fix things after is allowed for ~10 minutes. Avoid it if you can. - * Use `--force-with-lease` to minimize the chance of overwriting someone else's change. - * Post to `#node-dev` (IRC) if you force push. - - -## Landing PRs: Details - -* Please never use GitHub's green ["Merge Pull Request"](https://help.github.com/articles/merging-a-pull-request/#merging-a-pull-request-using-the-github-web-interface) button. - * If you do, please force-push removing the merge. - * Reasons for not using the web interface button: - * The merge method will add an unnecessary merge commit. - * The rebase & merge method adds metadata to the commit title. - * The rebase method changes the author. - * The squash & merge method has been known to add metadata to the commit title. - * If more than one author has contributed to the PR, only the latest author will be considered during the squashing. - - -Update your `master` branch (or whichever branch you are landing on, almost always `master`) - -* [**See "Updating Node.js from Upstream"**](./onboarding-extras.md#updating-nodejs-from-upstream) - -Landing a PR - -* If it all looks good, `curl -L 'url-of-pr.patch' | git am` - * If `git am` fails, see [the relevant section of the Onboarding Extras doc](./onboarding-extras.md#if-git-am-fails). -* `git rebase -i upstream/master` -* Squash into logical commits if necessary. -* `./configure && make -j8 test` (`-j8` builds node in parallel with 8 threads. adjust to the number of cores (or processor-level threads) your processor has (or slightly more) for best results.) -* Amend the commit description. - * The commit message text must conform to the [commit message guidelines](../CONTRIBUTING.md#step-3-commit). - * Add required metadata: - * `PR-URL: ` - * `Reviewed-By: ` - * Easiest to use `git log`, then do a search. - * In vim: `/Name` + `enter` (+ `n` as much as you need to) - * Only include collaborators who have commented `LGTM`. - * Add additional metadata as appropriate: - * `Fixes: ` - * Full URL of GitHub issue that the PR fixes. - * This will automatically close the PR when the commit lands in master. - * `Refs: ` - * Full URL of material that might provide additional useful information or context to someone trying to understand the change set or the thinking behind it. -* Optional: Force push the amended commit to the branch you used to open the pull request. If your branch is called `bugfix`, then the command would be `git push --force-with-lease origin master:bugfix`. When the pull request is closed, this will cause the pull request to show the purple merged status rather than the red closed status that is usually used for pull requests that weren't merged. Only do this when landing your own contributions. -* `git push upstream master` - * Close the pull request with a "Landed in ``" comment. +## Landing PRs + * [See the Collaborator Guide: Technical HOWTO](https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#technical-howto) ## Exercise: Make a PR adding yourself to the README - * Example: https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732 + * Example: [https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732](https://github.com/nodejs/node/commit/7b09aade8468e1c930f36b9c81e6ac2ed5bc8732) * For raw commit message: `git log 7b09aade8468e1c930f36b9c81e6ac2ed5bc8732 -1` * Collaborators are in alphabetical order by GitHub username. * Label your pull request with the `doc` subsystem label. @@ -216,18 +135,17 @@ Landing a PR * After a `LGTM` or two, land the PR. * Be sure to add the `PR-URL: ` and appropriate `Reviewed-By:` metadata! - -## final notes +## Final notes * don't worry about making mistakes: everybody makes them, there's a lot to internalize and that takes time (and we recognize that!) * very few (no?) mistakes are unrecoverable - * the existing node committers trust you and are grateful for your help! + * the existing collaborators trust you and are grateful for your help! * other repos: - * https://github.com/nodejs/dev-policy - * https://github.com/nodejs/NG - * https://github.com/nodejs/api - * https://github.com/nodejs/build - * https://github.com/nodejs/docs - * https://github.com/nodejs/nodejs.org - * https://github.com/nodejs/readable-stream - * https://github.com/nodejs/LTS + * [https://github.com/nodejs/dev-policy](https://github.com/nodejs/dev-policy) + * [https://github.com/nodejs/NG](https://github.com/nodejs/NG) + * [https://github.com/nodejs/api](https://github.com/nodejs/api) + * [https://github.com/nodejs/build](https://github.com/nodejs/build) + * [https://github.com/nodejs/docs](https://github.com/nodejs/docs) + * [https://github.com/nodejs/nodejs.org](https://github.com/nodejs/nodejs.org) + * [https://github.com/nodejs/readable-stream](https://github.com/nodejs/readable-stream) + * [https://github.com/nodejs/LTS](https://github.com/nodejs/LTS) From 35d284685eb4108fccdfd312f8a09bebbb098f7b Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 6 Dec 2016 15:08:11 -0500 Subject: [PATCH 194/195] 2016-12-06, Version 7.2.1 (Current) Notable changes: * buffer: - Reverted the runtime deprecation of calling `Buffer()` without `new`. (Anna Henningsen) https://github.com/nodejs/node/pull/9529 - Fixed `buffer.transcode()` for single-byte character encodings to `UCS2`. (Anna Henningsen) https://github.com/nodejs/node/pull/9838 * promise: `--trace-warnings` now produces useful stacktraces for Promise warnings. (Anna Henningsen) https://github.com/nodejs/node/pull/9525 * repl: Fixed a bug preventing correct parsing of generator functions. (Teddy Katz) https://github.com/nodejs/node/pull/9852 * V8: Fixed a significant `instanceof` performance regression. (Franziska Hinkelmann) https://github.com/nodejs/node/pull/9730 --- CHANGELOG.md | 3 +- doc/changelogs/CHANGELOG_V7.md | 210 +++++++++++++++++++++++++++++++++ src/node_version.h | 2 +- 3 files changed, 213 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fb528654cd40c..f5263390e5c07c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. - 7.2.0
+ 7.2.1
+ 7.2.0
7.1.0
7.0.0
diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md index cca42c54c32307..cdb0f692fab7ce 100644 --- a/doc/changelogs/CHANGELOG_V7.md +++ b/doc/changelogs/CHANGELOG_V7.md @@ -6,6 +6,7 @@ +7.2.1
7.2.0
7.1.0
7.0.0
@@ -22,6 +23,215 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2016-12-06, Version 7.2.1 (Current), @Fishrock123 + +### Notable changes + +* **buffer**: + - Reverted the runtime deprecation of calling `Buffer()` without `new`. (Anna Henningsen) [#9529](https://github.com/nodejs/node/pull/9529) + - Fixed `buffer.transcode()` for single-byte character +encodings to `UCS2`. (Anna Henningsen) [#9838](https://github.com/nodejs/node/pull/9838) +* **promise**: `--trace-warnings` now produces useful stacktraces for Promise warnings. (Anna Henningsen) [#9525](https://github.com/nodejs/node/pull/9525) +* **repl**: Fixed a bug preventing correct parsing of generator functions. (Teddy Katz) [#9852](https://github.com/nodejs/node/pull/9852) +* **V8**: Fixed a significant `instanceof` performance regression. (Franziska Hinkelmann) [#9730](https://github.com/nodejs/node/pull/9730) + +### Commits + +* [[`f55a63c86f`](https://github.com/nodejs/node/commit/f55a63c86f)] - internal/util: move the case 'latin1' (Jackson Tian) [#9646](https://github.com/nodejs/node/pull/9646) +* [[`5379b9da11`](https://github.com/nodejs/node/commit/5379b9da11)] - **async\_wrap**: call destroy() callback in `uv_idle_t` (Trevor Norris) [#9753](https://github.com/nodejs/node/pull/9753) +* [[`5157a5cee9`](https://github.com/nodejs/node/commit/5157a5cee9)] - **async\_wrap**: make Initialize a static class member (Trevor Norris) [#9753](https://github.com/nodejs/node/pull/9753) +* [[`3e5be7fc8b`](https://github.com/nodejs/node/commit/3e5be7fc8b)] - **async\_wrap**: mode constructor/destructor to .cc (Trevor Norris) [#9753](https://github.com/nodejs/node/pull/9753) +* [[`88464ac6ac`](https://github.com/nodejs/node/commit/88464ac6ac)] - **benchmark**: reformat code for clarity (Rich Trott) [#9790](https://github.com/nodejs/node/pull/9790) +* [[`573f9db6c9`](https://github.com/nodejs/node/commit/573f9db6c9)] - **buffer**: fix transcode for single-byte enc to ucs2 (Anna Henningsen) [#9838](https://github.com/nodejs/node/pull/9838) +* [[`0c745e3a3a`](https://github.com/nodejs/node/commit/0c745e3a3a)] - **buffer**: convert offset & length to int properly (Sakthipriyan Vairamani (thefourtheye)) [#9815](https://github.com/nodejs/node/pull/9815) +* [[`e0e62d1113`](https://github.com/nodejs/node/commit/e0e62d1113)] - ***Revert*** "**buffer**: runtime deprecation of calling Buffer without new" (Anna Henningsen) [#9529](https://github.com/nodejs/node/pull/9529) +* [[`371090d817`](https://github.com/nodejs/node/commit/371090d817)] - **build**: Make configure file parseable on python3 (kalrover) [#9657](https://github.com/nodejs/node/pull/9657) +* [[`16af467146`](https://github.com/nodejs/node/commit/16af467146)] - **build**: add shared library support to AIX build (Stewart Addison) [#9675](https://github.com/nodejs/node/pull/9675) +* [[`fa38032148`](https://github.com/nodejs/node/commit/fa38032148)] - **child\_process**: name anonymous functions (brad-decker) [#9880](https://github.com/nodejs/node/pull/9880) +* [[`5c9aa18484`](https://github.com/nodejs/node/commit/5c9aa18484)] - **constants**: errors -> errno (Bryan English) [#9349](https://github.com/nodejs/node/pull/9349) +* [[`dfa35d66f5`](https://github.com/nodejs/node/commit/dfa35d66f5)] - **debugger**: call `this.resume()` after `this.run()` (Lance Ball) [#10099](https://github.com/nodejs/node/pull/10099) +* [[`ac8d212428`](https://github.com/nodejs/node/commit/ac8d212428)] - **debugger**: refactor `_debugger.js` (Rich Trott) [#9860](https://github.com/nodejs/node/pull/9860) +* [[`4bcda633c0`](https://github.com/nodejs/node/commit/4bcda633c0)] - **deps**: upgrade npm to 3.10.10 (Rebecca Turner) [#9847](https://github.com/nodejs/node/pull/9847) +* [[`03b1c314cd`](https://github.com/nodejs/node/commit/03b1c314cd)] - **deps**: cherry-pick 08377af from v8 upstream (Franziska Hinkelmann) [#9730](https://github.com/nodejs/node/pull/9730) +* [[`e9c2ffd20c`](https://github.com/nodejs/node/commit/e9c2ffd20c)] - **deps**: backport GYP fix to fix AIX shared suffix (Stewart Addison) +* [[`3bc40ce725`](https://github.com/nodejs/node/commit/3bc40ce725)] - **doc**: remove repeated info onboarding.md (BethGriggs) [#9635](https://github.com/nodejs/node/pull/9635) +* [[`446bcbea4e`](https://github.com/nodejs/node/commit/446bcbea4e)] - **doc**: correct it's vs. its usage (Rich Trott) [#10098](https://github.com/nodejs/node/pull/10098) +* [[`b9bd9a2fcb`](https://github.com/nodejs/node/commit/b9bd9a2fcb)] - **doc**: remove Sam Roberts from release team (Sam Roberts) [#9862](https://github.com/nodejs/node/pull/9862) +* [[`51b77aa44a`](https://github.com/nodejs/node/commit/51b77aa44a)] - **doc**: add people to cc for async_wrap (Anna Henningsen) [#9471](https://github.com/nodejs/node/pull/9471) +* [[`346204d77e`](https://github.com/nodejs/node/commit/346204d77e)] - **doc**: add link to `net.Server` in tls.md (Devon Rifkin) [#10109](https://github.com/nodejs/node/pull/10109) +* [[`c4fbdfa785`](https://github.com/nodejs/node/commit/c4fbdfa785)] - **doc**: fix typo for `decipher.final`. (iamchenxin) [#10086](https://github.com/nodejs/node/pull/10086) +* [[`d226418b87`](https://github.com/nodejs/node/commit/d226418b87)] - **doc**: suggest Buffer.alloc instead of Buffer#fill (Teddy Katz) [#10000](https://github.com/nodejs/node/pull/10000) +* [[`78e188d929`](https://github.com/nodejs/node/commit/78e188d929)] - **doc**: clarify fs.createReadStream options (Wes Tyler) [#10078](https://github.com/nodejs/node/pull/10078) +* [[`cdec174d4d`](https://github.com/nodejs/node/commit/cdec174d4d)] - **doc**: var => const in js code examples of addons.md (Vse Mozhet Byt) [#10092](https://github.com/nodejs/node/pull/10092) +* [[`13eea40d6f`](https://github.com/nodejs/node/commit/13eea40d6f)] - **doc**: rename writing_tests.md to writing-tests.md (Safia Abdalla) [#9867](https://github.com/nodejs/node/pull/9867) +* [[`c948d9051b`](https://github.com/nodejs/node/commit/c948d9051b)] - **doc**: it’s -> its in api/child_process.md (Devon Rifkin) [#10090](https://github.com/nodejs/node/pull/10090) +* [[`f6c1f24068`](https://github.com/nodejs/node/commit/f6c1f24068)] - **doc**: update Collaborators list in README (Rich Trott) [#9846](https://github.com/nodejs/node/pull/9846) +* [[`a0e25b2544`](https://github.com/nodejs/node/commit/a0e25b2544)] - **doc**: remove minor contradiction in debugger doc (Rich Trott) [#9832](https://github.com/nodejs/node/pull/9832) +* [[`8c70f79249`](https://github.com/nodejs/node/commit/8c70f79249)] - **doc**: clarify introductory module material (Rich Trott) [#9816](https://github.com/nodejs/node/pull/9816) +* [[`2e22fa043d`](https://github.com/nodejs/node/commit/2e22fa043d)] - **doc**: improve description of module `exports` (Sam Roberts) [#9622](https://github.com/nodejs/node/pull/9622) +* [[`6ab920a3fc`](https://github.com/nodejs/node/commit/6ab920a3fc)] - **doc**: add guide for maintaining V8 (Ali Ijaz Sheikh) [#9777](https://github.com/nodejs/node/pull/9777) +* [[`4fa84c9589`](https://github.com/nodejs/node/commit/4fa84c9589)] - **doc**: fix crypto Verify cut-n-paste from Sign (子丶言) [#9796](https://github.com/nodejs/node/pull/9796) +* [[`6297b9afc5`](https://github.com/nodejs/node/commit/6297b9afc5)] - **doc**: minor fixes event-loop-timers-and-nexttick.md (Dan Koster) [#9126](https://github.com/nodejs/node/pull/9126) +* [[`a8d84d5b50`](https://github.com/nodejs/node/commit/a8d84d5b50)] - **doc**: changed order of invocations in https.request() example. (atrioom) [#9614](https://github.com/nodejs/node/pull/9614) +* [[`c7cd400fcb`](https://github.com/nodejs/node/commit/c7cd400fcb)] - **doc**: fix crypto "decipher.setAAD()" typo (子丶言) [#9782](https://github.com/nodejs/node/pull/9782) +* [[`77e145a00e`](https://github.com/nodejs/node/commit/77e145a00e)] - **doc**: clarify slashes-appending in url module (Rich Trott) [#9731](https://github.com/nodejs/node/pull/9731) +* [[`65af114267`](https://github.com/nodejs/node/commit/65af114267)] - **doc**: "util" is not needed to extend ES6 classes (Adam Brunner) [#9737](https://github.com/nodejs/node/pull/9737) +* [[`44ae0283af`](https://github.com/nodejs/node/commit/44ae0283af)] - **doc**: fix `` inside stability boxes (Roman Reiss) [#9723](https://github.com/nodejs/node/pull/9723) +* [[`9554a974d1`](https://github.com/nodejs/node/commit/9554a974d1)] - **https**: name anonymous functions in https (Pedro Lima) [#9217](https://github.com/nodejs/node/pull/9217) +* [[`80a3934cd7`](https://github.com/nodejs/node/commit/80a3934cd7)] - **inspector**: /json/version returns object, not array (Ben Noordhuis) [#9762](https://github.com/nodejs/node/pull/9762) +* [[`65cda7f265`](https://github.com/nodejs/node/commit/65cda7f265)] - **lib**: use === in `_http_server` and `_tls_wrap` (Walter Beller-Morales) [#9849](https://github.com/nodejs/node/pull/9849) +* [[`a673d44d68`](https://github.com/nodejs/node/commit/a673d44d68)] - **lib,tools**: remove unneeded escaping of / (Prince J Wesley) [#9591](https://github.com/nodejs/node/pull/9591) +* [[`3253954e62`](https://github.com/nodejs/node/commit/3253954e62)] - **meta**: whitelist dotfiles in .gitignore (Claudio Rodriguez) [#8016](https://github.com/nodejs/node/pull/8016) +* [[`cef3a04f62`](https://github.com/nodejs/node/commit/cef3a04f62)] - **promise**: better stack traces for --trace-warnings (Anna Henningsen) [#9525](https://github.com/nodejs/node/pull/9525) +* [[`a0f6cc718a`](https://github.com/nodejs/node/commit/a0f6cc718a)] - **repl**: avoid parsing division operator as regex (Teddy Katz) [#10103](https://github.com/nodejs/node/pull/10103) +* [[`6087e361e5`](https://github.com/nodejs/node/commit/6087e361e5)] - **repl**: preprocess only for defaultEval (Prince J Wesley) [#9752](https://github.com/nodejs/node/pull/9752) +* [[`9099664959`](https://github.com/nodejs/node/commit/9099664959)] - **repl**: fix generator function preprocessing (Teddy Katz) [#9852](https://github.com/nodejs/node/pull/9852) +* [[`9726c8271e`](https://github.com/nodejs/node/commit/9726c8271e)] - **test**: update parallel/test-crypto-hash.js (Deepti Agrawal) [#10009](https://github.com/nodejs/node/pull/10009) +* [[`7144f811a6`](https://github.com/nodejs/node/commit/7144f811a6)] - **test**: add test for url module domainToAscii and domainToUnicode (Daryl Thayil) [#10031](https://github.com/nodejs/node/pull/10031) +* [[`2f6d0c7e61`](https://github.com/nodejs/node/commit/2f6d0c7e61)] - **test**: refactor test-require-extensions-main (Daryl Thayil) [#9912](https://github.com/nodejs/node/pull/9912) +* [[`e718f2051c`](https://github.com/nodejs/node/commit/e718f2051c)] - **test**: refactor test-tls-ocsp-callback (k3kathy) [#9970](https://github.com/nodejs/node/pull/9970) +* [[`f5e622ea53`](https://github.com/nodejs/node/commit/f5e622ea53)] - **test**: use assert.strictEqual and fix setTimeout (Matt Phillips) [#9957](https://github.com/nodejs/node/pull/9957) +* [[`0a4fc64c3f`](https://github.com/nodejs/node/commit/0a4fc64c3f)] - **test**: clean up tls junk test (Danny Guo) [#9940](https://github.com/nodejs/node/pull/9940) +* [[`a3a664a321`](https://github.com/nodejs/node/commit/a3a664a321)] - **test**: update test-stdout-to-file (scalkpdev) [#9939](https://github.com/nodejs/node/pull/9939) +* [[`f531c96846`](https://github.com/nodejs/node/commit/f531c96846)] - **test**: changed assert.Equal to asset.strictEqual (Paul Chin) [#9973](https://github.com/nodejs/node/pull/9973) +* [[`843b8c1658`](https://github.com/nodejs/node/commit/843b8c1658)] - **test**: refactor test-domain-multi (Wes Tyler) [#9963](https://github.com/nodejs/node/pull/9963) +* [[`8936d835c1`](https://github.com/nodejs/node/commit/8936d835c1)] - **test**: refactor test-fs-write.js (hirabhullar) [#9982](https://github.com/nodejs/node/pull/9982) +* [[`2f731e5b5d`](https://github.com/nodejs/node/commit/2f731e5b5d)] - **test**: refactor test-child-fork-exec-path.js (hirabhullar) [#9982](https://github.com/nodejs/node/pull/9982) +* [[`d697ac404f`](https://github.com/nodejs/node/commit/d697ac404f)] - **test**: use assert.strictEqual in test-cli-eval (Nigel Kibodeaux) [#9919](https://github.com/nodejs/node/pull/9919) +* [[`0a07bccc5c`](https://github.com/nodejs/node/commit/0a07bccc5c)] - **test**: refactor test-tls-connect-simple (Russell Sherman) [#9934](https://github.com/nodejs/node/pull/9934) +* [[`371a785f6d`](https://github.com/nodejs/node/commit/371a785f6d)] - **test**: refactor test-signal-unregister (mark hughes) [#9920](https://github.com/nodejs/node/pull/9920) +* [[`79b36e927c`](https://github.com/nodejs/node/commit/79b36e927c)] - **test**: update test-net-connect-handle-econnrefused (Punit Buch) [#9932](https://github.com/nodejs/node/pull/9932) +* [[`ba7d1cf4bc`](https://github.com/nodejs/node/commit/ba7d1cf4bc)] - **test**: refactor test-require-resolve (blugavere) [#10120](https://github.com/nodejs/node/pull/10120) +* [[`1877ba3384`](https://github.com/nodejs/node/commit/1877ba3384)] - **test**: refactor test-fs-symlink-dir-junction (Walter Beller-Morales) [#9928](https://github.com/nodejs/node/pull/9928) +* [[`84813fdaf8`](https://github.com/nodejs/node/commit/84813fdaf8)] - **test**: refactor test-fs-read-stream-resume (Matt Webb) [#9927](https://github.com/nodejs/node/pull/9927) +* [[`f68bfc5bde`](https://github.com/nodejs/node/commit/f68bfc5bde)] - **test**: replace equal with strictEqual (Tracy Hinds) [#10011](https://github.com/nodejs/node/pull/10011) +* [[`c0eb08adbe`](https://github.com/nodejs/node/commit/c0eb08adbe)] - **test**: use strictEqual instead of equal (Uttam Pawar) [#9921](https://github.com/nodejs/node/pull/9921) +* [[`2e36b2ef49`](https://github.com/nodejs/node/commit/2e36b2ef49)] - **test**: using const and strictEqual (Fabrice Tatieze) [#9926](https://github.com/nodejs/node/pull/9926) +* [[`8e27254594`](https://github.com/nodejs/node/commit/8e27254594)] - **test**: convert assert.equal to assert.strictEqual (Jonathan Darling) [#9925](https://github.com/nodejs/node/pull/9925) +* [[`328cd93036`](https://github.com/nodejs/node/commit/328cd93036)] - **test**: changed assert.equal to assert.strictEqual (Scott Smereka) [#9936](https://github.com/nodejs/node/pull/9936) +* [[`cbdc64e026`](https://github.com/nodejs/node/commit/cbdc64e026)] - **test**: test-file-write-stream3.js refactor (Richard Karmazin) [#10035](https://github.com/nodejs/node/pull/10035) +* [[`7c90244677`](https://github.com/nodejs/node/commit/7c90244677)] - **test**: implemented es6 conventions (Erez Weiss) [#9669](https://github.com/nodejs/node/pull/9669) +* [[`bb677d41ce`](https://github.com/nodejs/node/commit/bb677d41ce)] - **test**: strictEqual() and RegExp in test-buffer-fill.js (J Scott Chapman) [#9895](https://github.com/nodejs/node/pull/9895) +* [[`34b8c86895`](https://github.com/nodejs/node/commit/34b8c86895)] - **test**: Modernize test-tls-peer-certificate.js (Ilya Potuzhnov) [#10014](https://github.com/nodejs/node/pull/10014) +* [[`5ad7e04280`](https://github.com/nodejs/node/commit/5ad7e04280)] - **test**: strictCompare and explcit inputs mprovement to test-buffer-slice (Michael Alexander) [#10048](https://github.com/nodejs/node/pull/10048) +* [[`256de35c98`](https://github.com/nodejs/node/commit/256de35c98)] - **test**: add test for process.stdin.setRawMode() (Jonathan Darling) [#10037](https://github.com/nodejs/node/pull/10037) +* [[`990a19fc7e`](https://github.com/nodejs/node/commit/990a19fc7e)] - **test**: refactor test for net listen on fd0 (Julian Duque) [#10025](https://github.com/nodejs/node/pull/10025) +* [[`7fd8833fa9`](https://github.com/nodejs/node/commit/7fd8833fa9)] - **test**: update assert.equal() to assert.strictEqual() (Peter Diaz) [#10024](https://github.com/nodejs/node/pull/10024) +* [[`fdc55ef02c`](https://github.com/nodejs/node/commit/fdc55ef02c)] - **test**: use const or let and assert.strictEqual (Christopher Rokita) [#10001](https://github.com/nodejs/node/pull/10001) +* [[`ae1ef5336d`](https://github.com/nodejs/node/commit/ae1ef5336d)] - **test**: fix buffer alloc tests (levsoroka) [#9998](https://github.com/nodejs/node/pull/9998) +* [[`e8fc7fcef7`](https://github.com/nodejs/node/commit/e8fc7fcef7)] - **test**: Added more validations to setEncoding (Paul Lucas) [#9997](https://github.com/nodejs/node/pull/9997) +* [[`79e6068d5c`](https://github.com/nodejs/node/commit/79e6068d5c)] - **test**: use strictEqual() domain-http (cdnadmin) [#9996](https://github.com/nodejs/node/pull/9996) +* [[`7428d80879`](https://github.com/nodejs/node/commit/7428d80879)] - **test**: refactor test-cluster-worker-events (fmizzell) [#9994](https://github.com/nodejs/node/pull/9994) +* [[`6df3b7babc`](https://github.com/nodejs/node/commit/6df3b7babc)] - **test**: update repl tests (makenova) [#9991](https://github.com/nodejs/node/pull/9991) +* [[`47b5f9e710`](https://github.com/nodejs/node/commit/47b5f9e710)] - **test**: modernize test-fs-truncate-fd (Nigel Kibodeaux) [#9978](https://github.com/nodejs/node/pull/9978) +* [[`8b6c45f4b4`](https://github.com/nodejs/node/commit/8b6c45f4b4)] - **test**: update tls test to use const/let and common.mustCall (rgoodwin) [#9968](https://github.com/nodejs/node/pull/9968) +* [[`c05909b3e8`](https://github.com/nodejs/node/commit/c05909b3e8)] - **test**: adding strictEqual to test-buffer-indexof.js (Eric Gonzalez) [#9955](https://github.com/nodejs/node/pull/9955) +* [[`d0852459d5`](https://github.com/nodejs/node/commit/d0852459d5)] - **test**: strictEqual in test-beforeexit-event.js (CodeTheInternet) [#10004](https://github.com/nodejs/node/pull/10004) +* [[`2beba9e025`](https://github.com/nodejs/node/commit/2beba9e025)] - **test**: refactor test-child-process-double-pipe (Dan Villa) [#9930](https://github.com/nodejs/node/pull/9930) +* [[`64b2494e90`](https://github.com/nodejs/node/commit/64b2494e90)] - **test**: updated tls-getcipher test (Ethan Arrowood) [#9923](https://github.com/nodejs/node/pull/9923) +* [[`e502262687`](https://github.com/nodejs/node/commit/e502262687)] - **test**: replace equal with strictEqual in test-freelist.js (Adrian Estrada) [#9910](https://github.com/nodejs/node/pull/9910) +* [[`5a2b68896c`](https://github.com/nodejs/node/commit/5a2b68896c)] - **test**: updated test-stream-pipe-unpipe-stream (Raja Panidepu) [#10100](https://github.com/nodejs/node/pull/10100) +* [[`f900753eeb`](https://github.com/nodejs/node/commit/f900753eeb)] - **test**: refactor test-crypto-ecb (michael6) [#10029](https://github.com/nodejs/node/pull/10029) +* [[`6502427761`](https://github.com/nodejs/node/commit/6502427761)] - **test**: refactor test-require-exceptions (Oscar Martinez) [#9882](https://github.com/nodejs/node/pull/9882) +* [[`a801ffb1ee`](https://github.com/nodejs/node/commit/a801ffb1ee)] - **test**: refactor test-console (Matt Crummey) [#9873](https://github.com/nodejs/node/pull/9873) +* [[`bca587bdb3`](https://github.com/nodejs/node/commit/bca587bdb3)] - **test**: refactor test-crypto-certificate (Josh Mays) [#9911](https://github.com/nodejs/node/pull/9911) +* [[`278772a5df`](https://github.com/nodejs/node/commit/278772a5df)] - **test**: refactor dgram-send-multi-buffer-copy (Konstantin Likhter) [#9909](https://github.com/nodejs/node/pull/9909) +* [[`6d5ded508e`](https://github.com/nodejs/node/commit/6d5ded508e)] - **test**: refactor test-domain (Johnny Reading) [#9890](https://github.com/nodejs/node/pull/9890) +* [[`318a2dbea4`](https://github.com/nodejs/node/commit/318a2dbea4)] - **test**: refactor test-cli-syntax (Exlipse7) [#10057](https://github.com/nodejs/node/pull/10057) +* [[`da8e3d946a`](https://github.com/nodejs/node/commit/da8e3d946a)] - **test**: refactor test-child-process-constructor (k3kathy) [#10060](https://github.com/nodejs/node/pull/10060) +* [[`9fddf29f53`](https://github.com/nodejs/node/commit/9fddf29f53)] - **test**: refactor test-repl-mode.js (Cesar Hernandez) [#10061](https://github.com/nodejs/node/pull/10061) +* [[`65c44830c2`](https://github.com/nodejs/node/commit/65c44830c2)] - **test**: var to const, assert.equal to assert.strictEqual in net (Sean Villars) [#9907](https://github.com/nodejs/node/pull/9907) +* [[`ef7cbde0a2`](https://github.com/nodejs/node/commit/ef7cbde0a2)] - **test**: changed vars to const in test-net-better-error-messages-listen-path.js (anoff) [#9905](https://github.com/nodejs/node/pull/9905) +* [[`f62567b7f8`](https://github.com/nodejs/node/commit/f62567b7f8)] - **test**: use const instead of var in test-require-json.js (Sarah Meyer) [#9904](https://github.com/nodejs/node/pull/9904) +* [[`5f3f54d4bb`](https://github.com/nodejs/node/commit/5f3f54d4bb)] - **test**: refactor test-http-dns-error (Outsider) [#10062](https://github.com/nodejs/node/pull/10062) +* [[`ae2bf0a761`](https://github.com/nodejs/node/commit/ae2bf0a761)] - **test**: Changed assert.equal to assert.strictEqual (Daniel Pittman) [#9902](https://github.com/nodejs/node/pull/9902) +* [[`1eb581779d`](https://github.com/nodejs/node/commit/1eb581779d)] - **test**: refactor test-vm-syntax-error-stderr.js (Jay Brownlee) [#9900](https://github.com/nodejs/node/pull/9900) +* [[`c456ca3601`](https://github.com/nodejs/node/commit/c456ca3601)] - **test**: refactor test-tls-destroy-whilst-write (Chris Bystrek) [#10064](https://github.com/nodejs/node/pull/10064) +* [[`fd17ca7710`](https://github.com/nodejs/node/commit/fd17ca7710)] - **test**: refactor test-net-dns-custom-lookup (Kent.Fan) [#10071](https://github.com/nodejs/node/pull/10071) +* [[`cf3c635dba`](https://github.com/nodejs/node/commit/cf3c635dba)] - **test**: refactor test-https-truncate (davidmarkclements) [#10074](https://github.com/nodejs/node/pull/10074) +* [[`14c0388945`](https://github.com/nodejs/node/commit/14c0388945)] - **test**: refactor test-tls-server-verify (Hutson Betts) [#10076](https://github.com/nodejs/node/pull/10076) +* [[`36b8dd3b07`](https://github.com/nodejs/node/commit/36b8dd3b07)] - **test**: refactor test-crypto-padding.js (Konstantin Likhter) [#9971](https://github.com/nodejs/node/pull/9971) +* [[`38ec8e44fa`](https://github.com/nodejs/node/commit/38ec8e44fa)] - **test**: improve test for crypto padding (Julian Duque) [#9906](https://github.com/nodejs/node/pull/9906) +* [[`a771f2181c`](https://github.com/nodejs/node/commit/a771f2181c)] - **test**: use strictEqual in test-cli-eval-event.js (Richard Karmazin) [#9964](https://github.com/nodejs/node/pull/9964) +* [[`e1394eeb16`](https://github.com/nodejs/node/commit/e1394eeb16)] - **test**: refactor test-tls-friendly-error-message.js (Adrian Estrada) [#9967](https://github.com/nodejs/node/pull/9967) +* [[`69077a13bf`](https://github.com/nodejs/node/commit/69077a13bf)] - **test**: refactor test-fs-append-file.js (adelmann) [#10110](https://github.com/nodejs/node/pull/10110) +* [[`baa1accdb1`](https://github.com/nodejs/node/commit/baa1accdb1)] - **test**: assert.equal -> assert.strictEqual (davidmarkclements) [#10065](https://github.com/nodejs/node/pull/10065) +* [[`a34e19532c`](https://github.com/nodejs/node/commit/a34e19532c)] - **test**: refactor test-dgram-exclusive-implicit-bind (Cesar Hernandez) [#10066](https://github.com/nodejs/node/pull/10066) +* [[`d87926ae34`](https://github.com/nodejs/node/commit/d87926ae34)] - **test**: assert.equal -> assert.strictEqual (davidmarkclements) [#10067](https://github.com/nodejs/node/pull/10067) +* [[`c4902e44ad`](https://github.com/nodejs/node/commit/c4902e44ad)] - **test**: polish test-net-better-error-messages-listen (Hitesh Kanwathirtha) [#10087](https://github.com/nodejs/node/pull/10087) +* [[`9b9fe8c5ac`](https://github.com/nodejs/node/commit/9b9fe8c5ac)] - **test**: change var to const in test-tls-key-mismatch.js (bjdelro) [#9897](https://github.com/nodejs/node/pull/9897) +* [[`7697aee7da`](https://github.com/nodejs/node/commit/7697aee7da)] - **test**: use strictEqual in cwd-enoent (JDHarmon) [#10077](https://github.com/nodejs/node/pull/10077) +* [[`cdc2909882`](https://github.com/nodejs/node/commit/cdc2909882)] - **test**: refactor test-fs-read-stream-inherit.js (Jonathan Darling) [#9894](https://github.com/nodejs/node/pull/9894) +* [[`55b58baed1`](https://github.com/nodejs/node/commit/55b58baed1)] - **test**: use assert.strictEqual in test-crypto-ecb (Daniel Pittman) [#9980](https://github.com/nodejs/node/pull/9980) +* [[`e070588a8a`](https://github.com/nodejs/node/commit/e070588a8a)] - **test**: refactor test-child-process-stdio-inherit (Wes Tyler) [#9893](https://github.com/nodejs/node/pull/9893) +* [[`22b15f2ab6`](https://github.com/nodejs/node/commit/22b15f2ab6)] - **test**: change var to const for require and strict equality checks (Harish Tejwani) [#9892](https://github.com/nodejs/node/pull/9892) +* [[`2a8d29339d`](https://github.com/nodejs/node/commit/2a8d29339d)] - **test**: Update to const and use regex for assertions (Daniel Flores) [#9891](https://github.com/nodejs/node/pull/9891) +* [[`295eb5a3b6`](https://github.com/nodejs/node/commit/295eb5a3b6)] - **test**: swap var->const/let and equal->strictEqual (Peter Masucci) [#9888](https://github.com/nodejs/node/pull/9888) +* [[`57f060c495`](https://github.com/nodejs/node/commit/57f060c495)] - **test**: replace equal with strictEqual in crypto (Julian Duque) [#9886](https://github.com/nodejs/node/pull/9886) +* [[`3d35930b2c`](https://github.com/nodejs/node/commit/3d35930b2c)] - **test**: replace equal with strictEqual (Julian Duque) [#9879](https://github.com/nodejs/node/pull/9879) +* [[`13cc6a005b`](https://github.com/nodejs/node/commit/13cc6a005b)] - **test**: var to const/let in test-tls-set-ciphers (rajatk) [#9877](https://github.com/nodejs/node/pull/9877) +* [[`f3eb8b1bea`](https://github.com/nodejs/node/commit/f3eb8b1bea)] - **test**: refactor test-tls-timeout-server-2 (Devon Rifkin) [#9876](https://github.com/nodejs/node/pull/9876) +* [[`dc76a20474`](https://github.com/nodejs/node/commit/dc76a20474)] - **test**: Updating vars to const and tsl server test (Matt Webb) [#9874](https://github.com/nodejs/node/pull/9874) +* [[`63fafb8aca`](https://github.com/nodejs/node/commit/63fafb8aca)] - **test**: refactor test-crypto-hash-stream-pipe (Matt Wilson) [#10055](https://github.com/nodejs/node/pull/10055) +* [[`fb4b650159`](https://github.com/nodejs/node/commit/fb4b650159)] - **test**: crypto-hash-stream-pipe use strict equal (Mitchell Stoutin) [#9935](https://github.com/nodejs/node/pull/9935) +* [[`8f550df252`](https://github.com/nodejs/node/commit/8f550df252)] - **test**: refactor child-process-spawn-error (Johnny Reading) [#9951](https://github.com/nodejs/node/pull/9951) +* [[`b73f6b760f`](https://github.com/nodejs/node/commit/b73f6b760f)] - **test**: refactor test-child-process-spawn-error (stokingerl) [#9937](https://github.com/nodejs/node/pull/9937) +* [[`371ca03568`](https://github.com/nodejs/node/commit/371ca03568)] - **test**: refactor test-vm-static-this.js (David Bradford) [#9887](https://github.com/nodejs/node/pull/9887) +* [[`3e37673d5c`](https://github.com/nodejs/node/commit/3e37673d5c)] - **test**: refactor test-crypto-cipheriv-decipheriv (Aileen) [#10018](https://github.com/nodejs/node/pull/10018) +* [[`f76bb2adf8`](https://github.com/nodejs/node/commit/f76bb2adf8)] - **test**: refactor test for crypto cipher/decipher iv (Julian Duque) [#9943](https://github.com/nodejs/node/pull/9943) +* [[`4cc813d8b9`](https://github.com/nodejs/node/commit/4cc813d8b9)] - **test**: refactor test-cluster-setup-master-argv (Oscar Martinez) [#9960](https://github.com/nodejs/node/pull/9960) +* [[`eb0c1cd412`](https://github.com/nodejs/node/commit/eb0c1cd412)] - **test**: refactor test-cluster-setup-master-argv (Christine Hong) [#9993](https://github.com/nodejs/node/pull/9993) +* [[`d2e89272d2`](https://github.com/nodejs/node/commit/d2e89272d2)] - **test**: refactor test-fs-append-file-sync (Chris Bystrek) [#10056](https://github.com/nodejs/node/pull/10056) +* [[`070370fd0a`](https://github.com/nodejs/node/commit/070370fd0a)] - **test**: refactor test-fs-append-file-sync (Ian White) [#9977](https://github.com/nodejs/node/pull/9977) +* [[`87038bb628`](https://github.com/nodejs/node/commit/87038bb628)] - **test**: refactor test-fs-write-file (adelmann) [#10030](https://github.com/nodejs/node/pull/10030) +* [[`1f6f411234`](https://github.com/nodejs/node/commit/1f6f411234)] - **test**: refactor test/parallel/test-fs-write-file.js (Kyle Carter) [#9992](https://github.com/nodejs/node/pull/9992) +* [[`4cb52ee827`](https://github.com/nodejs/node/commit/4cb52ee827)] - **test**: update to const iin cluster test (Greg Valdez) [#10007](https://github.com/nodejs/node/pull/10007) +* [[`f9d79ef597`](https://github.com/nodejs/node/commit/f9d79ef597)] - **test**: use assert.strictEqual() cluster test (Bidur Adhikari) [#10042](https://github.com/nodejs/node/pull/10042) +* [[`b4ec7d6c50`](https://github.com/nodejs/node/commit/b4ec7d6c50)] - **test**: use const in test-crypto-pbkdf2 (Greg Valdez) [#9974](https://github.com/nodejs/node/pull/9974) +* [[`2e889cf056`](https://github.com/nodejs/node/commit/2e889cf056)] - **test**: improve test for crypto pbkdf2 (joyeecheung) [#9883](https://github.com/nodejs/node/pull/9883) +* [[`c0a28622ce`](https://github.com/nodejs/node/commit/c0a28622ce)] - **test**: var -> let/const, .equal -> .strictEqual (shiya) [#9913](https://github.com/nodejs/node/pull/9913) +* [[`d1da89906d`](https://github.com/nodejs/node/commit/d1da89906d)] - **test**: increase coverage for timers (lrlna) [#10068](https://github.com/nodejs/node/pull/10068) +* [[`44d9bc8b90`](https://github.com/nodejs/node/commit/44d9bc8b90)] - **test**: change equal to strictEqual (Kevin Zurawel) [#9872](https://github.com/nodejs/node/pull/9872) +* [[`0cab6eb6ca`](https://github.com/nodejs/node/commit/0cab6eb6ca)] - **test**: test for http.request() invalid method error (Ashton Kinslow) [#10080](https://github.com/nodejs/node/pull/10080) +* [[`f9386f2846`](https://github.com/nodejs/node/commit/f9386f2846)] - **test**: update net-local-address-port (scalkpdev) [#9885](https://github.com/nodejs/node/pull/9885) +* [[`66554c75d5`](https://github.com/nodejs/node/commit/66554c75d5)] - **test**: refactor test-tls-ecdh (Adriana Rios) [#9878](https://github.com/nodejs/node/pull/9878) +* [[`a857c9a74c`](https://github.com/nodejs/node/commit/a857c9a74c)] - **test**: refactor test-vm-debug-context (makenova) [#9875](https://github.com/nodejs/node/pull/9875) +* [[`a6377a96dd`](https://github.com/nodejs/node/commit/a6377a96dd)] - **test**: increase coverage for lib/events.js (Safia Abdalla) [#9865](https://github.com/nodejs/node/pull/9865) +* [[`eb369f6d48`](https://github.com/nodejs/node/commit/eb369f6d48)] - **test**: use strictEqual in test-zlib-truncated (ben_cripps) [#9858](https://github.com/nodejs/node/pull/9858) +* [[`3af4ef4642`](https://github.com/nodejs/node/commit/3af4ef4642)] - **test**: use strictEqual in test-debugger-client.js (ben_cripps) [#9857](https://github.com/nodejs/node/pull/9857) +* [[`5c15a68091`](https://github.com/nodejs/node/commit/5c15a68091)] - **test**: refactor test-debug-args (Rich Trott) [#9833](https://github.com/nodejs/node/pull/9833) +* [[`0e36becd39`](https://github.com/nodejs/node/commit/0e36becd39)] - **test**: refactor test-fs-non-number-arguments-throw (Michaël Zasso) [#9844](https://github.com/nodejs/node/pull/9844) +* [[`c286312ef5`](https://github.com/nodejs/node/commit/c286312ef5)] - **test**: replace assert.equal with assert.strictEqual (brad-decker) [#9842](https://github.com/nodejs/node/pull/9842) +* [[`0ccb2c3992`](https://github.com/nodejs/node/commit/0ccb2c3992)] - **test**: refactor test-crypto-timing-safe-equal (Michaël Zasso) [#9843](https://github.com/nodejs/node/pull/9843) +* [[`0bdd5ca0f7`](https://github.com/nodejs/node/commit/0bdd5ca0f7)] - **test**: run cpplint on files in test/cctest (Ben Noordhuis) [#9787](https://github.com/nodejs/node/pull/9787) +* [[`956239124d`](https://github.com/nodejs/node/commit/956239124d)] - **test**: add toASCII and toUnicode punycode tests (Claudio Rodriguez) [#9741](https://github.com/nodejs/node/pull/9741) +* [[`70633f965d`](https://github.com/nodejs/node/commit/70633f965d)] - **test**: refactor test-util-inspect (Rich Trott) [#9804](https://github.com/nodejs/node/pull/9804) +* [[`4c2ad8c89f`](https://github.com/nodejs/node/commit/4c2ad8c89f)] - **test**: refactor test-preload (Rich Trott) [#9803](https://github.com/nodejs/node/pull/9803) +* [[`59aec82f88`](https://github.com/nodejs/node/commit/59aec82f88)] - **test**: refine test-http-status-reason-invalid-chars (Rich Trott) [#9802](https://github.com/nodejs/node/pull/9802) +* [[`c35bf44f60`](https://github.com/nodejs/node/commit/c35bf44f60)] - **test**: refactor test-crypto-binary-default (Michaël Zasso) [#9810](https://github.com/nodejs/node/pull/9810) +* [[`4d1e11243b`](https://github.com/nodejs/node/commit/4d1e11243b)] - **test**: refactor and fix test-crypto (Michaël Zasso) [#9807](https://github.com/nodejs/node/pull/9807) +* [[`74c3283cfa`](https://github.com/nodejs/node/commit/74c3283cfa)] - **test**: fix test-buffer-slow (Michaël Zasso) [#9809](https://github.com/nodejs/node/pull/9809) +* [[`e2db5c8e7a`](https://github.com/nodejs/node/commit/e2db5c8e7a)] - **test**: refactor test-net-pingpong (Michaël Zasso) [#9812](https://github.com/nodejs/node/pull/9812) +* [[`cd10e1ae4a`](https://github.com/nodejs/node/commit/cd10e1ae4a)] - **test**: refactor and fix test-dns (Michaël Zasso) [#9811](https://github.com/nodejs/node/pull/9811) +* [[`dcba25082f`](https://github.com/nodejs/node/commit/dcba25082f)] - **test**: refactor and fix test-buffer-bytelength (Michaël Zasso) [#9808](https://github.com/nodejs/node/pull/9808) +* [[`d06f010482`](https://github.com/nodejs/node/commit/d06f010482)] - **test**: cleanup test-dgram-error-message-address (Michael Macherey) [#8938](https://github.com/nodejs/node/pull/8938) +* [[`3b193defb2`](https://github.com/nodejs/node/commit/3b193defb2)] - **test**: fix flaky test-cluster-dgram-2 (Rich Trott) [#9791](https://github.com/nodejs/node/pull/9791) +* [[`3f1b068644`](https://github.com/nodejs/node/commit/3f1b068644)] - **test**: refactor common.js (Rich Trott) [#9732](https://github.com/nodejs/node/pull/9732) +* [[`d31a41149d`](https://github.com/nodejs/node/commit/d31a41149d)] - **test**: fix test-tls-connect-address-family (mkamakura) [#9573](https://github.com/nodejs/node/pull/9573) +* [[`d51c856f11`](https://github.com/nodejs/node/commit/d51c856f11)] - **test**: fix test-http-status-reason-invalid-chars (Yosuke Saito) [#9572](https://github.com/nodejs/node/pull/9572) +* [[`b763a31af0`](https://github.com/nodejs/node/commit/b763a31af0)] - **test**: refactor test-child-process-exec-error (Rich Trott) [#9780](https://github.com/nodejs/node/pull/9780) +* [[`2b7ecb5012`](https://github.com/nodejs/node/commit/2b7ecb5012)] - **test**: exclude no_interleaved_stdio test for AIX (Michael Dawson) [#9772](https://github.com/nodejs/node/pull/9772) +* [[`4971c3bb79`](https://github.com/nodejs/node/commit/4971c3bb79)] - **test**: fix flaky test-dgram-empty-packet & friends (Rich Trott) [#9724](https://github.com/nodejs/node/pull/9724) +* [[`2fb825750d`](https://github.com/nodejs/node/commit/2fb825750d)] - **test**: fix flaky test-inspector (Rich Trott) [#9727](https://github.com/nodejs/node/pull/9727) +* [[`fc13cc6a12`](https://github.com/nodejs/node/commit/fc13cc6a12)] - **test**: refactor test-tls-hello-parser-failure (Rich Trott) [#9715](https://github.com/nodejs/node/pull/9715) +* [[`ea1c4e1212`](https://github.com/nodejs/node/commit/ea1c4e1212)] - **test,url**: improve escaping in url.parse (joyeecheung) [#10083](https://github.com/nodejs/node/pull/10083) +* [[`64854f625b`](https://github.com/nodejs/node/commit/64854f625b)] - **tools**: add ESLint rule for assert.throws arguments (Michaël Zasso) [#10089](https://github.com/nodejs/node/pull/10089) +* [[`2ee3543e04`](https://github.com/nodejs/node/commit/2ee3543e04)] - **tools**: remove unneeded escaping in generate.js (Rich Trott) [#9781](https://github.com/nodejs/node/pull/9781) +* [[`53d175267c`](https://github.com/nodejs/node/commit/53d175267c)] - **tools**: Add no useless regex char class rule (Prince J Wesley) [#9591](https://github.com/nodejs/node/pull/9591) +* [[`561b1494bc`](https://github.com/nodejs/node/commit/561b1494bc)] - **tools**: allow test.py to use full paths of tests (Francis Gulotta) [#9694](https://github.com/nodejs/node/pull/9694) +* [[`5ae549c3aa`](https://github.com/nodejs/node/commit/5ae549c3aa)] - **url**: fix -Warray-bounds warning (Santiago Gimeno) [#9751](https://github.com/nodejs/node/pull/9751) + ## 2016-11-22, Version 7.2.0 (Current), @Fishrock123 diff --git a/src/node_version.h b/src/node_version.h index 11ad14764f8f90..a77441cade4d58 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -5,7 +5,7 @@ #define NODE_MINOR_VERSION 2 #define NODE_PATCH_VERSION 1 -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From c2cc11b3c65b40ca8114e89404c87256a241302a Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 6 Dec 2016 17:35:22 -0500 Subject: [PATCH 195/195] Working on v7.2.2 PR-URL: https://github.com/nodejs/node/pull/10127 --- src/node_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_version.h b/src/node_version.h index a77441cade4d58..31ac3fac814e85 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -3,9 +3,9 @@ #define NODE_MAJOR_VERSION 7 #define NODE_MINOR_VERSION 2 -#define NODE_PATCH_VERSION 1 +#define NODE_PATCH_VERSION 2 -#define NODE_VERSION_IS_RELEASE 1 +#define NODE_VERSION_IS_RELEASE 0 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)