-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppressor.jl don't capture all stdout
from CBinding
ed function
#46
Comments
Here is the asciinema https://asciinema.org/a/523250. |
Here is a little testing script, similar to JuliaDocs/IOCapture.jl#16 (comment): Test scriptusing Suppressor, Test
nbytes = [10^0, 10^1, 10^2, 10^3, 10^4, 10^5, 10^6]
function test_print(str)
out = @capture_out begin
print(str)
end
# save in a bool to avoid printing long strings when test fails
cap_output_equals_str = out == str
@test cap_output_equals_str
end
function test_puts(str)
retval = 0
out = @capture_out begin
retval = @ccall puts(str::Cstring)::Cint
end
@test retval == length(str) + 1
# save in a bool to avoid printing long strings when test fails
cap_output_equals_str = out == str * "\n"
@test cap_output_equals_str
end
function test_puts_flush(str)
retval = 0
out = @capture_out begin
retval = @ccall puts(str::Cstring)::Cint
Libc.flush_cstdio()
end
@test retval == length(str) + 1
# save in a bool to avoid printing long strings when test fails
cap_output_equals_str = out == str * "\n"
@test cap_output_equals_str
end
function run_testset(fn::Function)
@testset verbose=true "$fn" begin
for (i, n) in enumerate(nbytes)
# print different letters for each test
c = collect('A':'Z')[i]
@testset "$n" begin
fn(c^n)
end
end
end
end
@testset "Suppressor cstdio" verbose=true begin
run_testset(test_print)
run_testset(test_puts)
run_testset(test_puts_flush)
end Test script output
If you look at the errors, you can see that with From these results it seems to me that just adding a single |
Interesting, I need to look at it to know how to correct it for good. Thanks for the test script. |
I'm making a package called LibTeXPrintf.jl in which I need to capture
stdout
to define some variables.But
@capture_out
doesn't capture all the output unless I had run already a printing operation without capturing it. I'll upload a MWE and an asciinema once I have both.The text was updated successfully, but these errors were encountered: