Skip to content

Commit

Permalink
Add test for onerror keyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoegh authored and dhoegh committed Oct 22, 2015
1 parent e93ac4e commit a9780eb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ end
# walkdir #
###################

dir = mktempdir()
walkdir = mktempdir()
cd(dir) do
for i=1:2
mkdir("sub_dir$i")
Expand Down Expand Up @@ -932,8 +932,29 @@ cd(dir) do
@test dirs == ["sub_dir1", "sub_dir2"]
@test files == ["file1", "file2"]
end
#test of error handling
task_error = walkdir(".")
task_noerror = walkdir(".", onerror=x->x)
root, dirs, files = consume(task_error)
@test root == "."
@test dirs == ["sub_dir1", "sub_dir2"]
@test files == ["file1", "file2"]

rm(joinpath("sub_dir1"), recursive=true)
@test_throws SystemError consume(task_error) # throws an error because sub_dir1 do not exist

root, dirs, files = consume(task_noerror)
@test root == "."
@test dirs == ["sub_dir1", "sub_dir2"]
@test files == ["file1", "file2"]

root, dirs, files = consume(task_noerror) # skips sub_dir1 as it no longer exist
@test root == joinpath(".", "sub_dir2")
@test dirs == []
@test files == ["file_dir2"]

end
@unix_only rm(dir, recursive=true)
@unix_only rm(walkdir, recursive=true)

############
# Clean up #
Expand Down

0 comments on commit a9780eb

Please sign in to comment.