From 27c49a348d22cef4ed766d170e07b660778b7893 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Thu, 12 May 2022 00:13:03 -0700 Subject: [PATCH 1/3] extract `colorize` function into separate file --- packages/node/test/manual/colorize.js | 16 ++++++++++++++++ .../node/test/manual/release-health/runner.js | 16 +--------------- 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 packages/node/test/manual/colorize.js diff --git a/packages/node/test/manual/colorize.js b/packages/node/test/manual/colorize.js new file mode 100644 index 000000000000..632d20aba4f7 --- /dev/null +++ b/packages/node/test/manual/colorize.js @@ -0,0 +1,16 @@ +const COLOR_RESET = '\x1b[0m'; +const COLORS = { + green: '\x1b[32m', + red: '\x1b[31m', + yellow: '\x1b[33m', +}; + +function colorize(str, color) { + if (!(color in COLORS)) { + throw new Error(`Unknown color. Available colors: ${Object.keys(COLORS).join(', ')}`); + } + + return `${COLORS[color]}${str}${COLOR_RESET}`; +} + +module.exports = { colorize }; diff --git a/packages/node/test/manual/release-health/runner.js b/packages/node/test/manual/release-health/runner.js index ecbcf7fe15bc..c8ecab182859 100644 --- a/packages/node/test/manual/release-health/runner.js +++ b/packages/node/test/manual/release-health/runner.js @@ -1,21 +1,7 @@ const fs = require('fs'); const path = require('path'); const { spawn } = require('child_process'); - -const COLOR_RESET = '\x1b[0m'; -const COLORS = { - green: '\x1b[32m', - red: '\x1b[31m', - yellow: '\x1b[33m', -}; - -const colorize = (str, color) => { - if (!(color in COLORS)) { - throw new Error(`Unknown color. Available colors: ${Object.keys(COLORS).join(', ')}`); - } - - return `${COLORS[color]}${str}${COLOR_RESET}`; -}; +const { colorize } = require('../colorize'); const scenariosDirs = ['session-aggregates', 'single-session']; const scenarios = []; From 7a4fcd6b7371d4a8ed152ef7a4f59c31f96af3b9 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Thu, 12 May 2022 00:13:35 -0700 Subject: [PATCH 2/3] pipe console logs through to terminal in express test --- packages/node/test/manual/webpack-domain/npm-build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/test/manual/webpack-domain/npm-build.js b/packages/node/test/manual/webpack-domain/npm-build.js index 923d437212c5..cf01a15d6ef1 100644 --- a/packages/node/test/manual/webpack-domain/npm-build.js +++ b/packages/node/test/manual/webpack-domain/npm-build.js @@ -39,7 +39,7 @@ webpack( function runTests() { try { - execSync('node ' + path.resolve(__dirname, 'dist', 'bundle.js')); + execSync('node ' + path.resolve(__dirname, 'dist', 'bundle.js'), { stdio: 'inherit' }); } catch (_) { process.exit(1); } From 42c5ac33ac5aa067806fc288212f770b2009443a Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Thu, 12 May 2022 00:14:26 -0700 Subject: [PATCH 3/3] apply `colorize` to logs from other manual tests --- .../node/test/manual/express-scope-separation/start.js | 5 +++-- packages/node/test/manual/webpack-domain/index.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/node/test/manual/express-scope-separation/start.js b/packages/node/test/manual/express-scope-separation/start.js index faf7b381ecbc..b85d68c7b1f8 100644 --- a/packages/node/test/manual/express-scope-separation/start.js +++ b/packages/node/test/manual/express-scope-separation/start.js @@ -2,13 +2,14 @@ const http = require('http'); const express = require('express'); const app = express(); const Sentry = require('../../../build/cjs'); +const { colorize } = require('../colorize'); // don't log the test errors we're going to throw, so at a quick glance it doesn't look like the test itself has failed global.console.error = () => null; function assertTags(actual, expected) { if (JSON.stringify(actual) !== JSON.stringify(expected)) { - console.error('FAILED: Scope contains incorrect tags'); + console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red')); process.exit(1); } } @@ -20,7 +21,7 @@ function makeDummyTransport() { --remaining; if (!remaining) { - console.error('SUCCESS: All scopes contain correct tags'); + console.log(colorize('PASSED: All scopes contain correct tags\n', 'green')); server.close(); process.exit(0); } diff --git a/packages/node/test/manual/webpack-domain/index.js b/packages/node/test/manual/webpack-domain/index.js index 09ed18f3166f..5d3968106bab 100644 --- a/packages/node/test/manual/webpack-domain/index.js +++ b/packages/node/test/manual/webpack-domain/index.js @@ -1,4 +1,5 @@ const Sentry = require('../../../build/cjs'); +const { colorize } = require('../colorize'); let remaining = 2; @@ -7,7 +8,7 @@ function makeDummyTransport() { --remaining; if (!remaining) { - console.error('SUCCESS: Webpack Node Domain test OK!'); + console.log(colorize('PASSED: Webpack Node Domain test OK!\n', 'green')); process.exit(0); } @@ -23,13 +24,13 @@ Sentry.init({ beforeSend(event) { if (event.message === 'inside') { if (event.tags.a !== 'x' && event.tags.b !== 'c') { - console.error('FAILED: Scope contains incorrect tags'); + console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red')); process.exit(1); } } if (event.message === 'outside') { if (event.tags.a !== 'b') { - console.error('FAILED: Scope contains incorrect tags'); + console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red')); process.exit(1); } }