diff --git a/Project.toml b/Project.toml index e41d9fb..6d54661 100644 --- a/Project.toml +++ b/Project.toml @@ -25,7 +25,7 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" ExplicitImports = "1" HTTP = "1" JET = "0.9, 0.10, 0.11" -JSON3 = "1" +JSON3 = "1.1" JuliaFormatter = "2" LocalRegistry = "0.5" SafeTestsets = "0.0.1, 0.1, 1" diff --git a/src/import_timing_analysis.jl b/src/import_timing_analysis.jl index 3f2dc94..407720a 100644 --- a/src/import_timing_analysis.jl +++ b/src/import_timing_analysis.jl @@ -69,18 +69,22 @@ function analyze_import_timing_in_process(repo_path::String, package_name::Strin # Capture timing data in a structured way timing_data = [] - raw_output = IOBuffer() - - # Redirect stdout to capture the timing output - original_stdout = stdout - redirect_stdout(raw_output) do - # Run with time imports flag - Base.eval(Main, :(using InteractiveUtils)) - Base.eval(Main, :(@time_imports using \$(Symbol("$package_name")))) + + # Redirect stdout to a temporary file to capture the timing output. + # `redirect_stdout` accepts a file IOStream (not an IOBuffer), so we + # write to a temp file and read it back. + timing_capture_file = tempname() + open(timing_capture_file, "w") do capture_io + redirect_stdout(capture_io) do + # Run with time imports flag + Base.eval(Main, :(using InteractiveUtils)) + Base.eval(Main, :(@time_imports using \$(Symbol("$package_name")))) + end end - + # Process the captured output - raw_str = String(take!(raw_output)) + raw_str = read(timing_capture_file, String) + rm(timing_capture_file; force = true) lines = split(raw_str, '\n') for line in lines diff --git a/test/import_timing_analysis_tests.jl b/test/import_timing_analysis_tests.jl index 2612401..cef234c 100644 --- a/test/import_timing_analysis_tests.jl +++ b/test/import_timing_analysis_tests.jl @@ -1,5 +1,6 @@ using OrgMaintenanceScripts using Test +using Dates @testset "Import Timing Analysis Tests" begin # Create a simple test package structure diff --git a/test/invalidation_analysis_tests.jl b/test/invalidation_analysis_tests.jl index 22a5101..e8b1dcd 100644 --- a/test/invalidation_analysis_tests.jl +++ b/test/invalidation_analysis_tests.jl @@ -1,5 +1,6 @@ using OrgMaintenanceScripts using Test +using Dates @testset "Invalidation Analysis Tests" begin # Create a simple test package structure