Skip to content

Commit 0d3f01c

Browse files
authored
tests: Use realpath() before == path comparisons (#34506) (#34581)
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. (cherry picked from commit a5c422f)
1 parent b963fac commit 0d3f01c

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
@@ -768,7 +768,7 @@ end
768768
if Sys.iswindows()
769769
tmp = tempname()
770770
touch(tmp)
771-
path = dirname(tmp)
771+
path = realpath(dirname(tmp))
772772
file = basename(tmp)
773773
temp_name = basename(path)
774774
cd(path) do

test/cmdlineargs.jl

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

408408
# test the program name remains constant
409409
mktempdir() do dir
410+
# dir can be case-incorrect sometimes
411+
dir = realpath(dir)
412+
410413
a = joinpath(dir, "a.jl")
411414
b = joinpath(dir, "b.jl")
412415
c = joinpath(dir, ".julia", "config", "startup.jl")
@@ -430,19 +433,19 @@ let exename = `$(Base.julia_cmd()) --startup-file=no`
430433
[a, a,
431434
b, a]
432435
@test readsplit(`$exename -L $b -e 'exit(0)'`) ==
433-
[realpath(b), ""]
436+
[b, ""]
434437
@test readsplit(`$exename -L $b $a`) ==
435-
[realpath(b), a,
438+
[b, a,
436439
a, a,
437440
b, a]
438441
@test readsplit(`$exename --startup-file=yes -e 'exit(0)'`) ==
439442
[c, ""]
440443
@test readsplit(`$exename --startup-file=yes -L $b -e 'exit(0)'`) ==
441444
[c, "",
442-
realpath(b), ""]
445+
b, ""]
443446
@test readsplit(`$exename --startup-file=yes -L $b $a`) ==
444447
[c, a,
445-
realpath(b), a,
448+
b, a,
446449
a, a,
447450
b, a]
448451
end

0 commit comments

Comments
 (0)