Skip to content

Commit

Permalink
Fix env handling in Cmd (JuliaLang#36039)
Browse files Browse the repository at this point in the history
Matches behaviour in docs, adds test, fixes JuliaLang#32454.
  • Loading branch information
simonbyrne committed May 27, 2020
1 parent fb9be71 commit 9a431f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/cmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ byteenv(env::AbstractArray{<:AbstractString}) =
byteenv(env::AbstractDict) =
String[cstr(string(k)*"="*string(v)) for (k,v) in env]
byteenv(env::Nothing) = nothing
byteenv(env::Union{AbstractVector{Pair{T}}, Tuple{Vararg{Pair{T}}}}) where {T<:AbstractString} =
byteenv(env::Union{AbstractVector{Pair{T,V}}, Tuple{Vararg{Pair{T,V}}}}) where {T<:AbstractString,V} =
String[cstr(k*"="*string(v)) for (k,v) in env]

"""
Expand Down
2 changes: 1 addition & 1 deletion test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ end
pop!(need_to_handle_undef_sparam, first(methods(Base.same_names)))
@test_broken need_to_handle_undef_sparam == Set()
pop!(need_to_handle_undef_sparam, which(Base._cat, Tuple{Any, AbstractArray}))
pop!(need_to_handle_undef_sparam, which(Base.byteenv, (Union{AbstractArray{Pair{T}, 1}, Tuple{Vararg{Pair{T}}}} where T<:AbstractString,)))
pop!(need_to_handle_undef_sparam, which(Base.byteenv, (Union{AbstractArray{Pair{T,V}, 1}, Tuple{Vararg{Pair{T,V}}}} where {T<:AbstractString,V},)))
pop!(need_to_handle_undef_sparam, which(Base._cat, (Any, SparseArrays._TypedDenseConcatGroup{T} where T)))
pop!(need_to_handle_undef_sparam, which(Base.float, Tuple{AbstractArray{Union{Missing, T},N} where {T, N}}))
pop!(need_to_handle_undef_sparam, which(Base.zero, Tuple{Type{Union{Missing, T}} where T}))
Expand Down
7 changes: 7 additions & 0 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ end
@test Set([``, echocmd]) != Set([``, ``])
@test Set([echocmd, ``, ``, echocmd]) == Set([echocmd, ``])

# env handling (#32454)
@test Cmd(`foo`, env=Dict("A"=>true)).env == ["A=true"]
@test Cmd(`foo`, env=["A=true"]).env == ["A=true"]
@test Cmd(`foo`, env=("A"=>true,)).env == ["A=true"]
@test Cmd(`foo`, env=["A"=>true]).env == ["A=true"]
@test Cmd(`foo`, env=nothing).env == nothing

# test for interpolation of Cmd
let c = setenv(`x`, "A"=>true)
@test (`$c a`).env == String["A=true"]
Expand Down

0 comments on commit 9a431f3

Please sign in to comment.