Skip to content

Commit 37e4af7

Browse files
Merge pull request #449 from Hedgehogsoft/main
add tests
2 parents 19374af + 7eca907 commit 37e4af7

File tree

7 files changed

+134
-55
lines changed

7 files changed

+134
-55
lines changed

.github/workflows/linux.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: |
5757
sudo apt-get update -qq
5858
sudo apt-get install gcc-multilib
59-
sudo apt-get install -y --no-install-recommends libx11-dev mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev libgles2-mesa-dev libosmesa6-dev glslang-tools libvulkan-dev
59+
sudo apt-get install -y --no-install-recommends libx11-dev mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev libgles2-mesa-dev libosmesa6-dev glslang-tools libvulkan-dev xvfb
6060
mkdir build
6161
cd build
6262
mkdir ${{ env.RELEASE_NAME }}
@@ -66,6 +66,10 @@ jobs:
6666
cd ../../../RGFW
6767
# ${{ matrix.ARCH }}-linux-gnu-gcc -v
6868
69+
- name: tests
70+
run: |
71+
xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" make tests
72+
6973
- name: test C++
7074
run: |
7175
make

.github/workflows/macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ jobs:
5353
cd ../..
5454
# Generating static + shared library, note that i386 architecture is deprecated
5555
# Defining GL_SILENCE_DEPRECATION because OpenGL is deprecated on macOS
56+
- name: tests
57+
run: |
58+
make tests
59+
5660
- name: Build Library
5761
run: |
5862
clang --version

.github/workflows/wayland.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
run: |
5858
sudo apt-get update -qq
5959
sudo apt-get install gcc-multilib
60-
sudo apt-get install -y --no-install-recommends libx11-dev mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev wayland-protocols libgles2-mesa-dev libosmesa6-dev
60+
sudo apt-get install -y --no-install-recommends libx11-dev mesa-common-dev libglx-dev libxcursor-dev mesa-vulkan-drivers libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev wayland-protocols libgles2-mesa-dev libosmesa6-dev weston
6161
mkdir build
6262
cd build
6363
mkdir ${{ env.RELEASE_NAME }}
@@ -66,6 +66,24 @@ jobs:
6666
mkdir lib
6767
cd ../../../RGFW
6868
69+
# todo fix
70+
# - name: tests
71+
# run: |
72+
# export XDG_RUNTIME_DIR="$(mktemp -d)"
73+
# chmod 0700 "$XDG_RUNTIME_DIR"
74+
#
75+
# weston --backend=headless-backend.so --width=1279 --height=1024 --no-config --idle-time=0 &
76+
#
77+
# WESTON_PID=$!
78+
# sleep 6 # give it time to start
79+
#
80+
# export WAYLAND_DISPLAY=wayland-0
81+
# export XDG_RUNTIME_DIR
82+
#
83+
# make WAYLAND=1 tests
84+
#
85+
# kill $WESTON_PID
86+
6987
- name: test wayland
7088
run: |
7189
make WAYLAND_X11=1

.github/workflows/windows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ jobs:
6969
mkdir lib
7070
cd ../../../RGFW
7171
72+
- name: tests
73+
run: |
74+
make tests
75+
7276
- name: test C++
7377
run: |
7478
make

Makefile

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,35 +187,41 @@ EXAMPLE_OUTPUTS_CUSTOM = \
187187
examples/gears/gears \
188188
examples/srgb/srgb
189189

190+
TEST_OUTPUTS = \
191+
tests/loop \
192+
193+
190194
all: xdg-shell.c $(EXAMPLE_OUTPUTS) $(EXAMPLE_OUTPUTS_CUSTOM) libRGFW$(LIB_EXT) libRGFW.a
191195

192-
examples: $(EXAMPLE_OUTPUTS) $(EXAMPLE_OUTPUTS_CUSTOM)
196+
examples: xdg-shell.c $(EXAMPLE_OUTPUTS) $(EXAMPLE_OUTPUTS_CUSTOM)
193197

194-
examples/gears/gears: examples/gears/gears.c RGFW.h
198+
tests: xdg-shell.c $(TEST_OUTPUTS)
199+
200+
examples/gears/gears: examples/gears/gears.c RGFW.h xdg-shell.c
195201
ifneq (,$(filter $(CC),emcc em++))
196202
@echo gears is not supported on this platform
197203
else
198204
$(CC) $(CFLAGS) -I. $< $(LINK_GL1) $(LIBS) -lm $($) -o $@$(EXT)
199205
endif
200206

201-
examples/srgb/srgb: examples/srgb/srgb.c RGFW.h
207+
examples/srgb/srgb: examples/srgb/srgb.c RGFW.h xdg-shell.c
202208
$(CC) $(CFLAGS) -I. $< $(LINK_GL1) $(LIBS) -lm $($) -o $@$(EXT)
203209

