new: automated tests
|
@ -25,3 +25,5 @@ plugins
|
|||
tools/assimp-vc*-mt.lib
|
||||
tools/assimp/
|
||||
v4k.code-workspace
|
||||
tests/out
|
||||
tests/diff
|
||||
|
|
2
MAKE.bat
|
@ -587,6 +587,8 @@ rem del ??-*.* > nul 2> nul
|
|||
rd /q /s _fwk > nul 2> nul
|
||||
rd /q /s _cache > nul 2> nul
|
||||
rd /q /s _deploy > nul 2> nul
|
||||
rd /q /s tests\out > nul 2> nul
|
||||
rd /q /s tests\diff > nul 2> nul
|
||||
rem rd /q /s _project > nul 2> nul
|
||||
del tcc.bat > nul 2> nul
|
||||
del sh.bat > nul 2> nul
|
||||
|
|
28
TEST.bat
|
@ -1,5 +1,31 @@
|
|||
@echo off
|
||||
|
||||
set WORKDIR=%~dp0
|
||||
call make cook
|
||||
|
||||
mkdir %WORKDIR%\tests > nul 2> nul
|
||||
mkdir %WORKDIR%\tests\out > nul 2> nul
|
||||
mkdir %WORKDIR%\tests\ref > nul 2> nul
|
||||
mkdir %WORKDIR%\tests\diff > nul 2> nul
|
||||
|
||||
where gm > nul 2> nul
|
||||
if errorlevel 1 (
|
||||
echo "gm" not found. Please install GraphicsMagick and add it to the PATH.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for %%x in (*.exe) do (
|
||||
echo Running %%x...
|
||||
start /wait "" "%%x"
|
||||
start /wait "" "%%x" --nocook --capture=50
|
||||
|
||||
if not exist %WORKDIR%\tests\ref\%%~nx.exe.png (
|
||||
echo Reference image not found. Copying %%~nx.exe.png ...
|
||||
copy %WORKDIR%\tests\out\%%~nx.exe.png %WORKDIR%\tests\ref\%%~nx.exe.png
|
||||
) else (
|
||||
call gm compare -metric MSE -maximum-error 0.02 %WORKDIR%\tests\ref\%%~nx.exe.png %WORKDIR%\tests\out\%%~nx.exe.png -file %WORKDIR%\tests\diff\%%~nx.exe.png > nul 2> nul
|
||||
if errorlevel 1 (
|
||||
echo Images differ too much. Check %WORKDIR%\tests\diff\%%~nx.exe.png
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#include "v4k.h"
|
||||
|
||||
int main() {
|
||||
trap_install();
|
||||
app_crash();
|
||||
return 0;
|
||||
}
|
|
@ -392583,6 +392583,8 @@ void glNewFrame() {
|
|||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
}
|
||||
|
||||
static bool cook_done = false;
|
||||
|
||||
bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
||||
// abort run if any test suite failed in unit-test mode
|
||||
ifdef(debug, if( flag("--test") ) exit( test_errors ? -test_errors : 0 ));
|
||||
|
@ -392771,6 +392773,7 @@ bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
|||
}
|
||||
|
||||
if(cook_cancelling) cook_stop(), exit(-1);
|
||||
cook_done = true;
|
||||
|
||||
v4k_post_init(mode->refreshRate);
|
||||
return true;
|
||||
|
@ -392978,6 +392981,17 @@ int window_swap() {
|
|||
window_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t capture_frame = 0;
|
||||
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
|
||||
void *rgb = screenshot(3);
|
||||
stbi_flip_vertically_on_write(true);
|
||||
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
|
||||
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -260,6 +260,8 @@ void glNewFrame() {
|
|||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
}
|
||||
|
||||
static bool cook_done = false;
|
||||
|
||||
bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
||||
// abort run if any test suite failed in unit-test mode
|
||||
ifdef(debug, if( flag("--test") ) exit( test_errors ? -test_errors : 0 ));
|
||||
|
@ -448,6 +450,7 @@ bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
|||
}
|
||||
|
||||
if(cook_cancelling) cook_stop(), exit(-1);
|
||||
cook_done = true;
|
||||
|
||||
v4k_post_init(mode->refreshRate);
|
||||
return true;
|
||||
|
@ -655,6 +658,17 @@ int window_swap() {
|
|||
window_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t capture_frame = 0;
|
||||
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
|
||||
void *rgb = screenshot(3);
|
||||
stbi_flip_vertically_on_write(true);
|
||||
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
|
||||
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
14
engine/v4k.c
|
@ -27123,6 +27123,8 @@ void glNewFrame() {
|
|||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
|
||||
}
|
||||
|
||||
static bool cook_done = false;
|
||||
|
||||
bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
||||
// abort run if any test suite failed in unit-test mode
|
||||
ifdef(debug, if( flag("--test") ) exit( test_errors ? -test_errors : 0 ));
|
||||
|
@ -27311,6 +27313,7 @@ bool window_create_from_handle(void *handle, float scale, unsigned flags) {
|
|||
}
|
||||
|
||||
if(cook_cancelling) cook_stop(), exit(-1);
|
||||
cook_done = true;
|
||||
|
||||
v4k_post_init(mode->refreshRate);
|
||||
return true;
|
||||
|
@ -27518,6 +27521,17 @@ int window_swap() {
|
|||
window_shutdown();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t capture_frame = 0;
|
||||
if (cook_done && optioni("--capture", 0) && capture_frame++ == optioni("--capture", 0)) {
|
||||
void *rgb = screenshot(3);
|
||||
stbi_flip_vertically_on_write(true);
|
||||
if(!stbi_write_png(va("tests/out/%s.png", argv(0)), w, h, 3, rgb, 3 * w) ) {
|
||||
PANIC("!could not write screenshot file `%s`\n", screenshot_file);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 227 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 326 KiB |
After Width: | Height: | Size: 840 KiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 422 KiB |
After Width: | Height: | Size: 969 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 1017 KiB |
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 157 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 93 KiB |
After Width: | Height: | Size: 320 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 420 KiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 4.4 MiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 263 KiB |
After Width: | Height: | Size: 1.9 MiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 181 KiB |
After Width: | Height: | Size: 941 KiB |