mirror of
https://github.com/whyour/qinglong.git
synced 2026-10-01 05:13:50 +08:00
fix: reduce task startup overhead and lazy-load notifications (#3080)
This commit is contained in:
@@ -65,6 +65,35 @@ test('config, environment, cwd, and executable changes invalidate discovery', (t
|
||||
f.run();
|
||||
assert.equal(f.count(), before + 1);
|
||||
});
|
||||
test('alternating Node/crond working directories retain independent cached roots', (t) => {
|
||||
const f = fixture(t);
|
||||
fs.mkdirSync(path.join(f.root, 'child'));
|
||||
fs.writeFileSync(path.join(f.root, 'child', '.npmrc'), 'global-dir=/child\n');
|
||||
for (let i = 0; i < 4; i++) {
|
||||
assert.equal(f.run({ ANSWER: '/parent/modules' }).stdout.trim(), '/parent/modules');
|
||||
assert.equal(
|
||||
f.run({ ANSWER: '/child/modules' }, 'cd child; ' + f.command).stdout.trim(),
|
||||
'/child/modules',
|
||||
);
|
||||
}
|
||||
assert.equal(f.count(), 2, 'each working directory should discover only once');
|
||||
assert.equal(fs.readdirSync(f.env.dir_tmp).filter((x) => x.endsWith('.cache')).length, 2);
|
||||
});
|
||||
test('refresh retires old per-environment records without removing locks or unrelated files', (t) => {
|
||||
const f = fixture(t);
|
||||
fs.mkdirSync(f.env.dir_tmp);
|
||||
const prefix = `pnpm-root-${process.getuid()}`;
|
||||
const names = [`${prefix}-1-2.cache`, `${prefix}.lock`, 'unrelated.cache'];
|
||||
const old = new Date(Date.now() - 2 * 60 * 60 * 1000);
|
||||
for (const name of names) {
|
||||
const file = path.join(f.env.dir_tmp, name);
|
||||
fs.writeFileSync(file, '');
|
||||
fs.utimesSync(file, old, old);
|
||||
}
|
||||
assert.equal(f.run().status, 0);
|
||||
assert.equal(fs.existsSync(path.join(f.env.dir_tmp, names[0])), false);
|
||||
for (const name of names.slice(1)) assert.ok(fs.existsSync(path.join(f.env.dir_tmp, name)));
|
||||
});
|
||||
test('expired or malformed records refresh and failed lookups are not cached', (t) => {
|
||||
const f = fixture(t);
|
||||
f.run();
|
||||
|
||||
Reference in New Issue
Block a user