204-
examples/portableGL/pgl: examples/portableGL/pgl.c RGFW.h
210+
examples/portableGL/pgl: examples/portableGL/pgl.c RGFW.h xdg-shell.c
205211
ifeq (,$(filter $(CC),emcc em++))
206212
$(CC) -w $(CFLAGS) -I. $< -lm $(LIBS) -o $@
207213
else
208214
@echo "the portableGL example doesn't support html5"
209215
endif
210216

211-
examples/gles2/gles2: examples/gles2/gles2.c RGFW.h
217+
examples/gles2/gles2: examples/gles2/gles2.c RGFW.h xdg-shell.c
212218
ifneq ($(NO_GLES), 1)
213219
$(CC) $(CFLAGS) -I. $< $(LIBS) $(LINK_GL2) -lGL -o $@$(EXT)
214220
else
215221
@echo gles has been disabled
216222
endif
217223

218-
examples/egl/egl: examples/egl/egl.c RGFW.h
224+
examples/egl/egl: examples/egl/egl.c RGFW.h xdg-shell.c
219225
ifneq ($(NO_EGL), 1)
220226
$(CC) $(CFLAGS) -I. $< $(LIBS) $(LINK_GL1) -lGL -lEGL -o $@$(EXT)
221227
else
@@ -224,15 +230,15 @@ endif
224230

225231

226232

227-
examples/osmesa_demo/osmesa_demo: examples/osmesa_demo/osmesa_demo.c RGFW.h
233+
examples/osmesa_demo/osmesa_demo: examples/osmesa_demo/osmesa_demo.c RGFW.h xdg-shell.c
228234
ifneq ($(NO_OSMESA), 1)
229235
$(CC) $(CFLAGS) -I. $< $(LIBS) $(LINK_OSMESA) -lOSMesa -o $@$(EXT)
230236
else
231237
@echo osmesa has been disabled
232238
endif
233239

234240

235-
examples/vk10/vk10: examples/vk10/vk10.c examples/vk10/vkinit.h RGFW.h
241+
examples/vk10/vk10: examples/vk10/vk10.c examples/vk10/vkinit.h RGFW.h xdg-shell.c
236242
ifneq ($(NO_VULKAN), 1)
237243
glslangValidator -V examples/vk10/shaders/vert.vert -o examples/vk10/shaders/vert.h --vn vert_code
238244
glslangValidator -V examples/vk10/shaders/frag.frag -o examples/vk10/shaders/frag.h --vn frag_code
@@ -249,7 +255,7 @@ else
249255
$(CC) $(CFLAGS) -I. $< $(LIBS) $(LINK_GL1) $(DX11_LIBS) -D RGFW_NO_VULKAN -o $@
250256
endif
251257

252-
examples/dx11/dx11: examples/dx11/dx11.c RGFW.h
258+
examples/dx11/dx11: examples/dx11/dx11.c RGFW.h xdg-shell.c
253259
ifeq ($(CC), zig cc)
254260
@echo directX is not supported with Zig
255261
else ifneq (,$(filter $(CC),g++ clang++ "zig cc"))
@@ -261,14 +267,14 @@ else
261267
endif
262268

263269

264-
examples/metal/metal: examples/metal/metal.m RGFW.h
270+
examples/metal/metal: examples/metal/metal.m RGFW.h xdg-shell.c
265271
ifeq ($(detected_OS),Darwin) # Mac OS X
266272
$(CC) $(CFLAGS) examples/metal/metal.m -I. -framework CoreVideo -framework Metal -framework Cocoa -framework IOKit -framework QuartzCore -o $@
267273
else
268274
@echo metal is not supported on $(detected_OS)
269275
endif
270276

271-
examples/minimal_links/minimal_links: examples/minimal_links/minimal_links.c RGFW.h
277+
examples/minimal_links/minimal_links: examples/minimal_links/minimal_links.c RGFW.h xdg-shell.c
272278
ifeq ($(WAYLAND), 1)
273279
@echo nostl is not supported on this platform
274280
else ifneq (,$(filter $(CC),emcc em++))
@@ -286,7 +292,7 @@ else
286292
endif
287293

288294

289-
examples/nostl/nostl: examples/nostl/nostl.c RGFW.h
295+
examples/nostl/nostl: examples/nostl/nostl.c RGFW.h xdg-shell.c
290296
ifeq ($(WAYLAND), 1)
291297
@echo nostl is not supported on this platform
292298
else ifneq (,$(filter $(CC),emcc em++))
@@ -302,7 +308,7 @@ else
302308
endif
303309

304310

