Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

catcmd = `cat`
if is_windows()
try # use busybox-w32 on windows
success(`busybox`)
catcmd = `busybox cat`
end
end

let exename = `$(Base.julia_cmd()) --precompiled=yes`
# --version
let v = split(readstring(`$exename -v`), "julia version ")[end]
Expand Down Expand Up @@ -246,13 +254,6 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes`
@test readchomp(`$exename -e 'println(ARGS);' ''`) == "String[\"\"]"

# issue #12679
catcmd = `cat`
if is_windows()
try # use busybox-w32 on windows
success(`busybox`)
catcmd = `busybox cat`
end
end
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no --compile=yes -ioo`),stderr=catcmd)) == "ERROR: unknown option `-o`"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no -p`),stderr=catcmd)) == "ERROR: option `-p/--procs` is missing an argument"
@test readchomp(pipeline(ignorestatus(`$exename --startup-file=no --inline`),stderr=catcmd)) == "ERROR: option `--inline` is missing an argument"
Expand Down Expand Up @@ -287,3 +288,19 @@ let exename = `$(Base.julia_cmd())`
@test readchomp(`$exename --precompiled=yes -E "Bool(Base.JLOptions().use_precompiled)"`) == "true"
@test readchomp(`$exename --precompiled=no -E "Bool(Base.JLOptions().use_precompiled)"`) == "false"
end

# backtrace contains type and line number info (esp. on windows #17179)
for precomp in ("yes", "no")
bt = readstring(pipeline(ignorestatus(`$(Base.julia_cmd()) --precompiled=$precomp
-E 'include("____nonexistent_file")'`), stderr=catcmd))
@test contains(bt, "in include_from_node1")
if is_windows() && Sys.WORD_SIZE == 32 && precomp == "yes"
# fixme, issue #17251
@test_broken contains(bt, "in include_from_node1(::String) at $(joinpath(".","loading.jl"))")
else
@test contains(bt, "in include_from_node1(::String) at $(joinpath(".","loading.jl"))")
end
lno = match(r"at \.[\/\\]loading\.jl:(\d+)", bt)
@test length(lno.captures) == 1
@test parse(Int, lno.captures[1]) > 0
end
4 changes: 2 additions & 2 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ test_monitor_wait_poll()
test_watch_file_timeout(0.1)
test_watch_file_change(6)

@test_throws Base.UVError watch_file("nonexistantfile", 10)
@test_throws Base.UVError poll_file("nonexistantfile", 2, 10)
@test_throws Base.UVError watch_file("____nonexistent_file", 10)
@test_throws Base.UVError poll_file("____nonexistent_file", 2, 10)

##############
# mark/reset #
Expand Down
22 changes: 12 additions & 10 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import Base.Pkg.PkgError

function temp_pkg_dir(fn::Function, remove_tmp_dir::Bool=true)
# Used in tests below to setup and teardown a sandboxed package directory
const tmpdir = ENV["JULIA_PKGDIR"] = joinpath(tempdir(),randstring())
@test !isdir(Pkg.dir())
try
Pkg.init()
@test isdir(Pkg.dir())
Pkg.resolve()
fn()
finally
remove_tmp_dir && rm(tmpdir, recursive=true)
# Used in tests below to set up and tear down a sandboxed package directory
const tmpdir = joinpath(tempdir(),randstring())
withenv("JULIA_PKGDIR" => tmpdir) do
@test !isdir(Pkg.dir())
try
Pkg.init()
@test isdir(Pkg.dir())
Pkg.resolve()
fn()
finally
remove_tmp_dir && rm(tmpdir, recursive=true)
end
end
end

Expand Down
48 changes: 24 additions & 24 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,30 @@ if !is_windows() || Sys.windows_version() >= Sys.WINDOWS_VISTA_VER
# calling readuntil() to suppress the warning it (currently) gives for
# long strings.
origpwd = pwd()
tmpdir = mktempdir()
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd $(escape_string(tmpdir))\n")
readuntil(stdout_read, "cd $(escape_string(tmpdir))"[max(1,end-39):end])
readuntil(stdout_read, realpath(tmpdir)[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == realpath(tmpdir)
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd -\n")
readuntil(stdout_read, origpwd[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == origpwd
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd\n")
readuntil(stdout_read, homedir()[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == homedir()
rm(tmpdir)
mktempdir() do tmpdir
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd $(escape_string(tmpdir))\n")
readuntil(stdout_read, "cd $(escape_string(tmpdir))"[max(1,end-39):end])
readuntil(stdout_read, realpath(tmpdir)[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == realpath(tmpdir)
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd -\n")
readuntil(stdout_read, origpwd[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == origpwd
write(stdin_write, ";")
readuntil(stdout_read, "shell> ")
write(stdin_write, "cd\n")
readuntil(stdout_read, homedir()[max(1,end-39):end])
readuntil(stdout_read, "\n")
readuntil(stdout_read, "\n")
@test pwd() == homedir()
end
cd(origpwd)

# Test that accepting a REPL result immediately shows up, not
Expand Down
26 changes: 15 additions & 11 deletions test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,20 @@ module CompletionFoo
end
test_repl_comp_dict = CompletionFoo.test_dict

function temp_pkg_dir(fn::Function)
# Used in tests below to setup and teardown a sandboxed package directory
const tmpdir = ENV["JULIA_PKGDIR"] = joinpath(tempdir(),randstring())
@test !isdir(Pkg.dir())
try
mkpath(Pkg.dir())
@test isdir(Pkg.dir())
fn()
finally
rm(tmpdir, recursive=true)
function temp_pkg_dir_noinit(fn::Function)
# Used in tests below to set up and tear down a sandboxed package directory
# Unlike the version in test/pkg.jl, this does not run Pkg.init so does not
# clone METADATA (only pkg and libgit2-online tests should need internet access)
const tmpdir = joinpath(tempdir(),randstring())
withenv("JULIA_PKGDIR" => tmpdir) do
@test !isdir(Pkg.dir())
try
mkpath(Pkg.dir())
@test isdir(Pkg.dir())
fn()
finally
rm(tmpdir, recursive=true)
end
end
end

Expand Down Expand Up @@ -382,7 +386,7 @@ c, r, res = test_complete(s)

# Test completion of packages
mkp(p) = ((@assert !isdir(p)); mkpath(p))
temp_pkg_dir() do
temp_pkg_dir_noinit() do
# Complete <Mod>/src/<Mod>.jl and <Mod>.jl/src/<Mod>.jl
# but not <Mod>/ if no corresponding .jl file is found
pkg_dir = Pkg.dir("CompletionFooPackage", "src")
Expand Down
1 change: 0 additions & 1 deletion test/replutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ end

# Issue #13032
withenv("JULIA_EDITOR" => nothing, "VISUAL" => nothing, "EDITOR" => nothing) do

# Make sure editor doesn't error when no ENV editor is set.
@test isa(Base.editor(), Array)

Expand Down