diff --git a/test/choosetests.jl b/test/choosetests.jl index 90bdcb6f508aff..2a2eecfcbe248c 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -32,7 +32,7 @@ function choosetests(choices = []) "nullable", "meta", "profile", "libgit2", "docs", "markdown", "base64", "serialize", "functors", "misc", "enums", "cmdlineargs", "i18n", "workspace", "libdl", "int", - "intset", "floatfuncs", "compile", "shell", "interactiveutil" + "intset", "floatfuncs", "compile" ] if Base.USE_GPL_LIBS diff --git a/test/interactiveutil.jl b/test/interactiveutil.jl deleted file mode 100644 index 13fef6fc83e1e7..00000000000000 --- a/test/interactiveutil.jl +++ /dev/null @@ -1,40 +0,0 @@ -# This file is a part of Julia. License is MIT: http://julialang.org/license - -# Make sure editor doesn't error when no ENV editor is set. -pop!(ENV, "JULIA_EDITOR", "") -pop!(ENV, "VISUAL", "") -pop!(ENV, "EDITOR", "") -@test isa(Base.editor(), Array) - -# Invalid editors -ENV["JULIA_EDITOR"] = "" -@test_throws ErrorException Base.editor() - -# Note: The following testcases should work regardless of whether these editors are -# installed or not. - -# Editor on the path. -ENV["JULIA_EDITOR"] = "vim" -@test Base.editor() == ["vim"] - -# Absolute path to editor. -ENV["JULIA_EDITOR"] = "/usr/bin/vim" -@test Base.editor() == ["/usr/bin/vim"] - -# Editor on the path using arguments. -ENV["JULIA_EDITOR"] = "subl -w" -@test Base.editor() == ["subl", "-w"] - -# Absolute path to editor with spaces. -ENV["JULIA_EDITOR"] = "/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl" -@test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"] - -# Paths with spaces and arguments (#13032). -ENV["JULIA_EDITOR"] = "/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -w" -@test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] - -ENV["JULIA_EDITOR"] = "'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' -w" -@test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] - -ENV["JULIA_EDITOR"] = "\"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl\" -w" -@test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] diff --git a/test/replutil.jl b/test/replutil.jl index c0c8760d10d173..29e63ffb1ba041 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -132,3 +132,45 @@ let showerror(buff, MethodError(convert, Tuple{Type, Float64})) showerror(buff, MethodError(convert, Tuple{DataType, Float64})) end + +# Issue #13032 +let + # Make sure editor doesn't error when no ENV editor is set. + pop!(ENV, "JULIA_EDITOR", "") + pop!(ENV, "VISUAL", "") + pop!(ENV, "EDITOR", "") + @test isa(Base.editor(), Array) + + # Invalid editors + ENV["JULIA_EDITOR"] = "" + @test_throws ErrorException Base.editor() + + # Note: The following testcases should work regardless of whether these editors are + # installed or not. + + # Editor on the path. + ENV["JULIA_EDITOR"] = "vim" + @test Base.editor() == ["vim"] + + # Absolute path to editor. + ENV["JULIA_EDITOR"] = "/usr/bin/vim" + @test Base.editor() == ["/usr/bin/vim"] + + # Editor on the path using arguments. + ENV["JULIA_EDITOR"] = "subl -w" + @test Base.editor() == ["subl", "-w"] + + # Absolute path to editor with spaces. + ENV["JULIA_EDITOR"] = "/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl" + @test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"] + + # Paths with spaces and arguments (#13032). + ENV["JULIA_EDITOR"] = "/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -w" + @test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] + + ENV["JULIA_EDITOR"] = "'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' -w" + @test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] + + ENV["JULIA_EDITOR"] = "\"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl\" -w" + @test Base.editor() == ["/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "-w"] +end \ No newline at end of file diff --git a/test/shell.jl b/test/shell.jl deleted file mode 100644 index 45ada3da44ef58..00000000000000 --- a/test/shell.jl +++ /dev/null @@ -1,21 +0,0 @@ -# This file is a part of Julia. License is MIT: http://julialang.org/license - -# Ensure that quoting works -@test Base.shell_split("foo bar baz") == ["foo", "bar", "baz"] -@test Base.shell_split("foo\\ bar baz") == ["foo bar", "baz"] -@test Base.shell_split("'foo bar' baz") == ["foo bar", "baz"] -@test Base.shell_split("\"foo bar\" baz") == ["foo bar", "baz"] - -# "Over quoted" -@test Base.shell_split("'foo\\ bar' baz") == ["foo\\ bar", "baz"] -@test Base.shell_split("\"foo\\ bar\" baz") == ["foo\\ bar", "baz"] - -# Ensure that shell_split handles quoted spaces -cmd = ["/Volumes/External HD/program", "-a"] -@test Base.shell_split("/Volumes/External\\ HD/program -a") == cmd -@test Base.shell_split("'/Volumes/External HD/program' -a") == cmd -@test Base.shell_split("\"/Volumes/External HD/program\" -a") == cmd - -# Backticks should automatically quote where necessary -cmd = ["foo bar", "baz"] -@test string(`$cmd`) == "`'foo bar' baz`" diff --git a/test/spawn.jl b/test/spawn.jl index 1856df40147d19..d50658caba14f5 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -271,3 +271,25 @@ let fname = tempname() @test success(pipeline(`cat $fname`, `$exename -e $code`)) rm(fname) end + +let cmd = AbstractString[] + # Ensure that quoting works + @test Base.shell_split("foo bar baz") == ["foo", "bar", "baz"] + @test Base.shell_split("foo\\ bar baz") == ["foo bar", "baz"] + @test Base.shell_split("'foo bar' baz") == ["foo bar", "baz"] + @test Base.shell_split("\"foo bar\" baz") == ["foo bar", "baz"] + + # "Over quoted" + @test Base.shell_split("'foo\\ bar' baz") == ["foo\\ bar", "baz"] + @test Base.shell_split("\"foo\\ bar\" baz") == ["foo\\ bar", "baz"] + + # Ensure that shell_split handles quoted spaces + cmd = ["/Volumes/External HD/program", "-a"] + @test Base.shell_split("/Volumes/External\\ HD/program -a") == cmd + @test Base.shell_split("'/Volumes/External HD/program' -a") == cmd + @test Base.shell_split("\"/Volumes/External HD/program\" -a") == cmd + + # Backticks should automatically quote where necessary + cmd = ["foo bar", "baz"] + @test string(`$cmd`) == "`'foo bar' baz`" +end