Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 3 additions & 58 deletions src/ParallelTestRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
59 changes: 59 additions & 0 deletions src/records.jl
Original file line number Diff line number Diff line change
@@ -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
Loading