305-
examples/microui_demo/microui_demo: examples/microui_demo/microui_demo.c RGFW.h
311+
examples/microui_demo/microui_demo: examples/microui_demo/microui_demo.c RGFW.h xdg-shell.c
306312
ifeq (,$(filter $(CC),emcc em++ g++ clang++))
307313
$(CC) $(CFLAGS) -I. $< examples/microui_demo/microui.c $(LINK_GL1) $(LIBS) -o $@$(EXT)
308314
else ifneq (,$(filter $(CC),em++ g++ clang++))
@@ -311,18 +317,18 @@ else
311317
$(CC) $(CFLAGS) -I. $< examples/microui_demo/microui.c -s USE_WEBGL2 $(LIBS) $(LINK_GL1) -o $@$(EXT)
312318
endif
313319

314-
examples/window_icons/icons: examples/window_icons/icons.c RGFW.h
320+
examples/window_icons/icons: examples/window_icons/icons.c RGFW.h xdg-shell.c
315321
$(CC) $(CFLAGS) -I. $< $(LIBS) -lm $(LINK_GL1) -o $@$(EXT)
316-
examples/mouse_icons/icons: examples/mouse_icons/icons.c RGFW.h
322+
examples/mouse_icons/icons: examples/mouse_icons/icons.c RGFW.h xdg-shell.c
317323
$(CC) $(CFLAGS) -I. $< $(LIBS) -lm $(LINK_GL1) -o $@$(EXT)
318-
examples/gamepad/gamepad: examples/gamepad/gamepad.c RGFW.h
324+
examples/gamepad/gamepad: examples/gamepad/gamepad.c RGFW.h xdg-shell.c
319325
$(CC) $(CFLAGS) -I. $< $(LIBS) -lm $(LINK_GL1) -o $@$(EXT)
320326

321-
examples/first-person-camera/camera: examples/first-person-camera/camera.c RGFW.h
327+
examples/first-person-camera/camera: examples/first-person-camera/camera.c RGFW.h xdg-shell.c
322328
$(CC) $(CFLAGS) -I. $< $(LIBS) -lm $(LINK_GL1) -o $@$(EXT)
323329

324330

325-
examples/gl33/gl33: examples/gl33/gl33.c RGFW.h
331+
examples/gl33/gl33: examples/gl33/gl33.c RGFW.h xdg-shell.c
326332
ifeq ($(WAYLAND), 1)
327333
$(CC) $(CFLAGS) $(WARNINGS) -I. $< -lm $(LIBS) $(LINK_GL1) -lEGL -lwayland-egl -o $@$(EXT)
328334
else ifeq ($(detected_OS),NetBSD)
@@ -337,8 +343,15 @@ else
337343
$(CC) $(CFLAGS) $(WARNINGS) -I. $< $(LIBS) $(LINK_GL3) -o $@$(EXT)
338344
endif
339345

340-
$(EXAMPLE_OUTPUTS): %: %.c RGFW.h
346+
$(EXAMPLE_OUTPUTS): %: %.c RGFW.h xdg-shell.c
347+
$(CC) $(CFLAGS) $(WARNINGS) -I. $< $(LINK_GL1) $(LIBS) $($) -o $@$(EXT)
348+
349+
$(TEST_OUTPUTS): %: %.c RGFW.h xdg-shell.c
341350
$(CC) $(CFLAGS) $(WARNINGS) -I. $< $(LINK_GL1) $(LIBS) $($) -o $@$(EXT)
351+
@for exe in $(TEST_OUTPUTS); do \
352+
echo "Running $$exe..."; \
353+
./$$exe$(EXT); \
354+
done
342355

343356
debug: all
344357
@for exe in $(EXAMPLE_OUTPUTS); do \
@@ -366,7 +379,7 @@ endif
366379
$(MAKE) clean
367380

368381

369-
RGFW$(OBJ_FILE): RGFW.h
382+
RGFW$(OBJ_FILE): RGFW.h xdg-shell.c
370383
$(MAKE) initwayland
371384
#$(CC) -x c $(CUSTOM_CFLAGS) -c RGFW.h -D RGFW_IMPLEMENTATION -fPIC -D RGFW_EXPORT
372385
cp RGFW.h RGFW.c
@@ -407,7 +420,7 @@ else
407420
endif
408421

409422
clean:
410-
rm -f *.o *.obj *.dll .dylib *.a *.so $(EXAMPLE_OUTPUTS) $(EXAMPLE_OUTPUTS_CUSTOM) .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.exe .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.js .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.wasm .$(OS_DIR)examples$(OS_DIR)vk10$(OS_DIR)shaders$(OS_DIR)*.h
423+
rm -f *.o *.obj *.dll .dylib *.a *.so $(EXAMPLE_OUTPUTS) $(EXAMPLE_OUTPUTS_CUSTOM) $(TEST_OUTPUTS) .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.exe .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.js .$(OS_DIR)examples$(OS_DIR)*$(OS_DIR)*.wasm .$(OS_DIR)examples$(OS_DIR)vk10$(OS_DIR)shaders$(OS_DIR)*.h
411424

412425

413426
.PHONY: all examples clean

0 commit comments

Comments
 (0)