Skip to content

Commit 3397bf7

Browse files
committed
Implement reset_stdio_counter()
1 parent d3be198 commit 3397bf7

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

docs/src/_changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Changelog](https://keepachangelog.com).
99

1010
## Unreleased
1111

12+
### Added
13+
- Implemented [`reset_stdio_count()`](@ref) to provide a public API for
14+
resetting the stdio count ([#1172]).
15+
1216
### Changed
1317
- IJulia was completely refactored to minimize global state ([#1172]). This
1418
allows for better testing (for the first time we can test kernel execution)

docs/src/library/public.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ IJulia.load_string
4545
```@docs
4646
IJulia.readprompt
4747
IJulia.set_max_stdio
48+
IJulia.reset_stdio_count
4849
```

src/IJulia.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,15 @@ function set_max_stdio(max_output::Integer; kernel)
483483
kernel.max_output_per_request[] = max_output
484484
end
485485

486+
"""
487+
reset_stdio_count()
488+
489+
Reset the count of the number of bytes written to stdout/stderr. See
490+
[`set_max_stdio`](@ref) for more details.
491+
"""
492+
function reset_stdio_count(kernel=_default_kernel)
493+
kernel.stdio_bytes = 0
494+
end
486495

487496
#######################################################################
488497

test/stdio.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ using IJulia
3939
end
4040
end
4141

42+
kernel.stdio_bytes = 42
43+
IJulia.reset_stdio_count(kernel)
44+
@test kernel.stdio_bytes == 0
4245
end

0 commit comments

Comments
 (0)