pi-ext
bugabingas pi extensions
owned by bugabinga
test: stabilize cross-platform extension fixtures
b8d762c3d5436a7aa52a9d15fa2d21eb3ae27d29
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (6)
extensions/lazy/__tests__/harness.test.ts
Modified171 171 it(
"agent_end notifies for newly added lazy markers",
async ()
=> {
172 172 t
= await createTestSession({ extensions: [
extensionPath()] });
173 173 execFileSync(
"git", [
"init",
"-q"], { cwd: t.cwd });
174 + execFileSync(
"git", [
"config",
"core.autocrlf",
"false"], {
174 177 execFileSync(
"git", [
"config",
"user.email",
"lazy@example.invalid"], {
extensions/leaks/__fuzz__/replay.ts
Modified 1 1 import { test }
from "@fast-check/vitest";
2 2 import type { Arbitrary }
from "fast-check";
4 +export function isSelectedProperty(
6 + selected
= process.
env.FC_TEST,
8 + return !selected
|| selected
=== id;
4 11 export function prop<
T extends Record<
string,
Arbitrary<
unknown>>>(
9 - const selected
= !process.
env.FC_TEST
|| process.
env.FC_TEST
=== id;
16 + const selected
= isSelectedProperty(id);
10 17 const runner
= selected
? test
: test.skip;
11 18 return runner.
prop(arbitraries, {
extensions/leaks/__tests__/demo-corpus.test.ts
Modified54 54 .
filter((file)
=> !readFileSync(file).
includes(
0))
56 - const relativePath
= path.
relative(
root, file);
56 + const relativePath
= path.
relative(
root, file).
split(path.sep).
join(
"/");
57 57 const source
= readFileSync(file,
"utf8");
58 58 const result
= engine.
redactText(source,
"provider");
59 59 const spans
= __test.
selectSecretSpans(source, [
65 - fixtureClass: relativePath.
split(path.sep)[
0]
?? relativePath,
65 + fixtureClass: relativePath.
split(
"/")[
0]
?? relativePath,
66 66 redactionCount: result.count,
67 67 labels: [
...new Set(result.labels)].
toSorted(),
68 68 spans: spans.
map((span)
=> ({
73 73 restoredExactly: engine.
restoreText(result.
text)
=== source,
77 + a.relativePath
< b.relativePath
79 + : a.relativePath
> b.relativePath
78 85 function walk(dir
: string)
: string[] {
extensions/leaks/__tests__/fuzz-runner.test.ts
Modified 1 1 import { spawnSync }
from "node:child_process";
2 2 import process
from "node:process";
3 3 import { describe, expect, it }
from "vitest";
4 +import { isSelectedProperty }
from "../__fuzz__/replay.ts";
5 6 describe(
"leaks fuzz runner", ()
=> {
6 - it(
"selects and replays exactly one named property", ()
=> {
7 - const result
= spawnSync(
process.
execPath, [
"scripts/run_leaks_fuzz.mjs"], {
12 - FC_TEST:
"jwt-positive",
16 - expect(result.
status).
toBe(
0);
17 - expect(result.stdout).
toMatch(
/Tests\s+1 passed/);
7 + it(
"selects exactly one named property", ()
=> {
8 + expect(
isSelectedProperty(
"jwt-positive",
"jwt-positive")).
toBe(
true);
9 + expect(
isSelectedProperty(
"jwt-negative",
"jwt-positive")).
toBe(
false);
10 + expect(
isSelectedProperty(
"jwt-negative",
undefined)).
toBe(
true);
20 13 it(
"rejects unknown property selectors", ()
=> {
extensions/leaks/__tests__/harness.test.ts
Modified 55 55 item.
type === "custom" && item.customType
=== "leaks-mapping-v1",
57 - if (
!entry
|| entry.
type !== "custom")
throw new Error(
"missing mapping");
57 + if (entry?.
type !== "custom")
throw new Error(
"missing mapping");
58 58 return (entry.
data as { placeholder
: string }).placeholder;
extensions/leaks/__tests__/lifecycle.test.ts
Modified 82 82 const restored
= engine.
restoreDeep(proto).
value;
83 83 expect(
Object.
hasOwn(restored,
"__proto__")).
toBe(
true);
84 - expect(restored.
__proto__).
toBe(fixture);
84 + expect(
Object.
getOwnPropertyDescriptor(restored,
"__proto__")?.
value).
toBe(
87 89 it(
"blocks hydrated property-name collisions", ()
=> {