From 2d06cbf9a6b9beb0cad9b2d39af2ab0303c8701a Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 19 Jun 2021 11:35:14 +0900 Subject: [PATCH 1/3] add test for ErrorException --- Project.toml | 3 ++- test/runtests.jl | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 79f3590..a19cf6f 100644 --- a/Project.toml +++ b/Project.toml @@ -17,6 +17,7 @@ ImageIO = "0.5" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" +InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [targets] -test = ["Test", "Images"] +test = ["Test", "Images", "InteractiveUtils"] diff --git a/test/runtests.jl b/test/runtests.jl index 2a1dabf..74d9c3c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,7 @@ using ImageClipboard using Images using Test +using InteractiveUtils @testset "ImageClipboard.jl" begin @@ -9,7 +10,7 @@ using Test clipboard_img(img) img2 = clipboard_img() - # FIXME, windows.. + # FIXME, windows exception (#10) if Sys.iswindows() @test RGBA.(img) == img2 else @@ -22,10 +23,15 @@ using Test clipboard_img(img) img2 = clipboard_img() - # FIXME, windows.. + # FIXME, windows exception (#10) if !Sys.iswindows() @test img == img2 end end + @testset "Error if no image" begin + clipboard("") + @test_throws ErrorException("No image in clipboard") clipboard_img() + end + end From fe1a9eec43ed6b149cef32ff611a04740b8d8b50 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 19 Jun 2021 12:55:59 +0900 Subject: [PATCH 2/3] update error handling in _xclip --- src/_xclip.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/_xclip.jl b/src/_xclip.jl index 828d905..975e00f 100644 --- a/src/_xclip.jl +++ b/src/_xclip.jl @@ -12,9 +12,13 @@ function _xclip() # Pipe clipboard image to buffer if success(pipeline(`xclip -selection clipboard -t image/png -o`; stdout=img_buf)) - # Load image from buffer - img = load(img_buf) - return img + try + # Load image from buffer + img = load(img_buf) + return img + catch + error("No image in clipboard") + end else error("No image in clipboard") end From e321be074e5c7a99bbf635dabdf1ff5573a14ba5 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Sat, 19 Jun 2021 13:04:36 +0900 Subject: [PATCH 3/3] bump version to v0.1.1 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a19cf6f..a1ad56b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ImageClipboard" uuid = "6db54171-f50f-4661-a74f-bc514ef16cee" authors = ["hyrodium and contributors"] -version = "0.1.0" +version = "0.1.1" [deps] ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"