mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
module: skip NODE_COMPILE_CACHE when policy is enabled
It might be worth designing a policy for the compilation cache. For now, just skip the cache when policy is enabled. PR-URL: https://github.com/nodejs/node/pull/52577 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
@@ -1096,6 +1096,12 @@ void Environment::InitializeCompileCache() {
|
||||
dir_from_env.empty()) {
|
||||
return;
|
||||
}
|
||||
if (!options()->experimental_policy.empty()) {
|
||||
Debug(this,
|
||||
DebugCategory::COMPILE_CACHE,
|
||||
"[compile cache] skipping cache because policy is enabled");
|
||||
return;
|
||||
}
|
||||
auto handler = std::make_unique<CompileCacheHandler>(this);
|
||||
if (handler->InitializeDirectory(this, dir_from_env)) {
|
||||
compile_cache_handler_ = std::move(handler);
|
||||
|
||||
38
test/parallel/test-compile-cache-policy.js
Normal file
38
test/parallel/test-compile-cache-policy.js
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
// This tests NODE_COMPILE_CACHE is disabled when policy is used.
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const { spawnSyncAndAssert } = require('../common/child_process');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const tmpdir = require('../common/tmpdir');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
{
|
||||
tmpdir.refresh();
|
||||
const dir = tmpdir.resolve('.compile_cache_dir');
|
||||
const script = fixtures.path('policy', 'parent.js');
|
||||
const policy = fixtures.path(
|
||||
'policy',
|
||||
'dependencies',
|
||||
'dependencies-redirect-policy.json');
|
||||
spawnSyncAndAssert(
|
||||
process.execPath,
|
||||
['--experimental-policy', policy, script],
|
||||
{
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_DEBUG_NATIVE: 'COMPILE_CACHE',
|
||||
NODE_COMPILE_CACHE: dir
|
||||
},
|
||||
cwd: tmpdir.path
|
||||
},
|
||||
{
|
||||
stderr: /skipping cache because policy is enabled/
|
||||
});
|
||||
assert(!fs.existsSync(dir));
|
||||
}
|
||||
Reference in New Issue
Block a user