mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 08:22:20 +02:00
test: handle empty npm optional Codex slots in consumer verification
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
6cbf7e4b65
commit
854d7e1bef
2 files changed
+25
-2
No files matched your search
@@ -93,6 +93,17 @@ test('the installed Codex probe exercises the public export and rejects incomple
|
||||
assert.equal(JSON.parse(result.stdout).codexCommandLeaseVerified, true);
|
||||
assert.equal(readFileSync(join(server, 'lease-closed'), 'utf8'), 'ok');
|
||||
assert.equal(JSON.parse(result.stdout).providerCalls, 0);
|
||||
const emptySlot = join(server, 'node_modules/@openai/codex-' + target);
|
||||
mkdirSync(emptySlot, { recursive: true });
|
||||
result = run(); assert.equal(result.status, 0, result.stderr);
|
||||
assert.equal(JSON.parse(result.stdout).codexPlatformPackages.length, 1,
|
||||
'An empty nested npm optional slot must not obscure the qualified hoisted host package');
|
||||
writeFileSync(join(emptySlot, 'undeclared-native-payload'), 'native fixture; never executed');
|
||||
result = run(); assert.notEqual(result.status, 0); assert.match(result.stderr, /empty regular directory; found.*undeclared-native-payload/);
|
||||
rmSync(join(emptySlot, 'undeclared-native-payload'));
|
||||
writeFileSync(join(emptySlot, 'package.json'), '{ malformed');
|
||||
result = run(); assert.notEqual(result.status, 0); assert.match(result.stderr, /SyntaxError/);
|
||||
rmSync(join(emptySlot, 'package.json'));
|
||||
writeFileSync(integrity, moduleSource.replace('assert.deepEqual(profile,', "throw new Error('qualified executable digest mismatch'); assert.deepEqual(profile,"));
|
||||
result = run(); assert.notEqual(result.status, 0); assert.match(result.stderr, /qualified executable digest mismatch/);
|
||||
writeFileSync(integrity, moduleSource.replace("writeFileSync(", "throw new Error('command lease close failed'); writeFileSync("));
|
||||
|
||||
@@ -63,7 +63,7 @@ export function installedCodexProbeSource(indexPath, consumerRoot, expectedVersi
|
||||
import assert from 'node:assert/strict';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { createRequire } from 'node:module';
|
||||
import { accessSync, constants, existsSync, readFileSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
||||
import { accessSync, constants, existsSync, lstatSync, readFileSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
||||
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
const root = realpathSync(${JSON.stringify(consumerRoot)});
|
||||
@@ -83,7 +83,19 @@ export function installedCodexProbeSource(indexPath, consumerRoot, expectedVersi
|
||||
assert.ok(++visited <= 10000 && contained(packageRoot), 'Installed dependency graph must be bounded and contained');
|
||||
const path = relative(root, packageRoot).split(sep).join('/');
|
||||
if (${/(?:^|\/)node_modules\/@openai\/codex-(?:linux|darwin|win32)-(?:x64|arm64)$/.toString()}.test(path)) {
|
||||
installed.push({ path, manifest: JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8')) });
|
||||
let manifest;
|
||||
try { manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8')); }
|
||||
catch (error) {
|
||||
if (error.code !== 'ENOENT') throw error;
|
||||
const contents = readdirSync(packageRoot), slot = lstatSync(packageRoot);
|
||||
assert.ok(slot.isDirectory() && !slot.isSymbolicLink() && contents.length === 0,
|
||||
'Codex optional slot without a manifest must be an empty regular directory; found ' +
|
||||
JSON.stringify(contents.sort().slice(0, 16).map(name => name.slice(0, 256))));
|
||||
// npm can leave an empty nested optional slot while hoisting the
|
||||
// actual host payload. Its real lock and manifest still qualify below.
|
||||
continue;
|
||||
}
|
||||
installed.push({ path, manifest });
|
||||
}
|
||||
const nested = join(packageRoot, 'node_modules');
|
||||
if (existsSync(nested)) pending.push(nested);
|
||||
|
||||
Reference in new issue
Block a user