From 24b6d15b70780f891027e1863a5c05ae11e5c5b8 Mon Sep 17 00:00:00 2001 From: hyj1991 Date: Fri, 17 Jan 2020 11:37:43 +0800 Subject: [PATCH] fix: ci error with node-v13.6.0 on windows (#46) Ref: https://github.com/nodejs/node/pull/30556 PR-URL: https://github.com/hyj1991/xprofiler/pull/46 Reviewed-BY: hyj1991 --- lib/xctl.js | 4 ++-- src/logger.cc | 1 - test/logbypass.test.js | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/xctl.js b/lib/xctl.js index 5d4f9dc..3677600 100644 --- a/lib/xctl.js +++ b/lib/xctl.js @@ -101,8 +101,8 @@ async function createMessageConnection(pid, xprofilerPath, message) { message = JSON.stringify(message); - /* istanbul ignore if */ - if (!fs.existsSync(xprofilerPath)) { + /* istanbul ignore next */ + if (os.platform() !== 'win32' && !fs.existsSync(xprofilerPath)) { throw new Error(`进程 ${pid} 不存在或者没有启动 xprofiler 信令线程!`); } diff --git a/src/logger.cc b/src/logger.cc index 9308040..725a2c4 100644 --- a/src/logger.cc +++ b/src/logger.cc @@ -25,7 +25,6 @@ using v8::String; uv_mutex_lock(&logger_mutex); \ type##_stream.open(filepath, std::ios::app); \ type##_stream << log; \ - type##_stream.flush(); \ type##_stream.close(); \ uv_mutex_unlock(&logger_mutex); diff --git a/test/logbypass.test.js b/test/logbypass.test.js index 992e1a6..eeccf77 100644 --- a/test/logbypass.test.js +++ b/test/logbypass.test.js @@ -10,12 +10,21 @@ const getTestCases = require('./fixtures/logbypass.test'); const logdirBlocking = utils.createLogDir('log_bypass_blocking'); const logdirNonBlocking = utils.createLogDir('log_bypass_non_blocking'); +// common cases let cases = getTestCases('performance log correctly', logdirBlocking, logdirNonBlocking); + +// libuv cases +const logdirBlockingForUv = utils.createLogDir('log_bypass_blocking_uv'); +const logdirNonBlockingForUv = utils.createLogDir('log_bypass_non_blocking_uv'); const casesForLibuv = getTestCases('performance log correctly with XPROFILER_ENABLE_LOG_UV_HANDLES=NO', - logdirBlocking, logdirNonBlocking, { XPROFILER_ENABLE_LOG_UV_HANDLES: 'NO' }, + logdirBlockingForUv, logdirNonBlockingForUv, { XPROFILER_ENABLE_LOG_UV_HANDLES: 'NO' }, { uv: getTestCases.getUvRules(['active_handles']) }); + +// http cases +const logdirBlockingForHttp = utils.createLogDir('log_bypass_blocking_http'); +const logdirNonBlockingForHttp = utils.createLogDir('log_bypass_non_blocking_http'); const casesForHttp = getTestCases('performance log correctly XPROFILER_PATCH_HTTP=YES', - logdirBlocking, logdirNonBlocking, { XPROFILER_PATCH_HTTP: 'YES' }, + logdirBlockingForHttp, logdirNonBlockingForHttp, { XPROFILER_PATCH_HTTP: 'YES' }, { http: { live_http_request: /^\d+$/, @@ -24,6 +33,8 @@ const casesForHttp = getTestCases('performance log correctly XPROFILER_PATCH_HT http_rt: /^\d+.\d{2}$/ } }); + +// compose cases cases = cases.concat(casesForLibuv).concat(casesForHttp); function parseLog(logType, content, patt, alinode) { @@ -76,6 +87,10 @@ for (const testCase of cases) { if (testCase.targets.indexOf(target) === testCase.targets.length - 1) { utils.cleanDir(logdirBlocking); utils.cleanDir(logdirNonBlocking); + utils.cleanDir(logdirBlockingForUv); + utils.cleanDir(logdirNonBlockingForUv); + utils.cleanDir(logdirBlockingForHttp); + utils.cleanDir(logdirNonBlockingForHttp); } } });