From 498ac51307412adc29d6d4a6240ae7b98d55621e Mon Sep 17 00:00:00 2001 From: Tommaso Negri Date: Wed, 14 Oct 2026 22:30:19 +0200 Subject: improve performances --- Tests/barTests/BlockRefreshTests.swift | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/barTests/BlockRefreshTests.swift (limited to 'Tests/barTests/BlockRefreshTests.swift') diff --git a/Tests/barTests/BlockRefreshTests.swift b/Tests/barTests/BlockRefreshTests.swift new file mode 100644 index 0000000..495bcac --- /dev/null +++ b/Tests/barTests/BlockRefreshTests.swift @@ -0,0 +1,29 @@ +import Combine +import Testing +@testable import bar + +@Test @MainActor func unchangedOutputDoesNotPublish() { + let block = Block(name: "test", placement: .left, command: "") + var publications = 0 + let subscription = block.$cells.dropFirst().sink { _ in publications += 1 } + defer { subscription.cancel() } + + block.apply(["same", "same"]) + block.apply(["same", "same"]) + #expect(publications == 1) + #expect(block.cells.map(\.rawValue) == ["same", "same"]) + + // A highlight-only change must still publish, even with identical text. + block.apply(["&!1 same", "same"]) + #expect(publications == 2) + #expect(block.cells[0].id == " same:1") + block.apply([]) + block.apply([]) + #expect(publications == 3) + #expect(block.cells.isEmpty) +} + +@Test func runnerPreservesOutputAcrossPoolDrain() { + #expect(Runner.run("printf 'first\\n\\nlast\\n'") == ["first", "", "last"]) + #expect(Runner.run("exit 1") == ["ERROR"]) +} -- cgit v1.2.3