Skip to content

Commit

Permalink
use demo for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 23, 2023
1 parent 2883aac commit a32978a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Preferences = "1"
julia = "1.6"

[extras]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Printf","Test"]
10 changes: 10 additions & 0 deletions demo/demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ ImGuiGLFWBackend.init(glfw_ctx)
opengl_ctx = ImGuiOpenGLBackend.create_context(glsl_version)
ImGuiOpenGLBackend.init(opengl_ctx)

window_should_close = false
if haskey(ENV, "AUTO_CLOSE_DEMO")
tsecs = parse(Int, ENV["AUTO_CLOSE_DEMO"])
Timer(tsecs) do t
window_should_close = true
end
end

try
show_demo_window = true
show_another_window = false
Expand Down Expand Up @@ -120,6 +128,8 @@ try

glfwMakeContextCurrent(window)
glfwSwapBuffers(window)

window_should_close && break
end
catch e
@error "Error in renderloop!" exception=e
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ using CImGui
using Test

@testset "CImGui.jl" begin
# Write your own tests here.
withenv("AUTO_CLOSE_DEMO" => 10) do
include(joinpath("..", "demo", "demo.jl"))
end
end

0 comments on commit a32978a

Please sign in to comment.