Skip to content

Commit

Permalink
More concise printing of ans
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jun 25, 2019
1 parent cd10c4d commit ae8dfe8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ const precompile_code = """
_julia_cmd() = `$(Base.julia_cmd()) --color=yes --startup-file=no`
# TODO: use --color=yes only when make sense

struct Result
message::String
proc
end

function Base.show(io::IO, ::MIME"text/plain", result::Result)
print(io, "Result: ", result.message)
exitcode = result.proc.exitcode
if exitcode !== 0
print(io, " ")
printstyled(io, "(exit code: ", exitcode, ")"; color=:red)
end
end

function prepare(projectpath; precompile=true, parentproject=nothing)
projectpath = dirname(existingproject(projectpath))
code = prepare_code
Expand All @@ -96,7 +110,7 @@ function prepare(projectpath; precompile=true, parentproject=nothing)
env = copy(ENV)
env["JULIA_PROJECT"] = projectpath
cmd = setenv(`$(_julia_cmd()) -e $code -- $parentproject`, env)
run(cmd)
return Result("preparation finished", run(cmd))
end

function runproject(
Expand All @@ -120,7 +134,7 @@ function runproject(
end
@info "Running $script"
cmd = setenv(`$(_julia_cmd()) $julia_options $script`, env)
run(cmd)
return Result("run finished", run(cmd))
end

prepare_test(path="test"; kwargs...) = prepare(path; kwargs...)
Expand Down

0 comments on commit ae8dfe8

Please sign in to comment.