@quikit/quikpilot-runner 9.3.0-rc.47 → 9.3.0-rc.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24665,14 +24665,31 @@ function clearCheckoutExtraHeader() {
24665
24665
  if (status !== 5) throw err;
24666
24666
  }
24667
24667
  }
24668
- function push(branch, installationToken) {
24668
+ var PUSH_RETRY_DELAYS_MS = [3e3, 6e3, 12e3];
24669
+ var REPOSITORY_NOT_FOUND_RE = /Repository not found/i;
24670
+ function sleepSync(ms) {
24671
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
24672
+ }
24673
+ function push(branch, installationToken, sleep = sleepSync) {
24669
24674
  clearCheckoutExtraHeader();
24670
24675
  const basicAuth = Buffer.from(`x-access-token:${installationToken}`).toString("base64");
24671
- git(["push", "--set-upstream", "origin", branch], {
24672
- GIT_CONFIG_COUNT: "1",
24673
- GIT_CONFIG_KEY_0: "http.https://github.com/.extraheader",
24674
- GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${basicAuth}`
24675
- });
24676
+ for (let attempt2 = 0; ; attempt2 += 1) {
24677
+ try {
24678
+ git(["push", "--set-upstream", "origin", branch], {
24679
+ GIT_CONFIG_COUNT: "1",
24680
+ GIT_CONFIG_KEY_0: "http.https://github.com/.extraheader",
24681
+ GIT_CONFIG_VALUE_0: `AUTHORIZATION: basic ${basicAuth}`
24682
+ });
24683
+ if (attempt2 > 0) console.log(JSON.stringify({ event: "git.push_retry_ok", attempts: attempt2 + 1 }));
24684
+ return;
24685
+ } catch (err) {
24686
+ const delay = PUSH_RETRY_DELAYS_MS[attempt2];
24687
+ const said = `${err instanceof Error ? err.message : String(err)} ${String(err.stderr ?? "")}`;
24688
+ if (delay === void 0 || !REPOSITORY_NOT_FOUND_RE.test(said)) throw err;
24689
+ console.log(JSON.stringify({ event: "git.push_retry", attempt: attempt2 + 1, waitMs: delay }));
24690
+ sleep(delay);
24691
+ }
24692
+ }
24676
24693
  }
24677
24694
 
24678
24695
  // src/testHistory.ts
@@ -26434,7 +26451,7 @@ pp$8.enterClassBody = function() {
26434
26451
  };
26435
26452
  pp$8.exitClassBody = function() {
26436
26453
  var ref2 = this.privateNameStack.pop();
26437
- var declared = ref2.declared;
26454
+ var declared2 = ref2.declared;
26438
26455
  var used = ref2.used;
26439
26456
  if (!this.options.checkPrivateFields) {
26440
26457
  return;
@@ -26443,7 +26460,7 @@ pp$8.exitClassBody = function() {
26443
26460
  var parent = len === 0 ? null : this.privateNameStack[len - 1];
26444
26461
  for (var i2 = 0; i2 < used.length; ++i2) {
26445
26462
  var id = used[i2];
26446
- if (!hasOwn(declared, id.name)) {
26463
+ if (!hasOwn(declared2, id.name)) {
26447
26464
  if (parent) {
26448
26465
  parent.used.push(id);
26449
26466
  } else {
@@ -33516,6 +33533,11 @@ var ALLOWED_NAMES = /* @__PURE__ */ new Set([
33516
33533
  "PIPX_HOME",
33517
33534
  "PIPX_BIN_DIR",
33518
33535
  "POETRY_HOME",
33536
+ // QUIKTR-1699: PHP projects (Composer, set up by shivammathur/setup-php).
33537
+ "COMPOSER_HOME",
33538
+ "COMPOSER_CACHE_DIR",
33539
+ "COMPOSER_NO_INTERACTION",
33540
+ "PHP_INI_SCAN_DIR",
33519
33541
  "PNPM_HOME",
33520
33542
  "BUN_INSTALL",
33521
33543
  "DENO_INSTALL",
@@ -33896,7 +33918,220 @@ var import_node_path9 = require("node:path");
33896
33918
  // src/quiktest.ts
33897
33919
  var import_node_fs6 = require("node:fs");
33898
33920
  var import_node_path8 = require("node:path");
33921
+
33922
+ // src/caseTags.ts
33923
+ var MAX_CASE_TESTS = 50;
33924
+ var MAX_TEXT = 300;
33925
+ var CASE_ID_RE = /^QP-[A-Z][A-Z0-9]*-\d+-\d+$/;
33926
+ var TOKEN_RE = /\[QP-[A-Z][A-Z0-9]*-\d+-\d+\]/;
33927
+ var declared = [];
33928
+ function readCaseTests(value, allowedIds) {
33929
+ if (!Array.isArray(value)) return [];
33930
+ const allowed = new Set(allowedIds);
33931
+ const out = /* @__PURE__ */ new Map();
33932
+ for (const item of value.slice(0, MAX_CASE_TESTS)) {
33933
+ if (typeof item !== "object" || item === null) continue;
33934
+ const o = item;
33935
+ const ok = (v) => typeof v === "string" && v.trim().length > 0 && v.length <= MAX_TEXT;
33936
+ if (!ok(o.caseId) || !ok(o.path) || !ok(o.testName)) continue;
33937
+ const caseId = o.caseId.trim();
33938
+ if (!CASE_ID_RE.test(caseId) || allowed.size > 0 && !allowed.has(caseId)) continue;
33939
+ out.set(caseId, { caseId, path: normalisePath(o.path), testName: o.testName.trim() });
33940
+ }
33941
+ return [...out.values()];
33942
+ }
33943
+ function addCaseTests(list2) {
33944
+ const byId = new Map(declared.map((d) => [d.caseId, d]));
33945
+ for (const d of list2) byId.set(d.caseId, d);
33946
+ declared = [...byId.values()];
33947
+ }
33948
+ function declaredIn(caseId, written) {
33949
+ const d = declared.find((x) => x.caseId === caseId);
33950
+ if (!d) return false;
33951
+ for (const [path, text2] of written) if (samePath(path, d.path) && text2.includes(bareName(d.testName))) return true;
33952
+ return false;
33953
+ }
33954
+ function idCoversCase(testId, caseId) {
33955
+ if (testId.includes(`[${caseId}]`)) return true;
33956
+ const d = declared.find((x) => x.caseId === caseId);
33957
+ if (!d) return false;
33958
+ const at2 = testId.indexOf("::");
33959
+ const c = at2 < 0 ? { name: testId } : { classname: testId.slice(0, at2), name: testId.slice(at2 + 2) };
33960
+ if (!nameMatches(c.name, d.testName)) return false;
33961
+ return placeOf(c) === null || placeMatches(c, d.path);
33962
+ }
33963
+ function declaredFileOf(caseId) {
33964
+ return declared.find((x) => x.caseId === caseId)?.path ?? null;
33965
+ }
33966
+ function sameFile2(a, b) {
33967
+ return samePath(a, b);
33968
+ }
33969
+ function tagNames(cases, list2 = declared) {
33970
+ const names = cases.map((c) => c.name);
33971
+ for (const d of list2) {
33972
+ const matching = [];
33973
+ cases.forEach((c, i2) => {
33974
+ if (!TOKEN_RE.test(names[i2]) && nameMatches(c.name, d.testName)) matching.push(i2);
33975
+ });
33976
+ if (matching.length === 0) continue;
33977
+ const placed = matching.filter((i2) => placeOf(cases[i2]) !== null);
33978
+ let chosen;
33979
+ if (placed.length > 0) chosen = placed.filter((i2) => placeMatches(cases[i2], d.path));
33980
+ else chosen = matching.length === 1 || matching.every((i2) => isRowOf(cases[i2].name, d.testName)) ? matching : [];
33981
+ for (const i2 of chosen) names[i2] = `[${d.caseId}] ${names[i2]}`;
33982
+ }
33983
+ return names;
33984
+ }
33985
+ var SEPARATORS = [" ", " > ", " \u203A ", "::", ".", "/", "#"];
33986
+ function bareName(n) {
33987
+ return n.trim().replace(/\(\)$/, "");
33988
+ }
33989
+ function isRowOf(name, testName) {
33990
+ const n = bareName(name);
33991
+ const t = bareName(testName);
33992
+ return n === t || n.startsWith(`${t}[`) || n.startsWith(`${t}/`);
33993
+ }
33994
+ function nameMatches(name, testName) {
33995
+ const n = bareName(name);
33996
+ const t = bareName(testName);
33997
+ if (!t) return false;
33998
+ if (isRowOf(n, t)) return true;
33999
+ return SEPARATORS.some((s) => n.endsWith(`${s}${t}`) || n.includes(`${s}${t}[`));
34000
+ }
34001
+ function normalisePath(p) {
34002
+ return p.trim().replace(/\\/g, "/").replace(/^(\.\/)+/, "").replace(/^\/+/, "");
34003
+ }
34004
+ function samePath(a, b) {
34005
+ const x = normalisePath(a);
34006
+ const y = normalisePath(b);
34007
+ return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
34008
+ }
34009
+ var FILE_EXT_RE = /\.[A-Za-z0-9]{1,6}$/;
34010
+ function placeOf(c) {
34011
+ if (c.file && c.file.trim()) return { file: c.file };
34012
+ const cls = c.classname?.trim();
34013
+ if (!cls) return null;
34014
+ if (/[\\/]/.test(cls) && FILE_EXT_RE.test(cls)) return { file: cls };
34015
+ const parts = cls.split(/[\\/.]|::/).filter(Boolean);
34016
+ return parts.length > 1 ? { parts } : null;
34017
+ }
34018
+ function placeMatches(c, path) {
34019
+ const place = placeOf(c);
34020
+ if (!place) return false;
34021
+ if ("file" in place) return samePath(place.file, path);
34022
+ const segs = normalisePath(path).replace(FILE_EXT_RE, "").split(/[/.]/).filter(Boolean);
34023
+ const cls = place.parts;
34024
+ for (let k2 = Math.min(cls.length, segs.length); k2 >= 1; k2--) {
34025
+ if (cls.slice(0, k2).join("/") === segs.slice(-k2).join("/")) return true;
34026
+ }
34027
+ const dir = segs.slice(0, -1);
34028
+ if (dir.length === 0) return false;
34029
+ const k = Math.min(dir.length, cls.length);
34030
+ return cls.slice(-k).join("/") === dir.slice(-k).join("/");
34031
+ }
34032
+ var TESTCASE_TAG_RE = /<testcase\b([^>]*?)(\/?>)/g;
34033
+ var ATTR = (name) => new RegExp(`\\b${name}="([^"]*)"`);
34034
+ var unescape = (s) => s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
34035
+ var escape = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
34036
+ function tagReportXml(xml, list2 = declared) {
34037
+ if (list2.length === 0) return xml;
34038
+ const cases = [];
34039
+ for (const m of xml.matchAll(TESTCASE_TAG_RE)) {
34040
+ const attrs = m[1] ?? "";
34041
+ const name = ATTR("name").exec(attrs)?.[1];
34042
+ const classname = ATTR("classname").exec(attrs)?.[1];
34043
+ const file = ATTR("file").exec(attrs)?.[1];
34044
+ cases.push({ name: name === void 0 ? "" : unescape(name), ...classname !== void 0 ? { classname: unescape(classname) } : {}, ...file !== void 0 ? { file: unescape(file) } : {} });
34045
+ }
34046
+ const tagged = tagNames(cases, list2);
34047
+ if (tagged.every((n, i3) => n === cases[i3].name)) return xml;
34048
+ let i2 = 0;
34049
+ return xml.replace(TESTCASE_TAG_RE, (whole4, attrs, close) => {
34050
+ const index = i2++;
34051
+ const name = tagged[index];
34052
+ if (name === cases[index].name || !ATTR("name").test(attrs)) return whole4;
34053
+ return `<testcase${attrs.replace(ATTR("name"), () => `name="${escape(name)}"`)}${close}`;
34054
+ });
34055
+ }
34056
+
34057
+ // src/quiktest.ts
33899
34058
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
34059
+ var DEPENDENCY_DIRS = /* @__PURE__ */ new Set([
34060
+ "node_modules",
34061
+ ".git",
34062
+ ".venv",
34063
+ "venv",
34064
+ "vendor",
34065
+ "site-packages",
34066
+ ".tox",
34067
+ ".gradle",
34068
+ "__pycache__",
34069
+ ".pytest_cache",
34070
+ ".mypy_cache",
34071
+ "bower_components",
34072
+ // The runner's own copy of a failed run's final report (failureArtifact.ts FAILURE_ARTIFACT_DIR): never a report of a test run.
34073
+ "quikpilot-failure"
34074
+ ]);
34075
+ var MAX_REPORTS = 500;
34076
+ function isJUnitXml(path) {
34077
+ let fd = null;
34078
+ try {
34079
+ fd = (0, import_node_fs6.openSync)(path, "r");
34080
+ const buf = Buffer.alloc(2048);
34081
+ const n = (0, import_node_fs6.readSync)(fd, buf, 0, buf.length, 0);
34082
+ const head = buf.subarray(0, n).toString("utf8").replace(/^\uFEFF/, "");
34083
+ const body = head.replace(/<\?[\s\S]*?\?>/g, "").replace(/<!--[\s\S]*?-->/g, "").trimStart();
34084
+ return /^<testsuites?\b/.test(body);
34085
+ } catch {
34086
+ return false;
34087
+ } finally {
34088
+ if (fd !== null) (0, import_node_fs6.closeSync)(fd);
34089
+ }
34090
+ }
34091
+ function findJUnitReports(cwd = process.cwd(), opts = {}) {
34092
+ const found = [];
34093
+ const walk2 = (dir) => {
34094
+ if (found.length >= MAX_REPORTS) return;
34095
+ let entries;
34096
+ try {
34097
+ entries = (0, import_node_fs6.readdirSync)(dir);
34098
+ } catch {
34099
+ return;
34100
+ }
34101
+ for (const entry of entries) {
34102
+ if (DEPENDENCY_DIRS.has(entry)) continue;
34103
+ const full = (0, import_node_path8.join)(dir, entry);
34104
+ let stat;
34105
+ try {
34106
+ stat = (0, import_node_fs6.statSync)(full);
34107
+ } catch {
34108
+ continue;
34109
+ }
34110
+ if (stat.isDirectory()) walk2(full);
34111
+ else if (/\.xml$/i.test(entry) && (opts.freshSinceMs === void 0 || stat.mtimeMs >= opts.freshSinceMs) && isJUnitXml(full)) {
34112
+ found.push(full);
34113
+ if (found.length >= MAX_REPORTS) return;
34114
+ }
34115
+ }
34116
+ };
34117
+ walk2(cwd);
34118
+ const named = (p) => /^junit.*\.xml$/i.test(p.split(/[\\/]/).pop() ?? "") ? 0 : 1;
34119
+ return found.sort((a, b) => named(a) - named(b) || a.localeCompare(b));
34120
+ }
34121
+ function mergeJUnitReports(texts) {
34122
+ if (texts.length === 1) return texts[0];
34123
+ const inner = texts.map((t) => {
34124
+ const body = t.replace(/^\uFEFF/, "").replace(/<\?xml[\s\S]*?\?>/, "").trim();
34125
+ const wrapped = /^<testsuites\b[^>]*>([\s\S]*)<\/testsuites>\s*$/.exec(body);
34126
+ if (wrapped) return wrapped[1].trim();
34127
+ return /^<testsuites\b[^>]*\/>\s*$/.test(body) ? "" : body;
34128
+ });
34129
+ return `<?xml version="1.0" encoding="UTF-8"?>
34130
+ <testsuites>
34131
+ ${inner.filter(Boolean).join("\n")}
34132
+ </testsuites>
34133
+ `;
34134
+ }
33900
34135
  function walkForJUnitByName(dir) {
33901
34136
  let entries;
33902
34137
  try {
@@ -33934,14 +34169,16 @@ function firstXmlIn(dir, namePattern) {
33934
34169
  }
33935
34170
  function readTestReportBytes(cwd = process.cwd()) {
33936
34171
  try {
33937
- const report = findJUnitReport(cwd);
33938
- return report ? (0, import_node_fs6.readFileSync)(report) : null;
34172
+ const reports = findJUnitReports(cwd);
34173
+ if (reports.length === 0) return null;
34174
+ if (reports.length === 1) return (0, import_node_fs6.readFileSync)(reports[0]);
34175
+ return Buffer.from(mergeJUnitReports(reports.map((r) => (0, import_node_fs6.readFileSync)(r, "utf8"))), "utf8");
33939
34176
  } catch {
33940
34177
  return null;
33941
34178
  }
33942
34179
  }
33943
34180
  function findJUnitReport(cwd = process.cwd()) {
33944
- return walkForJUnitByName(cwd) ?? firstXmlIn((0, import_node_path8.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "target", "surefire-reports"), /\.xml$/);
34181
+ return walkForJUnitByName(cwd) ?? findJUnitReports(cwd)[0] ?? firstXmlIn((0, import_node_path8.join)(cwd, "test-results"), /\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "reports"), /^junit.*\.xml$/) ?? firstXmlIn((0, import_node_path8.join)(cwd, "target", "surefire-reports"), /\.xml$/);
33945
34182
  }
33946
34183
  function buildCiUrl(serverUrl, repository, githubRunId) {
33947
34184
  return `${serverUrl}/${repository}/actions/runs/${githubRunId}`;
@@ -33957,16 +34194,15 @@ async function reportToQuikTest(params) {
33957
34194
  console.log("packet.quikTest is null \u2014 this run has no QuikTest run to report into.");
33958
34195
  return null;
33959
34196
  }
33960
- const report = findJUnitReport(cwd);
33961
- if (!report) {
34197
+ const reports = findJUnitReports(cwd);
34198
+ if (reports.length === 0) {
33962
34199
  console.warn("::warning::QuikPilot found no JUnit report \u2014 no results reported to QuikTest.");
33963
34200
  return null;
33964
34201
  }
33965
34202
  try {
33966
- console.log(`reporting ${report}`);
34203
+ console.log(`reporting ${reports.length === 1 ? reports[0] : `${reports.length} reports`}`);
33967
34204
  const ciUrl = buildCiUrl(githubServerUrl, githubRepository, githubRunId);
33968
- const { readFileSync: readFileSync19 } = await import("node:fs");
33969
- const body = readFileSync19(report);
34205
+ const body = tagReportXml(mergeJUnitReports(reports.map((r) => (0, import_node_fs6.readFileSync)(r, "utf8"))));
33970
34206
  let url = `${resultsUrl}?ciUrl=${encodeURIComponent(ciUrl)}&automationIdFormat=bracket`;
33971
34207
  if (generatedFiles) {
33972
34208
  url += `&generatedFiles=${encodeURIComponent(generatedFiles.join(","))}`;
@@ -33979,7 +34215,7 @@ async function reportToQuikTest(params) {
33979
34215
  if (!res.ok) {
33980
34216
  throw new Error(`QuikTest report POST failed: ${res.status} ${res.statusText}`);
33981
34217
  }
33982
- (0, import_node_fs6.rmSync)(report, { force: true });
34218
+ for (const report of reports) (0, import_node_fs6.rmSync)(report, { force: true });
33983
34219
  let unmatched = [];
33984
34220
  try {
33985
34221
  const json = await res.json();
@@ -34057,9 +34293,9 @@ function withoutLoop7Words(previous) {
34057
34293
  var import_node_fs7 = require("node:fs");
34058
34294
 
34059
34295
  // src/pathShape.ts
34060
- var PATH_EXTENSION_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go)$/i;
34296
+ var PATH_EXTENSION_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py|rb|go|java|kt|kts|cs|php|rs|swift|scala|ex|exs|c|cc|cpp|h|hpp|dart|lua|vue|svelte)$/i;
34061
34297
  function looksLikeFilePath(value) {
34062
- return value.includes("/") || PATH_EXTENSION_RE.test(value);
34298
+ return PATH_EXTENSION_RE.test(value.trim());
34063
34299
  }
34064
34300
 
34065
34301
  // src/regressionCheck.ts
@@ -34112,6 +34348,13 @@ function extractFailureDetail(inner) {
34112
34348
  if (!text2) return null;
34113
34349
  return text2.length > MAX_FAILURE_DETAIL ? `${text2.slice(0, MAX_FAILURE_DETAIL)}\u2026` : text2;
34114
34350
  }
34351
+ var ANY_LOCATION_RE = /(?:File "([^"\r\n]+?\.[A-Za-z0-9]{1,6})", line (\d+))|(?:([^\s"'()\[\]<>]+?\.(?:[cm]?[jt]sx?|py|go|java|rb|rs|cs|php|kt|kts|swift|scala|exs?|c|cc|cpp|h|hpp|dart)):(?:line )?(\d+))/g;
34352
+ var DEPENDENCY_PATH_RE = /(^|\/)(node_modules|site-packages|dist-packages|vendor|\.venv|venv|\.cargo|\.m2|\.gradle|go\/pkg\/mod)\//;
34353
+ function shownPath(raw) {
34354
+ const path = normalizeSlashes(raw).replace(/^#\s*/, "").replace(/^\.\//, "");
34355
+ const root = `${normalizeSlashes(process.cwd()).replace(/\/+$/, "")}/`;
34356
+ return path.startsWith(root) ? path.slice(root.length) : path;
34357
+ }
34115
34358
  function parseAssertionLocation(body) {
34116
34359
  const text2 = unescapeXmlEntities(body);
34117
34360
  STACK_FRAME_RE.lastIndex = 0;
@@ -34124,6 +34367,17 @@ function parseAssertionLocation(body) {
34124
34367
  if (shown.length > MAX_FAILURE_LOCATION) return null;
34125
34368
  return `${shown}:${frame[2]}`;
34126
34369
  }
34370
+ ANY_LOCATION_RE.lastIndex = 0;
34371
+ let any;
34372
+ while (any = ANY_LOCATION_RE.exec(text2)) {
34373
+ const raw = any[1] ?? any[3];
34374
+ const line = any[2] ?? any[4];
34375
+ if (!raw || !line) continue;
34376
+ const shown = shownPath(raw);
34377
+ if (DEPENDENCY_PATH_RE.test(`/${shown}`) || /^(?:https?|file):/i.test(shown)) continue;
34378
+ if (shown.length > MAX_FAILURE_LOCATION) return null;
34379
+ return `${shown}:${line}`;
34380
+ }
34127
34381
  return null;
34128
34382
  }
34129
34383
  function extractFailureText(testcaseBody) {
@@ -34154,15 +34408,27 @@ function parseJUnitOutcomes(xml) {
34154
34408
  const file = FILE_ATTR_RE.exec(suiteMatch[1])?.[1];
34155
34409
  if (file) discoveredFiles.add(normalizeSlashes(file));
34156
34410
  }
34411
+ const cases = [];
34157
34412
  let match;
34158
34413
  TESTCASE_RE.lastIndex = 0;
34159
34414
  while (match = TESTCASE_RE.exec(xml)) {
34160
- const [, attrs, body = ""] = match;
34415
+ const [, attrs = "", body = ""] = match;
34161
34416
  const rawName = NAME_ATTR_RE.exec(attrs)?.[1];
34162
34417
  if (!rawName) continue;
34163
- const name = unescapeXmlEntities(rawName);
34164
34418
  const rawClassname = CLASSNAME_ATTR_RE.exec(attrs)?.[1];
34165
- const classname = rawClassname === void 0 ? void 0 : unescapeXmlEntities(rawClassname);
34419
+ const rawFile = FILE_ATTR_RE.exec(attrs)?.[1];
34420
+ cases.push({
34421
+ attrs,
34422
+ body,
34423
+ name: unescapeXmlEntities(rawName),
34424
+ ...rawClassname !== void 0 ? { classname: unescapeXmlEntities(rawClassname) } : {},
34425
+ ...rawFile !== void 0 ? { file: unescapeXmlEntities(rawFile) } : {}
34426
+ });
34427
+ }
34428
+ const tagged = tagNames(cases);
34429
+ for (const [index, c] of cases.entries()) {
34430
+ const { attrs, body, classname } = c;
34431
+ const name = tagged[index];
34166
34432
  const id = classname ? `${classname}::${name}` : name;
34167
34433
  const failed = FAILURE_CHILD_RE.test(body);
34168
34434
  outcomes.set(id, !failed);
@@ -34177,7 +34443,7 @@ function parseJUnitOutcomes(xml) {
34177
34443
  }
34178
34444
  const file = FILE_ATTR_RE.exec(attrs)?.[1];
34179
34445
  if (file) discoveredFiles.add(normalizeSlashes(file));
34180
- if (classname) discoveredFiles.add(normalizeSlashes(classname));
34446
+ if (classname && looksLikeFilePath(classname.trim())) discoveredFiles.add(normalizeSlashes(classname));
34181
34447
  if (!file?.trim() && !(classname && looksLikeFilePath(classname.trim()))) unmappedEntries += 1;
34182
34448
  const bracket = QP_TOKEN_BRACKET_RE.exec(name)?.[1];
34183
34449
  if (bracket) {
@@ -34191,17 +34457,45 @@ function parseJUnitOutcomes(xml) {
34191
34457
  }
34192
34458
  var FRESH_SLACK_MS = 2e3;
34193
34459
  function readJUnitOutcomes(cwd, freshSinceMs) {
34194
- const report = findJUnitReport(cwd);
34195
- if (!report) return null;
34196
- try {
34197
- if (freshSinceMs !== void 0 && (0, import_node_fs7.statSync)(report).mtimeMs < freshSinceMs) return null;
34198
- return parseJUnitOutcomes((0, import_node_fs7.readFileSync)(report, "utf8"));
34199
- } catch {
34200
- return null;
34460
+ const reports = findJUnitReports(cwd, freshSinceMs === void 0 ? {} : { freshSinceMs });
34461
+ const parsed = [];
34462
+ for (const report of reports) {
34463
+ try {
34464
+ parsed.push(parseJUnitOutcomes((0, import_node_fs7.readFileSync)(report, "utf8")));
34465
+ } catch {
34466
+ }
34467
+ }
34468
+ if (parsed.length === 0) return null;
34469
+ return parsed.length === 1 ? parsed[0] : mergeParsed(parsed);
34470
+ }
34471
+ function mergeParsed(all) {
34472
+ const out = {
34473
+ outcomes: /* @__PURE__ */ new Map(),
34474
+ automationIdResults: /* @__PURE__ */ new Map(),
34475
+ failureText: /* @__PURE__ */ new Map(),
34476
+ failureWhere: /* @__PURE__ */ new Map(),
34477
+ failureDetail: /* @__PURE__ */ new Map(),
34478
+ discoveredFiles: /* @__PURE__ */ new Set(),
34479
+ discoveredAutomationIds: /* @__PURE__ */ new Set(),
34480
+ unmappedEntries: 0
34481
+ };
34482
+ for (const p of all) {
34483
+ for (const [id, passed] of p.outcomes) out.outcomes.set(id, (out.outcomes.get(id) ?? true) && passed);
34484
+ for (const [id, r] of p.automationIdResults) {
34485
+ const seen = out.automationIdResults.get(id);
34486
+ if (!seen || RESULT_RANK[r] > RESULT_RANK[seen]) out.automationIdResults.set(id, r);
34487
+ }
34488
+ for (const [k, v] of p.failureText) out.failureText.set(k, v);
34489
+ for (const [k, v] of p.failureWhere) out.failureWhere.set(k, v);
34490
+ for (const [k, v] of p.failureDetail) out.failureDetail.set(k, v);
34491
+ for (const f of p.discoveredFiles) out.discoveredFiles.add(f);
34492
+ for (const id of p.discoveredAutomationIds) out.discoveredAutomationIds.add(id);
34493
+ out.unmappedEntries += p.unmappedEntries;
34201
34494
  }
34495
+ return out;
34202
34496
  }
34203
- function readAutomationIdResults(cwd = process.cwd()) {
34204
- return readJUnitOutcomes(cwd)?.automationIdResults ?? null;
34497
+ function readAutomationIdResults(cwd = process.cwd(), freshSinceMs) {
34498
+ return readJUnitOutcomes(cwd, freshSinceMs)?.automationIdResults ?? null;
34205
34499
  }
34206
34500
  function snapshotOf(outcome, parsed) {
34207
34501
  return {
@@ -34224,8 +34518,9 @@ async function captureLimited(command, cwd, limitMs) {
34224
34518
  }
34225
34519
  function captureTestSnapshot(command, cwd = process.cwd(), opts) {
34226
34520
  if (opts) return captureLimited(command, cwd, opts.limitMs);
34521
+ const startedAt = Date.now();
34227
34522
  const outcome = runTestCommand(command);
34228
- const parsed = readJUnitOutcomes(cwd);
34523
+ const parsed = readJUnitOutcomes(cwd, startedAt - FRESH_SLACK_MS);
34229
34524
  return {
34230
34525
  outcome,
34231
34526
  results: parsed?.outcomes ?? null,
@@ -34237,8 +34532,8 @@ function captureTestSnapshot(command, cwd = process.cwd(), opts) {
34237
34532
  unmappedEntries: parsed?.unmappedEntries
34238
34533
  };
34239
34534
  }
34240
- function readTestSnapshot(outcome, cwd = process.cwd()) {
34241
- const parsed = readJUnitOutcomes(cwd);
34535
+ function readTestSnapshot(outcome, cwd = process.cwd(), freshSinceMs) {
34536
+ const parsed = readJUnitOutcomes(cwd, freshSinceMs);
34242
34537
  return {
34243
34538
  outcome,
34244
34539
  results: parsed?.outcomes ?? null,
@@ -34262,8 +34557,9 @@ function readTestSnapshotAt(outcome, reportPath) {
34262
34557
  }
34263
34558
  async function captureBaselineSnapshot(command, cwd = process.cwd(), opts) {
34264
34559
  if (opts) return captureLimited(command, cwd, opts.limitMs);
34560
+ const startedAt = Date.now();
34265
34561
  const outcome = await runTestCommandAsync(command);
34266
- const parsed = readJUnitOutcomes(cwd);
34562
+ const parsed = readJUnitOutcomes(cwd, startedAt - FRESH_SLACK_MS);
34267
34563
  return {
34268
34564
  outcome,
34269
34565
  results: parsed?.outcomes ?? null,
@@ -34466,6 +34762,7 @@ async function runBaselineCheck(params) {
34466
34762
  const reportBefore = findJUnitReport(cwd);
34467
34763
  const mtimeBefore = reportBefore ? mtimeOf(reportBefore) : null;
34468
34764
  const untrackedBefore = untrackedFiles(cwd);
34765
+ const fileRunStartedAt = Date.now();
34469
34766
  const outcome = await runFile(buildSingleFileCommand(testFileCmd, target.path), BASELINE_CHECK_TIMEOUT_MS);
34470
34767
  if (outcome === "timeout") {
34471
34768
  skip(
@@ -34483,7 +34780,7 @@ async function runBaselineCheck(params) {
34483
34780
  "the single-file command wrote no new JUnit report (it must write the same JUnit report as the test command), so nothing could be checked."
34484
34781
  );
34485
34782
  } else {
34486
- const byId = readAutomationIdResults(cwd);
34783
+ const byId = readAutomationIdResults(cwd, fileRunStartedAt - 2e3);
34487
34784
  for (const id of ids) if (byId?.get(id) === "pass") flagged.push(id);
34488
34785
  }
34489
34786
  }
@@ -36071,6 +36368,8 @@ function testTimeLimitMs(baselineMs) {
36071
36368
  if (baselineMs > MAX_TEST_LIMIT_MS) return "too_slow";
36072
36369
  return Math.min(MAX_TEST_LIMIT_MS, Math.max(MIN_TEST_LIMIT_MS, baselineMs * 3));
36073
36370
  }
36371
+ var FILE_COMMAND_PASSED_SENTENCE = "The Test command passed on this file, but no JUnit report was written to say which tests ran.";
36372
+ var FILE_COMMAND_FAILED_SENTENCE = "The Test command failed on this file; no JUnit report was written to say which test failed. Its output is in the job log.";
36074
36373
  var MESSAGES = {
36075
36374
  tests_passed: "The tests passed.",
36076
36375
  tests_failed: "Some tests failed. output lists their names, regressions first: a regression passed before your change. For a test you wrote in this run, messages gives the first line of why it failed.",
@@ -36116,10 +36415,10 @@ function wholeFailure(text2, where, max) {
36116
36415
  if (firstSafe.length >= max - 1) return firstLine(text2, where, max);
36117
36416
  return `${safe.slice(0, max - 1)}\u2026`;
36118
36417
  }
36119
- var normalisePath = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
36418
+ var normalisePath2 = (p) => p.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
36120
36419
  function samePlace2(a, b) {
36121
- const x = normalisePath(a);
36122
- const y = normalisePath(b);
36420
+ const x = normalisePath2(a);
36421
+ const y = normalisePath2(b);
36123
36422
  return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
36124
36423
  }
36125
36424
  function ownFailureIds(newFailures, changedPaths, requiredIds) {
@@ -36387,16 +36686,7 @@ var RunTestsTool = class {
36387
36686
  }
36388
36687
  const run2 = await runCommand2(command, file === void 0 || testLimitsOff() ? limit : Math.min(limit, FILE_RUN_LIMIT_MS), d.root);
36389
36688
  if (!run2.started || run2.timedOut) return { run: run2, snapshot: null };
36390
- const report = findReport(d.root);
36391
- let fresh = false;
36392
- if (report) {
36393
- try {
36394
- fresh = (0, import_node_fs14.statSync)(report).mtimeMs >= startedAt - FRESH_SLACK_MS2;
36395
- } catch {
36396
- fresh = false;
36397
- }
36398
- }
36399
- const snapshot = fresh ? readSnapshot(run2.outcome, d.root) : null;
36689
+ const snapshot = readSnapshot(run2.outcome, d.root, startedAt - FRESH_SLACK_MS2);
36400
36690
  return { run: run2, snapshot: snapshot && snapshot.results ? snapshot : null };
36401
36691
  },
36402
36692
  { ...d.tree, preserve }
@@ -36448,7 +36738,8 @@ var RunTestsTool = class {
36448
36738
  this.lastFailingKey = null;
36449
36739
  this.lastFailed = null;
36450
36740
  }
36451
- return this.answer(callId, "no_report", { seconds, scope, ...planInfo(null) ? { plan: planInfo(null) } : {} });
36741
+ const byExitCode = file !== void 0 && ran.run.started && !ran.run.timedOut ? ran.run.outcome === "success" ? { reason: "test_command_passed", extra: FILE_COMMAND_PASSED_SENTENCE } : { reason: "test_command_failed", extra: FILE_COMMAND_FAILED_SENTENCE } : {};
36742
+ return this.answer(callId, "no_report", { seconds, scope, ...byExitCode, ...planInfo(null) ? { plan: planInfo(null) } : {} });
36452
36743
  }
36453
36744
  const answer = testAnswerFrom({
36454
36745
  baseline: baseline?.snapshot ?? null,
@@ -38687,14 +38978,14 @@ function unitOf(text2, starts, node) {
38687
38978
  const base = { line: lineAt2(starts, node.start), names: [], declared: [], children: [], declaration: false };
38688
38979
  if (node.type === "ImportDeclaration") {
38689
38980
  const names = [];
38690
- const declared2 = [];
38981
+ const declared3 = [];
38691
38982
  for (const spec of node.specifiers) {
38692
- declared2.push(spec.local.name);
38983
+ declared3.push(spec.local.name);
38693
38984
  if (spec.type === "ImportSpecifier") names.push(`${spec.imported.type === "Identifier" ? spec.imported.name : String(spec.imported.value)}:${spec.local.name}`);
38694
38985
  else if (spec.type === "ImportDefaultSpecifier") names.push(`default:${spec.local.name}`);
38695
38986
  else names.push(`*:${spec.local.name}`);
38696
38987
  }
38697
- return { ...base, kind: "import", key: `import:${String(node.source.value)}`, names, declared: declared2 };
38988
+ return { ...base, kind: "import", key: `import:${String(node.source.value)}`, names, declared: declared3 };
38698
38989
  }
38699
38990
  if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression") {
38700
38991
  const root = rootName(node.expression);
@@ -38707,16 +38998,16 @@ function unitOf(text2, starts, node) {
38707
38998
  return { ...base, kind: "test", key: text2.slice(node.start, node.end) };
38708
38999
  }
38709
39000
  }
38710
- const declared = [];
39001
+ const declared2 = [];
38711
39002
  let declaration = false;
38712
39003
  if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {
38713
39004
  declaration = true;
38714
- declared.push(node.id.name);
39005
+ declared2.push(node.id.name);
38715
39006
  } else if (node.type === "VariableDeclaration") {
38716
39007
  declaration = true;
38717
- for (const d of node.declarations) patternNames(d.id, declared);
39008
+ for (const d of node.declarations) patternNames(d.id, declared2);
38718
39009
  }
38719
- return { ...base, kind: "other", key: text2.slice(node.start, node.end), declared, declaration };
39010
+ return { ...base, kind: "other", key: text2.slice(node.start, node.end), declared: declared2, declaration };
38720
39011
  }
38721
39012
  function unitsOf(text2, body) {
38722
39013
  const starts = lineStartsOf(text2);
@@ -41415,7 +41706,7 @@ async function runCodegenLoop(args, deps) {
41415
41706
  };
41416
41707
  const anyOwnTestFails = () => {
41417
41708
  const runs = currentRedRuns();
41418
- return args.requiredAutomationIds.some((id) => runs.some((r) => r.failing.some((name) => name.includes(`[${id}]`))));
41709
+ return args.requiredAutomationIds.some((id) => runs.some((r) => failsFor(r, id)));
41419
41710
  };
41420
41711
  const redProblem = () => {
41421
41712
  const ids = args.redCheckIds ?? [];
@@ -41424,9 +41715,8 @@ async function runCodegenLoop(args, deps) {
41424
41715
  const passing = [];
41425
41716
  const unrun = [];
41426
41717
  for (const id of ids) {
41427
- const token = `[${id}]`;
41428
- if (runs.some((r) => r.failing.some((name) => name.includes(token)))) continue;
41429
- const covering = runs.filter((r) => r.file === void 0 || (overlay.get(r.file)?.lf ?? "").includes(token));
41718
+ if (runs.some((r) => failsFor(r, id))) continue;
41719
+ const covering = runs.filter((r) => r.file === void 0 || fileHolds(r.file, id));
41430
41720
  if (covering.length === 0) unrun.push(id);
41431
41721
  else if (covering.every((r) => !r.truncated)) passing.push(id);
41432
41722
  }
@@ -41443,6 +41733,12 @@ async function runCodegenLoop(args, deps) {
41443
41733
  }
41444
41734
  return null;
41445
41735
  };
41736
+ const fileHolds = (file, id) => {
41737
+ if ((overlay.get(file)?.lf ?? "").includes(`[${id}]`)) return true;
41738
+ const declared2 = declaredFileOf(id);
41739
+ return declared2 !== null && sameFile2(declared2, file);
41740
+ };
41741
+ const failsFor = (r, id) => r.failing.some((name) => idCoversCase(name, id)) || r.fileFailed === true && r.file !== void 0 && fileHolds(r.file, id);
41446
41742
  const sentSteps = () => stepsOf(transcript.slice(0, sent.entries), toolResults.slice(0, sent.results));
41447
41743
  let turns = 0;
41448
41744
  let noProgressStreak = 0;
@@ -41557,7 +41853,8 @@ async function runCodegenLoop(args, deps) {
41557
41853
  return new CodegenLoopFailure("no_writes");
41558
41854
  }
41559
41855
  const texts = changed.map((p) => overlay.get(p)?.lf ?? "");
41560
- const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)));
41856
+ const written = new Map(changed.map((p) => [p, overlay.get(p)?.lf ?? ""]));
41857
+ const missing = args.requiredAutomationIds.filter((id) => !texts.some((t) => t.includes(`[${id}]`)) && !declaredIn(id, written));
41561
41858
  if (missing.length > 0) {
41562
41859
  if (!quiet) log({ event: "codegen.loop_refused", turn, reason: "coverage_missing", missing: missing.length });
41563
41860
  return new CodegenLoopFailure("coverage_missing", void 0, void 0, `${missing.length} required test case(s) not written`, coverageSentence(missing));
@@ -41677,8 +41974,9 @@ async function runCodegenLoop(args, deps) {
41677
41974
  const redLeft = harness && args.phase === "tests" ? redProblem() : null;
41678
41975
  if (harness && args.phase === "tests" && currentRedRuns().some((r) => r.failing.length > 0) && handOverRefusal(turn, true) === null && (redLeft === null || redLeft.kind === "passing")) {
41679
41976
  log({ event: "codegen.red_check", turn, outcome: "gave_up_but_red", files: overlay.changedPaths().length, ...redLeft ? { unproven: redLeft.ids.length } : {} });
41680
- const red = currentRedRuns().at(-1).answer;
41681
- return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), ...redLeft ? { redUnproven: redLeft.ids } : {}, lastTestAnswer: last ?? red };
41977
+ const red = currentRedRuns().filter((r) => r.answer !== void 0).at(-1)?.answer;
41978
+ const kept = last ?? red;
41979
+ return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary: said ?? "", steps: sentSteps(), ...redLeft ? { redUnproven: redLeft.ids } : {}, ...kept ? { lastTestAnswer: kept } : {} };
41682
41980
  }
41683
41981
  if (args.keepOnGiveUp === true && last !== void 0 && last.regressions + last.newFailures > 0 && handOverRefusal(turn, true) === null) {
41684
41982
  log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: last.regressions, newFailures: last.newFailures });
@@ -41688,6 +41986,11 @@ async function runCodegenLoop(args, deps) {
41688
41986
  }
41689
41987
  if (body.outcome === "DONE") {
41690
41988
  log({ event: "codegen.loop_turn", turn, outcome: "done", requestTokens, elapsedMs: now() - turnStarted, calls: [] });
41989
+ const declaredTests = readCaseTests(body.caseTests, args.requiredAutomationIds);
41990
+ if (declaredTests.length > 0) {
41991
+ addCaseTests(declaredTests);
41992
+ log({ event: "codegen.case_tests", turn, declared: declaredTests.length });
41993
+ }
41691
41994
  if (conflictTool && conflictTool.recorded().length > 0) {
41692
41995
  const said = typeof body.summary === "string" ? body.summary.slice(0, MAX_SUMMARY_CHARS) : void 0;
41693
41996
  throw new TestConflictStop(conflictTool.recorded(), new CodegenLoopFailure("cannot_complete", void 0, void 0, said, said));
@@ -41760,7 +42063,7 @@ async function runCodegenLoop(args, deps) {
41760
42063
  const lane = args.lane;
41761
42064
  if (harness && args.phase === "code" && lane?.kind === "code" && !lane.amend && args.keepOnGiveUp === true) {
41762
42065
  const red2 = currentRedRuns().filter((r) => r.failing.some((name) => lane.frozen.some((p) => samePlace3(name.split("::")[0] ?? "", p)))).at(-1);
41763
- if (red2) {
42066
+ if (red2?.answer) {
41764
42067
  log({ event: "codegen.loop_kept", files: overlay.changedPaths().length, regressions: red2.answer.regressions, newFailures: red2.answer.newFailures, after: "done" });
41765
42068
  return { results: overlay.results(), summary: snapshot("gave_up_kept"), doneSummary, gaveUp: true, steps: sentSteps(), lastTestAnswer: red2.answer };
41766
42069
  }
@@ -41830,6 +42133,8 @@ async function runCodegenLoop(args, deps) {
41830
42133
  if (call.name === RUN_TESTS_TOOL && isTestAnswer(result.output) && result.status !== "duplicate") {
41831
42134
  const file = result.output.scope === "file" && isPlainObject3(call.args) && typeof call.args.file === "string" ? call.args.file : void 0;
41832
42135
  redRuns.push({ version: versionOfFiles(filesOnDisk()), ...file ? { file } : {}, failing: result.output.failingTests, truncated: result.output.truncated, answer: result.output });
42136
+ } else if (call.name === RUN_TESTS_TOOL && result.status === "no_report" && result.reason === "test_command_failed" && isPlainObject3(call.args) && typeof call.args.file === "string") {
42137
+ redRuns.push({ version: versionOfFiles(filesOnDisk()), file: call.args.file, failing: [], truncated: false, fileFailed: true });
41833
42138
  }
41834
42139
  if (read) reads.push(read);
41835
42140
  statusCounts[result.status] = (statusCounts[result.status] ?? 0) + 1;
@@ -43891,7 +44196,7 @@ var samePlace6 = (a, b) => {
43891
44196
  const y = b.replace(/\\/g, "/").replace(/^(\.\/)+/, "");
43892
44197
  return x === y || x.endsWith(`/${y}`) || y.endsWith(`/${x}`);
43893
44198
  };
43894
- function isRowOf(id, test) {
44199
+ function isRowOf2(id, test) {
43895
44200
  const { file, name } = splitTestId(id);
43896
44201
  return (file === null || samePlace6(file, test.path)) && nameEndsWithTitle(name, test.testTitle);
43897
44202
  }
@@ -43903,10 +44208,10 @@ function approvedTestsFailing(input) {
43903
44208
  const out = [];
43904
44209
  const taken = /* @__PURE__ */ new Set();
43905
44210
  for (const d of approved) {
43906
- const failingIds = failing.filter((id) => !taken.has(id) && isRowOf(id, d));
44211
+ const failingIds = failing.filter((id) => !taken.has(id) && isRowOf2(id, d));
43907
44212
  if (failingIds.length === 0) continue;
43908
44213
  for (const id of failingIds) taken.add(id);
43909
- const totalRows = Math.max(failingIds.length, after.filter((id) => isRowOf(id, d)).length);
44214
+ const totalRows = Math.max(failingIds.length, after.filter((id) => isRowOf2(id, d)).length);
43910
44215
  const examples = [];
43911
44216
  for (const id of failingIds) {
43912
44217
  if (examples.length >= MAX_MISFIT_EXAMPLES) break;
@@ -43927,6 +44232,31 @@ function misfitSentence(misfits, max = 600) {
43927
44232
  return clip3(parts.join("; "), max);
43928
44233
  }
43929
44234
 
44235
+ // src/testVerification.ts
44236
+ function verifyTier(i2) {
44237
+ if (!i2.command || i2.command.trim() === "") return { tier: "unverified", reason: "no_command" };
44238
+ const before = i2.baseline.results !== null;
44239
+ const now = i2.after.results !== null;
44240
+ if (before && now) return { tier: "report" };
44241
+ if (before !== now) return { tier: "unverified", reason: "report_one_side" };
44242
+ if (i2.baseline.outcome !== "success") return { tier: "unverified", reason: "failing_before" };
44243
+ return i2.after.outcome === "success" ? { tier: "exit_code", pass: true } : { tier: "exit_code", pass: false };
44244
+ }
44245
+ var UNVERIFIED_PREFIX = "QuikPilot could not check this change against the project's tests";
44246
+ var UNVERIFIED_WHY = {
44247
+ no_command: "the project has no Test command. Set one in the project's QuikPilot settings",
44248
+ failing_before: "the tests already failed before the change and no test report was found, so a failure after it cannot be told apart from the ones that were there",
44249
+ report_one_side: "a test report was written on one side of the change only (before it or after it, not both), so the two runs cannot be compared. Check that the Test command writes its JUnit report the same way every time"
44250
+ };
44251
+ function unverifiedMessage(reason) {
44252
+ return `${UNVERIFIED_PREFIX}: ${UNVERIFIED_WHY[reason]}. Nothing was pushed.`;
44253
+ }
44254
+ var EXIT_CODE_FAILED_PREFIX = "QuikPilot's change made the project's tests fail";
44255
+ function exitCodeFailedMessage() {
44256
+ return `${EXIT_CODE_FAILED_PREFIX} \u2014 the Test command passed before the change and failed after it. No test report was found to say which test, so QuikPilot could not fix it. Nothing was pushed.`;
44257
+ }
44258
+ var EXIT_CODE_ONLY_NOTE = "The change was checked by the Test command's result only: it passed before and after the change, but no test report was found, so QuikPilot could not see individual tests or confirm that its new tests ran.";
44259
+
43930
44260
  // src/testPlacementCheck.ts
43931
44261
  function isDiscovered(targetPath, discoveredFiles) {
43932
44262
  const normalized = targetPath.replace(/\\/g, "/");
@@ -44326,6 +44656,7 @@ async function verifyChange(ctx, results, undoable) {
44326
44656
  runCommand(packet.commands.lint, "Lint");
44327
44657
  timing("lint", lintStartedAt, packet.commands.lint);
44328
44658
  stage = "gate";
44659
+ if (!packet.commands.test || packet.commands.test.trim() === "") return fail(new Error(unverifiedMessage("no_command")));
44329
44660
  const gateStartedAt = now();
44330
44661
  const leftMs = ctx.jobStopAtMs === void 0 ? Number.NaN : ctx.jobStopAtMs - gateStartedAt;
44331
44662
  const limit = testLimitsOff() ? null : gateLimitMs({ baselineMs: ctx.baselineMs, leftMs });
@@ -44347,6 +44678,17 @@ async function verifyChange(ctx, results, undoable) {
44347
44678
  warnings.push(w);
44348
44679
  console.warn(`QuikPilot test warning (not blocking): ${w}`);
44349
44680
  }
44681
+ const verification = verifyTier({ command: packet.commands.test, baseline, after });
44682
+ if (verification.tier === "unverified") return fail(new Error(unverifiedMessage(verification.reason)));
44683
+ if (verification.tier === "exit_code") {
44684
+ outputs.testVerification = "exit_code";
44685
+ console.log(JSON.stringify({ event: "gate.verified_by", tier: "exit_code", pass: verification.pass }));
44686
+ if (!verification.pass) return fail(new Error(exitCodeFailedMessage()));
44687
+ warnings.push(EXIT_CODE_ONLY_NOTE);
44688
+ console.warn(`QuikPilot test warning (not blocking): ${EXIT_CODE_ONLY_NOTE}`);
44689
+ } else {
44690
+ outputs.testVerification = "report";
44691
+ }
44350
44692
  const check = checkForRegressions(baseline, after);
44351
44693
  if (check.blocked) {
44352
44694
  const readable = Boolean(baseline.results && after.results);
@@ -44662,7 +45004,7 @@ function workspacePatterns(readText) {
44662
45004
  }
44663
45005
  function globMatcher(pattern) {
44664
45006
  const parts = pattern.replace(/^\.\//, "").replace(/\/+$/, "").split("/");
44665
- const escape = (s) => s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
45007
+ const escape2 = (s) => s.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
44666
45008
  let re = "";
44667
45009
  parts.forEach((part, i2) => {
44668
45010
  const first = i2 === 0;
@@ -44670,7 +45012,7 @@ function globMatcher(pattern) {
44670
45012
  re += first ? "(?:[^/]+/)*" : "(?:/[^/]+)*";
44671
45013
  return;
44672
45014
  }
44673
- const segment = part.split("*").map(escape).join("[^/]*");
45015
+ const segment = part.split("*").map(escape2).join("[^/]*");
44674
45016
  re += first || i2 === 1 && parts[0] === "**" ? segment : `/${segment}`;
44675
45017
  });
44676
45018
  return new RegExp(`^${re}$`);
@@ -44966,7 +45308,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
44966
45308
  var REPORT_COPY = "final-test-report.xml";
44967
45309
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
44968
45310
  var MAX_FILES = 200;
44969
- var RUNNER_VERSION = true ? "9.3.0-rc.47" : "dev";
45311
+ var RUNNER_VERSION = true ? "9.3.0-rc.49" : "dev";
44970
45312
  function safeDestination(base, repoPath) {
44971
45313
  if (!repoPath || (0, import_node_path24.isAbsolute)(repoPath)) return null;
44972
45314
  const destination = (0, import_node_path24.resolve)(base, repoPath);