-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
Fixes the Windows tempdir function returning a path with the trailing slash.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,8 +244,39 @@ close(s) | |
end | ||
end | ||
|
||
my_tempdir = tempdir() | ||
@test isdir(my_tempdir) == true | ||
@testset "tempdir" begin | ||
my_tempdir = tempdir() | ||
@test isdir(my_tempdir) | ||
@test my_tempdir[end] != '/' | ||
@test my_tempdir[end] != '\\' | ||
|
||
var = Sys.iswindows() ? "TMP" : "TMPDIR" | ||
PATH_PREFIX = Sys.iswindows() ? "C:\\" : "/tmp/" | ||
# Warning: On Windows uv_os_tmpdir internally calls GetTempPathW. The max string length for | ||
# GetTempPathW is 261 (including the implied trailing backslash), not the typical length 259. | ||
# We thus use 260 (with implied trailing slash backlash this then gives 261 chars) and | ||
# subtract 9 to account for i = 0:9. | ||
MAX_PATH = (Sys.iswindows() ? 260-9 : 1024) - length(PATH_PREFIX) | ||
for i = 0:8 | ||
local tmp = PATH_PREFIX * "x"^MAX_PATH * "123456789"[1:i] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
StefanKarpinski
Member
|
||
@test withenv(var => tmp) do | ||
tempdir() | ||
end == (tmp) | ||
end | ||
for i = 9 | ||
local tmp = PATH_PREFIX * "x"^MAX_PATH * "123456789"[1:i] | ||
if Sys.iswindows() | ||
# libuv bug | ||
@test_broken withenv(var => tmp) do | ||
tempdir() | ||
end == tmp | ||
else | ||
@test withenv(var => tmp) do | ||
tempdir() | ||
end == tmp | ||
end | ||
end | ||
end | ||
|
||
let path = tempname() | ||
# issue #9053 | ||
|
@musm, why does this generate too-long
tmp
paths? Is that intentional or was the intention to make these exactly the max path length? This is causing problems when I test #33593 because even stating the too long path is an error and the tempdir path definitely cannot exist.