From 8c1adc82f8ab17bd26612428984c4c9c135a8550 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 20 Jun 2017 21:52:57 -0700 Subject: [PATCH] fix homedir error handling for 1020+ character usernames or 250 characters for a certain broken OS --- base/path.jl | 2 +- test/path.jl | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/base/path.jl b/base/path.jl index 28ac0b520e85d..940ae4cd2d6e0 100644 --- a/base/path.jl +++ b/base/path.jl @@ -68,7 +68,7 @@ function homedir() if rc == 0 resize!(buf, sz[]) return String(buf) - elseif rc == UV_ENOBUFS + elseif rc == Base.UV_ENOBUFS resize!(buf, sz[] - 1) else error("unable to retrieve home directory") diff --git a/test/path.jl b/test/path.jl index a2444e7810681..e02176c33945f 100644 --- a/test/path.jl +++ b/test/path.jl @@ -197,3 +197,15 @@ test_relpath() # Test type stability @test isa(joinpath("a", "b"), String) @test isa(joinpath(abspath("a"), "b"), String) + +# homedir +let var = is_windows() ? "USERPROFILE" : "HOME", + MAX_PATH = is_windows() ? 240 : 1020 + for i = 0:9 + local home = " "^MAX_PATH * "123456789"[1:i] + @test withenv(var => home) do + homedir() + end == home + end + @test isabspath(withenv(homedir, var => nothing)) +end