Skip to content

Commit a5c422f

Browse files
staticfloatvtjnash
authored andcommitted
tests: Use realpath() before == path comparisons (#34506)
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.
1 parent 91a118e commit a5c422f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

stdlib/LibGit2/test/libgit2.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ end
600600
end
601601

602602
mktempdir() do dir
603+
dir = realpath(dir)
603604
# test parameters
604605
repo_url = "https://github.com/JuliaLang/Example.jl"
605606
cache_repo = joinpath(dir, "Example")

stdlib/REPL/test/replcompletions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ end
804804
if Sys.iswindows()
805805
tmp = tempname()
806806
touch(tmp)
807-
path = dirname(tmp)
807+
path = realpath(dirname(tmp))
808808
file = basename(tmp)
809809
temp_name = basename(path)
810810
cd(path) do

test/cmdlineargs.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
437437

438438
# test the program name remains constant
439439
mktempdir() do dir
440+
# dir can be case-incorrect sometimes
441+
dir = realpath(dir)
442+
440443
a = joinpath(dir, "a.jl")
441444
b = joinpath(dir, "b.jl")
442445
c = joinpath(dir, ".julia", "config", "startup.jl")
@@ -460,19 +463,19 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
460463
[a, a,
461464
b, a]
462465
@test readsplit(`$exename -L $b -e 'exit(0)'`) ==
463-
[realpath(b), ""]
466+
[b, ""]
464467
@test readsplit(`$exename -L $b $a`) ==
465-
[realpath(b), a,
468+
[b, a,
466469
a, a,
467470
b, a]
468471
@test readsplit(`$exename --startup-file=yes -e 'exit(0)'`) ==
469472
[c, ""]
470473
@test readsplit(`$exename --startup-file=yes -L $b -e 'exit(0)'`) ==
471474
[c, "",
472-
realpath(b), ""]
475+
b, ""]
473476
@test readsplit(`$exename --startup-file=yes -L $b $a`) ==
474477
[c, a,
475-
realpath(b), a,
478+
b, a,
476479
a, a,
477480
b, a]
478481
end

0 commit comments

Comments
 (0)