From 9f348ff6d02d2f6dd93942a98ce2c8b18bd2596e Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Sun, 20 Sep 2026 23:24:57 -0300 Subject: [PATCH] Split off AbstractTestRecord and TestRecord --- src/ParallelTestRunner.jl | 61 ++------------------------------------- src/records.jl | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 58 deletions(-) create mode 100644 src/records.jl diff --git a/src/ParallelTestRunner.jl b/src/ParallelTestRunner.jl index d8aaf2c..5aabac3 100644 --- a/src/ParallelTestRunner.jl +++ b/src/ParallelTestRunner.jl @@ -26,6 +26,9 @@ include("ptrworker.jl") # find_tests, ParsedArgs, extract_flag!, parse_args, filter_tests!, partition_tests include("args.jl") +# AbstractTestRecord, TestRecord, parent, memory_usage, init_time, getindex +include("records.jl") + include("history.jl") using .TestHistory @@ -59,64 +62,6 @@ function get_max_worker_rss() return mb * 2^20 end -""" - AbstractTestRecord - -Abstract supertype for per-test result records. [`TestRecord`](@ref) is the -default concrete subtype, carrying the captured test set and baseline timing / -memory statistics. Custom subtypes can attach extra per-test data (e.g. GPU -statistics) by carrying a `base::TestRecord` field and dispatching -[`execute`](@ref) on the new type. See the `RecordType` argument of -[`runtests`](@ref) for how to plug a custom record type into a run. -""" -abstract type AbstractTestRecord end - -""" - TestRecord <: AbstractTestRecord - -Default per-test record. Holds the captured `DefaultTestSet` alongside the -baseline timing and memory statistics that [`runtests`](@ref) prints and -persists. Custom [`AbstractTestRecord`](@ref) subtypes wrap a `TestRecord` in a -`base` field; [`parent`](@ref) returns that baseline so the default `print_*` -methods work unchanged. -""" -struct TestRecord <: AbstractTestRecord - value::DefaultTestSet - - # stats - time::Float64 - bytes::UInt64 - gctime::Float64 - compile_time::Float64 - rss::UInt64 - total_time::Float64 -end - -""" - parent(rec::AbstractTestRecord) -> TestRecord - -Return the [`TestRecord`](@ref) baseline that a custom record type wraps. By -default, subtypes of `AbstractTestRecord` are expected to carry a -`base::TestRecord` field; override `parent` for a different layout. The default -`print_*` methods read baseline fields through `parent`, so wrapped types -inherit the standard output unchanged. -""" -Base.parent(rec::AbstractTestRecord) = rec.base -Base.parent(rec::TestRecord) = rec - -function memory_usage(rec::AbstractTestRecord) - return parent(rec).rss -end - -function init_time(rec::AbstractTestRecord) - base = parent(rec) - return base.total_time - base.time -end - -function Base.getindex(rec::AbstractTestRecord) - return parent(rec).value -end - # # overridable I/O context for pretty-printing diff --git a/src/records.jl b/src/records.jl new file mode 100644 index 0000000..1f88f27 --- /dev/null +++ b/src/records.jl @@ -0,0 +1,59 @@ +# Per-test result records + +""" + AbstractTestRecord + +Abstract supertype for per-test result records. [`TestRecord`](@ref) is the +default concrete subtype, carrying the captured test set and baseline timing / +memory statistics. Custom subtypes can attach extra per-test data (e.g. GPU +statistics) by carrying a `base::TestRecord` field and dispatching +[`execute`](@ref) on the new type. See the `RecordType` argument of +[`runtests`](@ref) for how to plug a custom record type into a run. +""" +abstract type AbstractTestRecord end + +""" + TestRecord <: AbstractTestRecord + +Default per-test record. Holds the captured `DefaultTestSet` alongside the +baseline timing and memory statistics that [`runtests`](@ref) prints and +persists. Custom [`AbstractTestRecord`](@ref) subtypes wrap a `TestRecord` in a +`base` field; [`parent`](@ref) returns that baseline so the default `print_*` +methods work unchanged. +""" +struct TestRecord <: AbstractTestRecord + value::DefaultTestSet + + # stats + time::Float64 + bytes::UInt64 + gctime::Float64 + compile_time::Float64 + rss::UInt64 + total_time::Float64 +end + +""" + parent(rec::AbstractTestRecord) -> TestRecord + +Return the [`TestRecord`](@ref) baseline that a custom record type wraps. By +default, subtypes of `AbstractTestRecord` are expected to carry a +`base::TestRecord` field; override `parent` for a different layout. The default +`print_*` methods read baseline fields through `parent`, so wrapped types +inherit the standard output unchanged. +""" +Base.parent(rec::AbstractTestRecord) = rec.base +Base.parent(rec::TestRecord) = rec + +function memory_usage(rec::AbstractTestRecord) + return parent(rec).rss +end + +function init_time(rec::AbstractTestRecord) + base = parent(rec) + return base.total_time - base.time +end + +function Base.getindex(rec::AbstractTestRecord) + return parent(rec).value +end