Skip to content

Commit

Permalink
tests: Use realpath() before == path comparisons (#34506)
Browse files Browse the repository at this point in the history
These should probably be using `samefile`, if they were real code instead of just tests. Though it's unclear why real code would be doing this. Maybe just don't put your paths in hash-tables and you'll normally be fine.
  • Loading branch information
staticfloat authored and vtjnash committed Jan 27, 2020
1 parent 91a118e commit a5c422f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions stdlib/LibGit2/test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ end
end

mktempdir() do dir
dir = realpath(dir)
# test parameters
repo_url = "https://github.com/JuliaLang/Example.jl"
cache_repo = joinpath(dir, "Example")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ end
if Sys.iswindows()
tmp = tempname()
touch(tmp)
path = dirname(tmp)
path = realpath(dirname(tmp))
file = basename(tmp)
temp_name = basename(path)
cd(path) do
Expand Down
11 changes: 7 additions & 4 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`

# test the program name remains constant
mktempdir() do dir
# dir can be case-incorrect sometimes
dir = realpath(dir)

a = joinpath(dir, "a.jl")
b = joinpath(dir, "b.jl")
c = joinpath(dir, ".julia", "config", "startup.jl")
Expand All @@ -460,19 +463,19 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
[a, a,
b, a]
@test readsplit(`$exename -L $b -e 'exit(0)'`) ==
[realpath(b), ""]
[b, ""]
@test readsplit(`$exename -L $b $a`) ==
[realpath(b), a,
[b, a,
a, a,
b, a]
@test readsplit(`$exename --startup-file=yes -e 'exit(0)'`) ==
[c, ""]
@test readsplit(`$exename --startup-file=yes -L $b -e 'exit(0)'`) ==
[c, "",
realpath(b), ""]
b, ""]
@test readsplit(`$exename --startup-file=yes -L $b $a`) ==
[c, a,
realpath(b), a,
b, a,
a, a,
b, a]
end
Expand Down

0 comments on commit a5c422f

Please sign in to comment.