@quikit/quikpilot-runner 9.3.0-rc.81 → 9.3.0-rc.83

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
@@ -38768,8 +38768,8 @@ var REJECT_MESSAGES = {
38768
38768
  unsupported_language: "Only JavaScript, TypeScript, Python, Go and Java test files can be reported.",
38769
38769
  title_not_found: "No test with that title was found in that file. Copy the title exactly as the file writes it. For a test written once for each row of a table, that is the title in the file with its $name or %s placeholders as they are, not the name of one row.",
38770
38770
  title_not_unique: "More than one test in that file has that title, so it cannot be told which one you mean.",
38771
- no_match: "find was not found in that file. Copy it exactly as read_file shows it.",
38772
- ambiguous: "find matches more than once in that file. Make it longer so it matches once.",
38771
+ no_match: "find was not found in that file. Copy it exactly as read_file shows it, with its tabs and spaces.",
38772
+ ambiguous: "find matches more than once in that file. Make it longer so it matches once, with lines of this test just before or just after it.",
38773
38773
  find_outside_test: "find is not inside that test. It must be lines of that test.",
38774
38774
  beyond_expectations: "replace changes more than the test's expected values. Only the expect(...) statements (and the title) may differ from find; the set-up and the call the test makes must stay as they are.",
38775
38775
  not_passing_before: "That test did not pass on the code before this run, so it does not assert how the code behaves today. It is not a conflict.",
@@ -38780,6 +38780,89 @@ var REJECT_MESSAGES = {
38780
38780
  generated_test: "That test is written once and run for each row of a table (describe.each or it.each), and its rows were not found in the test run made before your change, so it cannot be checked. Do not report it again: answer CANNOT_COMPLETE, and in your summary name the test and the case it contradicts. A person will change it."
38781
38781
  };
38782
38782
  var OTHER_LANGUAGE_EXPECTATIONS = "In this language only literal values (text, numbers, true/false), assertion statements, comments and the test's name may differ from find; everything else the test does must stay as it is.";
38783
+ var AMBIGUOUS_LINES_SHOWN = 6;
38784
+ var AMBIGUOUS_GROW_MAX = 8;
38785
+ function occurrences2(text3, part, cap2) {
38786
+ const at2 = [];
38787
+ for (let i3 = text3.indexOf(part); i3 !== -1 && at2.length < cap2; i3 = text3.indexOf(part, i3 + 1)) at2.push(i3);
38788
+ return at2;
38789
+ }
38790
+ function ambiguityHint(lf, find, test) {
38791
+ const found = occurrences2(lf, find, 100);
38792
+ if (found.length < 2) return "";
38793
+ const lines = found.map((i3) => lineAt(lf, i3));
38794
+ const shown = lines.slice(0, AMBIGUOUS_LINES_SHOWN).join(", ") + (lines.length > AMBIGUOUS_LINES_SHOWN ? ", ..." : "");
38795
+ const first = test.bodyStartLine ?? test.startLine;
38796
+ const inside3 = found.filter((i3) => lineAt(lf, i3) >= first && lineAt(lf, i3 + find.length - 1) <= test.endLine);
38797
+ const where = `(lines ${shown}).`;
38798
+ if (inside3.length === 0) return `It matches at ${where} None of them is inside that test; the test is at lines ${test.startLine} to ${test.endLine}.`;
38799
+ if (inside3.length > 1) return `It matches ${where} It matches more than once inside this test, so no extra line from the test can tell the copies apart; copy the lines of the one you mean together with what stands next to it.`;
38800
+ const at2 = inside3[0];
38801
+ const startLine = lineAt(lf, at2);
38802
+ const endLine = lineAt(lf, at2 + find.length - 1);
38803
+ const starts = [0];
38804
+ for (let i3 = 0; i3 < lf.length; i3++) if (lf.charCodeAt(i3) === 10) starts.push(i3 + 1);
38805
+ const head = `It matches at ${where} The copy in this test is at line ${startLine}.`;
38806
+ for (let k = 1; k <= AMBIGUOUS_GROW_MAX && endLine + k <= test.endLine; k++) {
38807
+ const stop2 = endLine + k < starts.length ? starts[endLine + k] - 1 : lf.length;
38808
+ if (occurrences2(lf, lf.slice(at2, stop2), 2).length === 1) return `${head} Add the next ${k} line(s) after it (up to line ${endLine + k}) so it matches once.`;
38809
+ }
38810
+ for (let k = 1; k <= AMBIGUOUS_GROW_MAX && startLine - k >= first; k++) {
38811
+ const from = starts[startLine - k - 1];
38812
+ if (occurrences2(lf, lf.slice(from, at2 + find.length), 2).length === 1) return `${head} Add the ${k} line(s) before it (from line ${startLine - k}) so it matches once.`;
38813
+ }
38814
+ return `${head} Add lines of this test around it until it matches once.`;
38815
+ }
38816
+ function indentOf2(line2) {
38817
+ const lead = /^[ \t]*/.exec(line2)[0];
38818
+ let tabs = 0;
38819
+ for (const c of lead) if (c === " ") tabs++;
38820
+ return { tabs, spaces: lead.length - tabs };
38821
+ }
38822
+ function indentWords(i3) {
38823
+ const parts2 = [];
38824
+ if (i3.tabs > 0) parts2.push(`${i3.tabs} tab(s)`);
38825
+ if (i3.spaces > 0) parts2.push(`${i3.spaces} space(s)`);
38826
+ return parts2.length > 0 ? parts2.join(" and ") : "no indent";
38827
+ }
38828
+ function mismatchHint(lf, find, test) {
38829
+ const want = find.split(/\r?\n/);
38830
+ const have = lf.split("\n");
38831
+ const first = want[0].trim();
38832
+ let at2 = -1;
38833
+ let k = 0;
38834
+ let inTest = false;
38835
+ if (first !== "") {
38836
+ for (let s = 0; s < have.length; s++) {
38837
+ if (have[s].trim() !== first) continue;
38838
+ let n = 1;
38839
+ while (n < want.length && s + n < have.length && have[s + n].trim() === want[n].trim()) n++;
38840
+ const inside3 = test !== void 0 && s + 1 >= test.startLine && s + n <= test.endLine;
38841
+ if (n > k || n === k && inside3 && !inTest) {
38842
+ at2 = s;
38843
+ k = n;
38844
+ inTest = inside3;
38845
+ }
38846
+ }
38847
+ }
38848
+ if (at2 < 0) return "No line of that file equals the first line of find, even ignoring spaces and tabs. Copy whole lines as read_file shows them.";
38849
+ if (k < want.length) {
38850
+ const ends = at2 + k >= have.length;
38851
+ return `The first line of find is at line ${at2 + 1} of the file; lines 1 to ${k} of find agree there, but line ${k + 1} of find does not match ${ends ? "anything: the file ends" : `line ${at2 + k + 1} of the file`}, even ignoring spaces and tabs. Check line ${k + 1} of find against the file.`;
38852
+ }
38853
+ const head = `It matches lines ${at2 + 1} to ${at2 + k} of the file when spaces and tabs are ignored, so only whitespace differs.`;
38854
+ const tail2 = "Copy the lines exactly as read_file shows them, with their tabs and spaces.";
38855
+ for (let j = 0; j < want.length; j++) {
38856
+ const a = want[j];
38857
+ const b = have[at2 + j];
38858
+ if (a === b) continue;
38859
+ const ai = indentOf2(a);
38860
+ const bi = indentOf2(b);
38861
+ if (ai.tabs !== bi.tabs || ai.spaces !== bi.spaces) return `${head} Line ${j + 1} of find starts with ${indentWords(ai)}; line ${at2 + j + 1} of the file starts with ${indentWords(bi)}. ${tail2}`;
38862
+ return `${head} Line ${j + 1} of find differs from line ${at2 + j + 1} of the file only after its indent (spaces at the end of the line, or line endings). ${tail2}`;
38863
+ }
38864
+ return `${head} ${find.includes("\r") ? "find has Windows line endings; the file is read with plain ones. " : ""}${tail2}`;
38865
+ }
38783
38866
  var NOT_FOUND_LEAD = "The tests in that file are: ";
38784
38867
  var NOT_FOUND_TAIL = ". The title is the name of the test function.";
38785
38868
  function titlesHint(tests, room = Number.POSITIVE_INFINITY) {
@@ -39042,7 +39125,10 @@ var TestConflictTool = class {
39042
39125
  const { t: test, index } = matches[0];
39043
39126
  const isTable = index >= located.tests.length;
39044
39127
  const applied = applyEdits(lf, [{ find: r.find, replace: r.replace }]);
39045
- if (!applied.ok) return this.reject(applied.refusals[0]?.kind === "ambiguous" ? "ambiguous" : "no_match");
39128
+ if (!applied.ok) {
39129
+ if (applied.refusals[0]?.kind !== "ambiguous") return this.reject("no_match", helper ? void 0 : mismatchHint(lf, r.find, test));
39130
+ return this.reject("ambiguous", helper ? void 0 : ambiguityHint(lf, r.find, test) || void 0);
39131
+ }
39046
39132
  const at2 = lf.indexOf(r.find);
39047
39133
  const changeLine = lineAt(lf, at2);
39048
39134
  const lastLine = lineAt(lf, at2 + r.find.length - 1);
@@ -54144,7 +54230,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54144
54230
  var REPORT_COPY = "final-test-report.xml";
54145
54231
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54146
54232
  var MAX_FILES = 200;
54147
- var RUNNER_VERSION = true ? "9.3.0-rc.81" : "dev";
54233
+ var RUNNER_VERSION = true ? "9.3.0-rc.83" : "dev";
54148
54234
  function safeDestination(base, repoPath) {
54149
54235
  if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
54150
54236
  const destination = (0, import_node_path28.resolve)(base, repoPath);