From 1c9ba2cdc3634896b47ec218083a3561f8d923b4 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 22 Nov 2019 19:19:53 -0500 Subject: [PATCH] test: test for minimum ICU version consistency The minimum ICU version for Node.js must be at least the minimum ICU version for V8. PR-URL: https://github.com/nodejs/node/pull/30608 Refs: https://github.com/nodejs/node/pull/30607 Reviewed-By: Steven R Loomis Reviewed-By: Anna Henningsen Reviewed-By: Jiawen Geng Reviewed-By: Colin Ihrig --- test/parallel/test-icu-minimum-version.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/parallel/test-icu-minimum-version.js diff --git a/test/parallel/test-icu-minimum-version.js b/test/parallel/test-icu-minimum-version.js new file mode 100644 index 00000000000000..3daafc364ae55f --- /dev/null +++ b/test/parallel/test-icu-minimum-version.js @@ -0,0 +1,20 @@ +'use strict'; + +// Tests that the minimum ICU version for Node.js is at least the minimum ICU +// version for V8. + +require('../common'); +const assert = require('assert'); +const path = require('path'); +const { readFileSync } = require('fs'); + +const srcRoot = path.join(__dirname, '..', '..'); +const icuVersionsFile = path.join(srcRoot, 'tools', 'icu', 'icu_versions.json'); +const { minimum_icu: minimumICU } = require(icuVersionsFile); +const v8SrcFile = path.join(srcRoot, + 'deps', 'v8', 'src', 'objects', 'intl-objects.h'); +const v8Src = readFileSync(v8SrcFile, { encoding: 'utf8' }); +const v8MinimumICU = v8Src.match(/#define\s+V8_MINIMUM_ICU_VERSION\s+(\d+)/)[1]; +assert.ok(minimumICU >= Number(v8MinimumICU), + `minimum ICU version in ${icuVersionsFile} (${minimumICU}) ` + + `must be at least that in ${v8SrcFile} (${Number(v8MinimumICU)})`);