Skip to content

Commit f71ea0a

Browse files
[Autobuild] Add log file prompt (#1154)
* [autobuild] Add log file prompt * [AutoBuild] Tweak prompt copy * Update src/AutoBuild.jl Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> * Update src/AutoBuild.jl Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> * Update src/AutoBuild.jl Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> * Update src/AutoBuild.jl * Add test for debug prompt * Add dashes before files * Fix testset closure * Two space tabs (make consistent with other examples) * Typo * Fix remaining four space tab * Update test/basic.jl * Fixes based on giordano's patch * Fix path * Update test/basic.jl Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> * Update test/basic.jl Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com> * Extract testset Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
1 parent b85cb6e commit f71ea0a

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/AutoBuild.jl

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,32 @@ function get_meta_json(
605605
return dict
606606
end
607607

608+
function compose_debug_prompt(workspace)
609+
log_files = String[]
610+
for (root, dirs, files) in walkdir(joinpath(workspace, "srcdir"))
611+
for file in files
612+
if endswith(file, ".log")
613+
push!(log_files, replace(joinpath(root, file), workspace => "\${WORKSPACE}"))
614+
end
615+
end
616+
end
617+
618+
if length(log_files) > 0
619+
log_files_str = join(log_files, "\n - ")
620+
621+
debug_shell_prompt = """
622+
Build failed, the following log files were generated:
623+
- $log_files_str
624+
625+
Launching debug shell:
626+
"""
627+
else
628+
debug_shell_prompt = "Build failed, launching debug shell:"
629+
end
630+
631+
return debug_shell_prompt
632+
end
633+
608634
"""
609635
autobuild(dir::AbstractString, src_name::AbstractString,
610636
src_version::VersionNumber, sources::Vector,
@@ -793,7 +819,9 @@ function autobuild(dir::AbstractString,
793819
end
794820
if !did_succeed
795821
if debug
796-
@warn("Build failed, launching debug shell")
822+
# Print debug prompt and paths to any generated log files
823+
debug_shell_prompt = compose_debug_prompt(prefix.path)
824+
@warn(debug_shell_prompt)
797825
run_interactive(ur, `/bin/bash -l -i`)
798826
end
799827
msg = "Build for $(src_name) on $(triplet(platform)) did not complete successfully\n"

test/basic.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ end
111111
end
112112
end
113113

114+
@testset "Debug Prompt (Flag Generated Logs)" begin
115+
mktempdir() do build_path
116+
log_dir = joinpath(build_path, "srcdir")
117+
mkdir(log_dir)
118+
@test "Build failed, launching debug shell:" == BinaryBuilder.compose_debug_prompt(build_path)
119+
120+
logfile_path = joinpath(log_dir, "errors.log")
121+
write(logfile_path, "sample log message")
122+
@test "Build failed, the following log files were generated:\n - $(replace(logfile_path, "$build_path" => "\${WORKSPACE}"))\n\nLaunching debug shell:\n" == BinaryBuilder.compose_debug_prompt(build_path)
123+
end
124+
end
125+
114126
@testset "Wizard Utilities" begin
115127
# Make sure canonicalization does what we expect
116128
zmq_url = "https://github.com/zeromq/zeromq3-x/releases/download/v3.2.5/zeromq-3.2.5.tar.gz"

0 commit comments

Comments
 (0)