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 24, 2023
1 parent 2883aac commit cbe07c3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
46 changes: 37 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
loading:
name: Loading only - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
Expand All @@ -20,19 +22,45 @@ jobs:
exclude:
- os: macOS-latest
arch: x86
- os: ubuntu-latest # covered in "tests" job
arch: x64
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install xvfb && Xvfb :99 &
if: matrix.os == 'ubuntu-latest'
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-uploadcodecov@v0.1
env:
DISPLAY: :99
- uses: julia-actions/julia-uploadcodecov@latest
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
tests:
name: Tests - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
version:
- '1.6'
- '1'
- 'nightly'
os:
- ubuntu-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
prefix: xvfb-run -a -s '-screen 0 1024x768x24'
env:
LD_PRELOAD: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
- uses: julia-actions/julia-uploadcodecov@v0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
docs:
Expand All @@ -43,7 +71,7 @@ jobs:
- run: sudo apt-get install xvfb && Xvfb :99 &
- uses: julia-actions/setup-julia@v1
with:
version: '1.6'
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Expand Down
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"]
12 changes: 11 additions & 1 deletion 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)

# 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
Expand Down Expand Up @@ -112,14 +120,16 @@ 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)
ImGuiOpenGLBackend.render(opengl_ctx) #ImGui_ImplOpenGL3_RenderDrawData(CImGui.GetDrawData())

glfwMakeContextCurrent(window)
glfwSwapBuffers(window)

yield() # to allow shutdown timer to run
end
catch e
@error "Error in renderloop!" exception=e
Expand Down
9 changes: 8 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ using CImGui
using Test

@testset "CImGui.jl" begin
# Write your own tests here.
# if CI only run if linux given xvfb is available in CI
if !haskey(ENV, "CI") || Sys.islinux() && Sys.WORD_SIZE == 64
withenv("AUTO_CLOSE_DEMO" => "5") do
include(joinpath("..", "demo", "demo.jl"))
end
else
@warn "Tests not run" haskey(ENV, "CI") Sys.islinux() Sys.WORD_SIZE
end
end

0 comments on commit cbe07c3

Please sign in to comment.