e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
export function extractZeroSource(text: string): string {
|
|
const fenced = text.match(/```(?:zero|0)?\s*([\s\S]*?)```/i);
|
|
const source = fenced ? fenced[1] : extractUnfencedZeroSource(text);
|
|
return `${source.trim()}\n`;
|
|
}
|
|
|
|
export function sourcePatternFailures(
|
|
source: string,
|
|
patterns: RegExp[],
|
|
): string[] {
|
|
return patterns
|
|
.filter((pattern) => !pattern.test(source))
|
|
.map((pattern) => pattern.toString());
|
|
}
|
|
|
|
const ZERO_SOURCE_START_PATTERN =
|
|
/^\s*(?:(?:pub\s+)?(?:export\s+c\s+fn|extern\s+(?:c|type)|packed\s+type|fn|const|type|enum|choice|alias|interface)\s+|use\s+|test\s+)/;
|
|
|
|
export function finalSourceResponseFailures(
|
|
responseText: string,
|
|
source: string,
|
|
): string[] {
|
|
if (!ZERO_SOURCE_START_PATTERN.test(source.trim())) {
|
|
return ["final response did not include Zero source"];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
function extractUnfencedZeroSource(text: string) {
|
|
const lines = text.split(/\r?\n/);
|
|
const start = lines.findIndex((line) => ZERO_SOURCE_START_PATTERN.test(line));
|
|
if (start === -1) return text;
|
|
return lines.slice(start).join("\n");
|
|
}
|