Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/tui/test/live.rip
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ test "lanes in flight: a spinner, the name, a bar against the last run — by ti
styledRow = cells.styled(view.ansi)[4]
ok styledRow.startsWith(' «#22d3ee»⠹«» root (extended tier) «#2cd6d4»█████████▋«dim»────'), "the bar is 24% of the way from cyan to green: #{styledRow}"

test "a lane that starts between two ticks has spent nothing yet: its bar is empty and its colors are colors", ->
board MEMORY(), ({ view, tally, hear, lanes }) ->
hear 0, { type: 'plan' }, { type: 'finish', result: { lane: lanes[3], status: 'skip', ms: 0, why: lanes[3].skip, output: '' } }, { type: 'start', lane: lanes[0] }
# The lanes' clock moves on and a lane starts before the board's next
# tick, so the board's time is older than the lane's start.
tally.now = -> 8000
tally.hear { type: 'start', lane: lanes[1] }
frame = rows view.frame()
ok frame.some((row) -> row.includes('packages/sites')), frame.join '\n'
ok not /#[0-9a-f]{7}/.test(view.ansi), 'no color of seven digits'

test "a lane past its last duration turns amber, and red past twice it; a first run sweeps a bar with nothing to fill it by", ->
board MEMORY(), ({ view, hear, lanes }) ->
hear 0, { type: 'plan' }, { type: 'start', lane: lanes[0] }
Expand Down
7 changes: 5 additions & 2 deletions scripts/test-live.rip
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ hue =! (name) -> if screen.colors >= 256 then HUES[name] else NAMED[name]

# A true color `t` of the way from one to the other.
blend =! (from, to, t) ->
t = Math.min 1, Math.max(0, t)
mix = (k) -> Math.round(parseInt(from.slice(k, k + 2), 16) * (1 - t) + parseInt(to.slice(k, k + 2), 16) * t)
'#' + ((mix(k).toString(16).padStart 2, '0') for k in [1, 3, 5]).join ''

Expand Down Expand Up @@ -228,7 +229,7 @@ export class Tally
return null unless weight
total += weight
done += weight if entry.result
done += Math.min(now - entry.at, weight) if entry.status is 'running'
done += Math.min(Math.max(0, now - entry.at), weight) if entry.status is 'running'
if total then done / total else null

# ── The memory of the last run ────────────────────────────────────────────────
Expand Down Expand Up @@ -376,7 +377,9 @@ export Board = component

running ~=
for entry in @tally.entries when entry.status is 'running'
spent = now - entry.at
# `now` is taken once a tick and a lane's start as it arrives, so a
# lane that starts between two ticks has spent nothing yet.
spent = Math.max 0, now - entry.at
weight = @tally.estimate entry.lane.label
counts = @tally.counted entry.lane.label
record = @tally.memory.lanes[entry.lane.label]
Expand Down
Loading