Skip to content

Commit b229cd2

Browse files
committed
Remove the FILE ptr versions of the print_statistics functions to avoid issues on Windows.
1 parent 934f031 commit b229cd2

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

src/managed_scip.jl

+1-31
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,8 @@ for (scip_statistics_func, statistics_func) in zip(SCIP_STATISTICS_FUNCS, STATIS
287287
@eval begin
288288
"""
289289
$($statistics_func)(mscip::ManagedSCIP)
290-
$($statistics_func)(mscip::ManagedSCIP, file_descriptor::RawFD)
291-
$($statistics_func)(mscip::ManagedSCIP, stream::Union{Base.Filesystem.File, IOStream})
292-
$($statistics_func)(mscip::ManagedSCIP, filename::AbstractString)
293290
294-
Print statistics (calls `$($scip_statistics_func)`).
295-
296-
The one-argument version prints to standard output.
297-
298-
Note that the method that takes a stream only applies to synchronous
299-
`File`s and `IOStream`s. In particular, it doesn't apply to `stdout`.
291+
Print statistics (calls `$($scip_statistics_func)`) to standard output.
300292
"""
301293
function $statistics_func end
302294

@@ -305,27 +297,5 @@ for (scip_statistics_func, statistics_func) in zip(SCIP_STATISTICS_FUNCS, STATIS
305297
ret !== nothing && @assert ret == SCIP_OKAY
306298
return nothing
307299
end
308-
309-
function $statistics_func(mscip::ManagedSCIP, file_descriptor::RawFD)
310-
file = Libc.FILE(file_descriptor, "w")
311-
try
312-
ret = $scip_statistics_func(mscip, file)
313-
ret !== nothing && @assert ret == SCIP_OKAY
314-
finally
315-
close(file)
316-
end
317-
return nothing
318-
end
319-
320-
function $statistics_func(mscip::ManagedSCIP, stream::Union{Base.Filesystem.File, IOStream})
321-
return $statistics_func(mscip, fd(stream))
322-
end
323-
324-
function $statistics_func(mscip::ManagedSCIP, filename::AbstractString)
325-
open(filename, write=true) do io
326-
$statistics_func(mscip, RawFD(fd(io)))
327-
end
328-
return nothing
329-
end
330300
end
331301
end

test/managed_scip.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,17 @@ end
107107
mktempdir() do dir
108108
filename = joinpath(dir, "statistics.txt")
109109
@test !isfile(filename)
110-
statistics_func(mscip, filename)
110+
open(filename, write=true) do io
111+
redirect_stdout(io) do
112+
statistics_func(mscip)
113+
end
114+
end
111115
@test isfile(filename)
116+
if statistics_func == SCIP.print_statistics
117+
# Ensure that at least `print_statistics` produces output
118+
# (Not all statistics functions do for this simple model.)
119+
@test filesize(filename) > 0
120+
end
112121
end
113122
end
114123
end

0 commit comments

Comments
 (0)