testAMergeLeftToSettleWaitsApart

tcmts.cli.test.e2e.merge.testAMergeLeftToSettleWaitsApart · #n5cih3sg · term

A merge that leaves conflicts isn't made: the branch stays as it was, the conflicts' sides are written to scratch files to settle them in, and commands on the branch work on the merge as merged; once nothing's left to settle, the branch has the merge.

import { tcmIn } from "#codebase/tcmts/cli/test/e2e/harness";
import { withConflicts } from "#codebase/tcmts/cli/test/e2e/merge";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

export const testAMergeLeftToSettleWaitsApart = () => {
  const { dir, tcm, merged } = withConflicts("merge waits apart");
  assert.match(merged.out, /not merged yet/, merged.out);
  assert.match(merged.out, /s is as it was/);
  // s, as another process reads it, has its own k (no conflict, no merge entry)
  const own = tcm("view", "lib.k", "--branch", "s");
  assert.match(own, /const a = 10;/);
  assert.doesNotMatch(own, /const a = 100;/);
  assert.doesNotMatch(tcm("history", "--branch", "s"), /merge main/);
  // the conflicts' sides, merged where they can be, to settle
  assert.ok(fs.existsSync(path.join(dir, "lib.k.ts")), fs.readdirSync(dir).join(" "));
  // commands on s work on the merge
  const todo = tcm("todo");
  assert.match(todo, /merging main into s: not finished/);
  assert.match(todo, /conflict lib\.k/);
  tcm("resolve", "lib.k", "--ours");
  assert.match(tcm("todo"), /conflict lib\.m/, "one left: still apart");
  assert.doesNotMatch(tcm("history", "--branch", "s"), /merge main/);
  const last = tcmIn(dir, "resolve", "lib.m", "--theirs");
  assert.equal(last.status, 0, last.out);
  assert.match(last.out, /s has the merge now/);
  assert.match(tcm("history", "--branch", "s"), /merge main/);
  assert.equal(tcm("run", "lib.user").trim(), String((10 + 2 + 3 + 3) * 10));
  assert.match(tcm("todo"), /nothing to do/);
}

uses