Skip to content

Commit 7f647db

Browse files
committed
Translate build bot directory to local source
1 parent f1f2c17 commit 7f647db

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ DataStructures = "0.17, 0.18"
1919
FlameGraphs = "0.1, 0.2"
2020
HAML = "0.3.1"
2121
julia = "1.6"
22+
23+
[extras]
24+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
25+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
26+
27+
[targets]
28+
test = ["Random", "Test"]

src/Reports.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ end
2020

2121
const found_source_files = Dict{Symbol, Union{Nothing, Symbol}}()
2222

23+
function find_source_file(file)
24+
res = Base.find_source_file(file)
25+
!isnothing(res) && isfile(res) && return res
26+
# try to translate build bot directory to local source
27+
res = replace(file, r".*?[\\/]usr[\\/]share[\\/]julia[\\/]stdlib" => joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "stdlib"))
28+
isfile(res) ? normpath(res) : nothing
29+
end
30+
2331
TracePoint(frame::StackFrame) = begin
2432
file = get!(found_source_files, frame.file) do
25-
res = Base.find_source_file(string(frame.file))
33+
res = find_source_file(string(frame.file))
2634
isnothing(res) ? nothing : Symbol(res)
2735
end
2836

test/end-to-end.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,22 @@ fibonacci(n) = n <= 2 ? 1 : fibonacci(n-1) + fibonacci(n-2)
4747
end
4848
end
4949
end
50+
51+
function searchdir(dir, pat)
52+
any(readdir(dir)) do path
53+
!isnothing(match(pat, path))
54+
end
55+
end
56+
57+
@testset "Translate stdlib path" begin
58+
mktempdir() do dir
59+
cd(dir) do
60+
a = Vector{UInt8}(undef, 10000000)
61+
@profilehtml rand!(a, [1, 2, 3])
62+
63+
@test isdir("statprof")
64+
@test searchdir("statprof", r"generation\.jl-.+")
65+
end
66+
end
67+
end
5068
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using StatProfilerHTML
2+
using Random
23

34
using Test
45
using Profile

0 commit comments

Comments
 (0)