Skip to content

Commit

Permalink
Improve tempdir test to ensure filename generated on UNIX is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
musm authored Feb 1, 2020
1 parent cb32020 commit fbc2c0a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,20 +520,21 @@ end
@test my_tempdir[end] != '\\'

var = Sys.iswindows() ? "TMP" : "TMPDIR"
PATH_PREFIX = Sys.iswindows() ? "C:\\" : "/tmp/"
PATH_PREFIX = Sys.iswindows() ? "C:\\" : "/tmp/" * "x"^255 # we want a long path on UNIX so that we test buffer resizing in `tempdir`
# 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)
# We thus use 260 (with implied trailing slash backlash this then gives 261 chars)
# NOTE: not the actual max path on UNIX, but true in the Windows case for this function.
# NOTE: we subtract 9 to account for i = 0:9.
MAX_PATH = (Sys.iswindows() ? 260 - length(PATH_PREFIX) : 255) - 9
for i = 0:8
local tmp = PATH_PREFIX * "x"^MAX_PATH * "123456789"[1:i]
local tmp = joinpath(PATH_PREFIX, "x"^MAX_PATH * "123456789"[1:i])
@test withenv(var => tmp) do
tempdir()
end == (tmp)
end
for i = 9
local tmp = PATH_PREFIX * "x"^MAX_PATH * "123456789"[1:i]
local tmp = joinpath(PATH_PREFIX, "x"^MAX_PATH * "123456789"[1:i])
if Sys.iswindows()
# libuv bug
@test_broken withenv(var => tmp) do
Expand Down

6 comments on commit fbc2c0a

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.