diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index 6dc47473cd17b..2ffbef9eb89c7 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -615,7 +615,7 @@ function build(pkg::AbstractString, build_file::AbstractString, errfile::Abstrac --eval $code ``` - success(pipeline(cmd, stderr=STDERR)) + success(pipeline(cmd, stdout=STDOUT, stderr=STDERR)) end function build!(pkgs::Vector, seen::Set, errfile::AbstractString) diff --git a/test/pkg.jl b/test/pkg.jl index 288cc657c0146..4d2548f253d87 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -572,6 +572,23 @@ temp_pkg_dir() do @test contains(msg, "INFO: Main.JULIA_RC_LOADED defined true") end end + + let package = "Output" + stdout_file = Pkg.dir(package, "stdout.txt") + stderr_file = Pkg.dir(package, "stderr.txt") + content = """ + println(STDOUT, "stdout") + println(STDERR, "stderr") + """ + write_build(package, content) + + code = "Pkg.build(\"$package\")" + msg = run(pipeline( + `$(Base.julia_cmd()) --startup-file=no -e $code`, + stdout=stdout_file, stderr=stderr_file)) + @test last(readlines(stdout_file)) == "stdout" + @test last(readlines(stderr_file)) == "stderr" + end end @testset "Pkg functions with .jl extension" begin