From 216e72d0f977afb83fd5b1bf8968ca90308b1dc8 Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 18 Aug 2020 14:14:16 -0700 Subject: [PATCH] [7.9] [src/dev/build] remove node-version from snapshots (#75303) (#75359) Co-authored-by: spalger --- .../nodejs/extract_node_builds_task.test.ts | 29 ++++++++++++++----- .../verify_existing_node_builds_task.test.ts | 15 +++++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts index f1700ef7b578c..a5b9e01714f38 100644 --- a/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts @@ -17,10 +17,15 @@ * under the License. */ +import { readFileSync } from 'fs'; +import Path from 'path'; + import { ToolingLog, ToolingLogCollectingWriter, createAbsolutePathSerializer, + createRecursiveSerializer, + REPO_ROOT, } from '@kbn/dev-utils'; import { Config } from '../../lib'; @@ -37,6 +42,14 @@ log.setWriters([testWriter]); expect.addSnapshotSerializer(createAbsolutePathSerializer()); +const nodeVersion = readFileSync(Path.resolve(REPO_ROOT, '.node-version'), 'utf8').trim(); +expect.addSnapshotSerializer( + createRecursiveSerializer( + (s) => typeof s === 'string' && s.includes(nodeVersion), + (s) => s.split(nodeVersion).join('') + ) +); + async function setup() { const config = await Config.create({ isRelease: true, @@ -74,8 +87,8 @@ it('runs expected fs operations', async () => { Object { "copy": Array [ Array [ - /.node_binaries/10.21.0/node.exe, - /.node_binaries/10.21.0/win32-x64/node.exe, + /.node_binaries//node.exe, + /.node_binaries//win32-x64/node.exe, Object { "clone": true, }, @@ -83,22 +96,22 @@ it('runs expected fs operations', async () => { ], "untar": Array [ Array [ - /.node_binaries/10.21.0/node-v10.21.0-linux-x64.tar.gz, - /.node_binaries/10.21.0/linux-x64, + /.node_binaries//node-v-linux-x64.tar.gz, + /.node_binaries//linux-x64, Object { "strip": 1, }, ], Array [ - /.node_binaries/10.21.0/node-v10.21.0-linux-arm64.tar.gz, - /.node_binaries/10.21.0/linux-arm64, + /.node_binaries//node-v-linux-arm64.tar.gz, + /.node_binaries//linux-arm64, Object { "strip": 1, }, ], Array [ - /.node_binaries/10.21.0/node-v10.21.0-darwin-x64.tar.gz, - /.node_binaries/10.21.0/darwin-x64, + /.node_binaries//node-v-darwin-x64.tar.gz, + /.node_binaries//darwin-x64, Object { "strip": 1, }, diff --git a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts index 19416963d5edd..1a850890a33fe 100644 --- a/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts +++ b/src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts @@ -17,10 +17,15 @@ * under the License. */ +import Path from 'path'; +import Fs from 'fs'; + import { ToolingLog, ToolingLogCollectingWriter, createAnyInstanceSerializer, + createRecursiveSerializer, + REPO_ROOT, } from '@kbn/dev-utils'; import { Config, Platform } from '../../lib'; @@ -41,6 +46,14 @@ log.setWriters([testWriter]); expect.addSnapshotSerializer(createAnyInstanceSerializer(Config)); +const nodeVersion = Fs.readFileSync(Path.resolve(REPO_ROOT, '.node-version'), 'utf8').trim(); +expect.addSnapshotSerializer( + createRecursiveSerializer( + (s) => typeof s === 'string' && s.includes(nodeVersion), + (s) => s.split(nodeVersion).join('') + ) +); + async function setup(actualShaSums?: Record) { const config = await Config.create({ isRelease: true, @@ -87,7 +100,7 @@ it('checks shasums for each downloaded node build', async () => { [MockFunction] { "calls": Array [ Array [ - "10.21.0", + "", ], ], "results": Array [