mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: run code cache test by default and test generator
- Add the code cache tests to the default test suite, and test the bookkeeping when the binary is not built with the code cache. - Test the code cache generator to make sure we do not accidentally break it - until we enable code cache in the CI. Refs: https://github.com/nodejs/node/issues/21563 PR-URL: https://github.com/nodejs/node/pull/23855 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
1841d0f776
commit
c5577c17ac
3 files changed
+88
-17
No files matched your search
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
// Flags: --expose-internals
|
||||
// This test verifies that the binary is compiled with code cache and the
|
||||
// cache is used when built in modules are compiled.
|
||||
// This test verifies that if the binary is compiled with code cache,
|
||||
// and the cache is used when built in modules are compiled.
|
||||
// Otherwise, verifies that no cache is used when compiling builtins.
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
@@ -18,23 +19,36 @@ const {
|
||||
compiledWithoutCache
|
||||
} = require('internal/bootstrap/cache');
|
||||
|
||||
assert.strictEqual(
|
||||
typeof process.config.variables.node_code_cache_path,
|
||||
'string'
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(compiledWithoutCache, []);
|
||||
|
||||
const loadedModules = process.moduleLoadList
|
||||
.filter((m) => m.startsWith('NativeModule'))
|
||||
.map((m) => m.replace('NativeModule ', ''));
|
||||
|
||||
for (const key of loadedModules) {
|
||||
assert(compiledWithCache.includes(key),
|
||||
`"${key}" should've been compiled with code cache`);
|
||||
}
|
||||
// The binary is not configured with code cache, verifies that the builtins
|
||||
// are all compiled without cache and we are doing the bookkeeping right.
|
||||
if (process.config.variables.node_code_cache_path === undefined) {
|
||||
assert.deepStrictEqual(compiledWithCache, []);
|
||||
assert.notStrictEqual(compiledWithoutCache.length, 0);
|
||||
|
||||
for (const key of cachableBuiltins) {
|
||||
assert(isUint8Array(codeCache[key]) && codeCache[key].length > 0,
|
||||
`Code cache for "${key}" should've been generated`);
|
||||
for (const key of loadedModules) {
|
||||
assert(compiledWithoutCache.includes(key),
|
||||
`"${key}" should not have been compiled with code cache`);
|
||||
}
|
||||
|
||||
} else {
|
||||
// The binary is configured with code cache.
|
||||
assert.strictEqual(
|
||||
typeof process.config.variables.node_code_cache_path,
|
||||
'string'
|
||||
);
|
||||
assert.deepStrictEqual(compiledWithoutCache, []);
|
||||
|
||||
for (const key of loadedModules) {
|
||||
assert(compiledWithCache.includes(key),
|
||||
`"${key}" should've been compiled with code cache`);
|
||||
}
|
||||
|
||||
for (const key of cachableBuiltins) {
|
||||
assert(isUint8Array(codeCache[key]) && codeCache[key].length > 0,
|
||||
`Code cache for "${key}" should've been generated`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user