Skip to content

Commit

Permalink
test_trace_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki committed Nov 30, 2022
1 parent 599818a commit a859fcb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_trace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from ice import trace
import pytest


@pytest.mark.anyio
async def test_trace_blocks():
trace.enable_trace()
current_trace = trace.trace_var.get()
assert trace.trace_enabled()
assert current_trace

long = "a" * trace.Trace.BLOCK_LENGTH
assert trace.emit_block("foo") == [0, 0]
assert trace.emit_block("bar") == [0, 1]
assert trace.emit_block(long) == [0, 2]
assert trace.emit_block("baz") == [1, 0]
assert trace.emit_block("quux") == [1, 1]

assert (current_trace.dir / "block_0.jsonl").read_text() == f'"foo"\n"bar"\n"{long}"\nend'

0 comments on commit a859fcb

Please sign in to comment.