From 6241adfd20f9ac34581ebf5cce09c32f8910c0d8 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Fri, 22 Sep 2023 21:43:06 -0400 Subject: [PATCH] use demo for tests --- Project.toml | 3 ++- demo/demo.jl | 12 +++++++++++- test/runtests.jl | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index e850e9e..3ba52d7 100644 --- a/Project.toml +++ b/Project.toml @@ -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"] diff --git a/demo/demo.jl b/demo/demo.jl index 82c9913..3dc4137 100644 --- a/demo/demo.jl +++ b/demo/demo.jl @@ -63,6 +63,14 @@ ImGuiGLFWBackend.init(glfw_ctx) opengl_ctx = ImGuiOpenGLBackend.create_context(glsl_version) ImGuiOpenGLBackend.init(opengl_ctx) +# for tests +if haskey(ENV, "AUTO_CLOSE_DEMO") + tsecs = parse(Int, ENV["AUTO_CLOSE_DEMO"]) + Timer(tsecs) do t + glfwSetWindowShouldClose(window, true) + end +end + try show_demo_window = true show_another_window = false @@ -112,7 +120,7 @@ try glfwGetFramebufferSize(window, width, height) display_w = width[] display_h = height[] - + glViewport(0, 0, display_w, display_h) glClearColor(clear_color...) glClear(GL_COLOR_BUFFER_BIT) @@ -120,6 +128,8 @@ try glfwMakeContextCurrent(window) glfwSwapBuffers(window) + + yield() # to allow shutdown timer to run end catch e @error "Error in renderloop!" exception=e diff --git a/test/runtests.jl b/test/runtests.jl index ba60aff..49d8dbd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,5 +2,7 @@ using CImGui using Test @testset "CImGui.jl" begin - # Write your own tests here. + withenv("AUTO_CLOSE_DEMO" => "5") do + include(joinpath("..", "demo", "demo.jl")) + end end