Public: anyone can read this; the crew can change it.

Stopwatch.line can say "after the run started", with the deploy line unchanged #3784

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/3778-stopwatch-line-can-say-after-the-run-sta → main 1 commit fork

  • Merged. scout/3778-stopwatch-line-can-say-after-the-run-sta was merged into main as fd74976.

Review

Sign in to review this change.
2 files changed +32 −3
src/apps/timing.ts +4 −3
@@ -37,10 +37,11 @@ export class Stopwatch {
3737
3838 /**
3939 * `timing: <what> 0.4s after the deploy started — turn 0.0s · checkout
40 * 0.3s · …`, every lap so far in the order it was taken.
40 * 0.3s · …`, every lap so far in the order it was taken. `since` names
41 * the start in the line's words; a run says "the run started".
4142 */
42 line(what: string): string {
43 line(what: string, since = "the deploy started"): string {
4344 const steps = this.laps.map((l) => `${l.name} ${seconds(l.ms)}`).join(" · ");
44 return `timing: ${what} ${seconds(this.elapsed())} after the deploy started${steps === "" ? "" : ` — ${steps}`}`;
45 return `timing: ${what} ${seconds(this.elapsed())} after ${since}${steps === "" ? "" : ` — ${steps}`}`;
4546 }
4647 }
test/apps-timing-line.test.ts added +28
@@ -0,0 +1,28 @@
1 import { expect, test } from "bun:test";
2 import { Stopwatch } from "../src/apps/timing.ts";
3
4 const watch = () => {
5 let t = 0;
6 const w = new Stopwatch(() => t);
7 return { w, at: (ms: number) => (t = ms) };
8 };
9
10 test("the deploy line keeps its wording", () => {
11 const { w, at } = watch();
12 at(300);
13 w.lap("turn");
14 at(1000);
15 expect(w.line("serving")).toBe("timing: serving 1.0s after the deploy started — turn 0.3s");
16 });
17
18 test("a run line says it counts from the run started", () => {
19 const { w, at } = watch();
20 at(1000);
21 w.lap("clone");
22 at(1500);
23 w.lap("brief");
24 at(12000);
25 expect(w.line("run ended", "the run started")).toBe(
26 "timing: run ended 12.0s after the run started — clone 1.0s · brief 0.5s",
27 );
28 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs