-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Free-Pascal-meets-SDL-Website/addtest-2
Add (first) test (SDL_Init), compilation and execution workflow
- Loading branch information
Showing
4 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
branches: [ master ] | ||
|
||
jobs: | ||
macos-11: | ||
macos-11-big-sur: | ||
runs-on: macos-11 | ||
steps: | ||
- name: Install FPC | ||
|
@@ -46,6 +46,21 @@ jobs: | |
with: | ||
source: units/sdl2_ttf.pas | ||
verbosity: ewnh | ||
- name: Install SDL2 library | ||
run: brew install sdl2 | ||
- name: Get SDL2 library version and path(s) | ||
run: | | ||
sdl2-config --version | ||
sdl2-config --libs | ||
- name: Test 1 - Compile Init Test | ||
uses: suve/[email protected] | ||
with: | ||
source: tests/testinit.pas | ||
flags: Fl/usr/local/lib | ||
verbosity: ewnh | ||
- name: Test 1 - Run Init Test | ||
run: | | ||
./tests/testinit | ||
ubuntu-20-04: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
|
@@ -86,6 +101,18 @@ jobs: | |
with: | ||
source: units/sdl2_ttf.pas | ||
verbosity: ewnh | ||
- name: Install SDL2 library | ||
run: sudo apt-get install libsdl2-dev | ||
- name: Test 1 - Compile Init Test | ||
uses: suve/[email protected] | ||
with: | ||
source: tests/testinit.pas | ||
verbosity: ewnh | ||
- name: Test 1 - Run Init Test | ||
run: | | ||
mkdir ~/tmp | ||
export XDG_RUNTIME_DIR=~/tmp | ||
./tests/testinit | ||
windows-2022: | ||
runs-on: windows-2022 | ||
steps: | ||
|
@@ -124,4 +151,14 @@ jobs: | |
with: | ||
source: units/sdl2_ttf.pas | ||
verbosity: ewnh | ||
|
||
- name: Test 1 - Compile Init Test | ||
uses: suve/[email protected] | ||
with: | ||
source: tests/testinit.pas | ||
flags: Flunits | ||
verbosity: ewnh | ||
# !!! Since no SDL2.DLL is available via chocolatey, the run will fail. | ||
# TODO: Find solution to install SDL2 binary. | ||
# - name: Test 1 - Run Init Test | ||
# run: | | ||
# ./tests/testinit.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
program testinit; | ||
|
||
{ | ||
Test initilization of SDL2 system with a sample of flags. | ||
This file is part of | ||
SDL2-for-Pascal | ||
Copyright (C) 2020-2022 PGD Community | ||
Visit: https://github.com/PascalGameDevelopment/SDL2-for-Pascal | ||
} | ||
|
||
{$I testsettings.inc} | ||
|
||
uses | ||
Classes, SysUtils, SDL2; | ||
|
||
type | ||
ESDL2Error = class(Exception); | ||
|
||
const | ||
Flags: array[0..12] of TSDL_Init = ( | ||
{ single flags } | ||
SDL_INIT_TIMER, SDL_INIT_AUDIO, SDL_INIT_VIDEO, | ||
SDL_INIT_JOYSTICK, SDL_INIT_HAPTIC, SDL_INIT_GAMECONTROLLER, | ||
SDL_INIT_EVENTS, SDL_INIT_SENSOR, SDL_INIT_NOPARACHUTE, | ||
SDL_INIT_EVERYTHING, | ||
{ typically combined flags } | ||
SDL_INIT_AUDIO or SDL_INIT_VIDEO, | ||
SDL_INIT_VIDEO or SDL_INIT_JOYSTICK, | ||
SDL_INIT_VIDEO or SDL_INIT_GAMECONTROLLER or SDL_INIT_AUDIO); | ||
|
||
var | ||
Flag: TSDL_Init; | ||
begin | ||
write('Start SDL2 inilization test... '); | ||
for Flag in Flags do | ||
begin | ||
try | ||
if SDL_Init(Flag) <> 0 then | ||
raise ESDL2Error.Create('SDL_Init failed: Flag = ' + IntToStr(Flag)); | ||
except | ||
on E: ESDL2Error do | ||
try | ||
SDL_Quit; | ||
except | ||
raise; | ||
end; | ||
end; | ||
SDL_Quit; | ||
end; | ||
writeln(' finished.'); | ||
end. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{$IFDEF FPC} | ||
{$MODE DELPHI}{$H+} | ||
{$UNITPATH ../units} // Does this work in Delphi? | ||
{$ENDIF} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters