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

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
@@ -38769,7 +38769,7 @@ var REJECT_MESSAGES = {
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
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.",
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,39 @@ 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
+ }
38783
38816
  var NOT_FOUND_LEAD = "The tests in that file are: ";
38784
38817
  var NOT_FOUND_TAIL = ". The title is the name of the test function.";
38785
38818
  function titlesHint(tests, room = Number.POSITIVE_INFINITY) {
@@ -39042,7 +39075,10 @@ var TestConflictTool = class {
39042
39075
  const { t: test, index } = matches[0];
39043
39076
  const isTable = index >= located.tests.length;
39044
39077
  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");
39078
+ if (!applied.ok) {
39079
+ if (applied.refusals[0]?.kind !== "ambiguous") return this.reject("no_match");
39080
+ return this.reject("ambiguous", helper ? void 0 : ambiguityHint(lf, r.find, test) || void 0);
39081
+ }
39046
39082
  const at2 = lf.indexOf(r.find);
39047
39083
  const changeLine = lineAt(lf, at2);
39048
39084
  const lastLine = lineAt(lf, at2 + r.find.length - 1);
@@ -54144,7 +54180,7 @@ var FAILURE_ARTIFACT_DIR = "quikpilot-failure";
54144
54180
  var REPORT_COPY = "final-test-report.xml";
54145
54181
  var MAX_REPORT_BYTES = 5 * 1024 * 1024;
54146
54182
  var MAX_FILES = 200;
54147
- var RUNNER_VERSION = true ? "9.3.0-rc.81" : "dev";
54183
+ var RUNNER_VERSION = true ? "9.3.0-rc.82" : "dev";
54148
54184
  function safeDestination(base, repoPath) {
54149
54185
  if (!repoPath || (0, import_node_path28.isAbsolute)(repoPath)) return null;
54150
54186
  const destination = (0, import_node_path28.resolve)(base, repoPath);