-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a test for version macros/functions #60
Merged
Free-Pascal-meets-SDL-Website
merged 7 commits into
PascalGameDevelopment:master
from
Free-Pascal-meets-SDL-Website:addversiontest
Jul 11, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
da544f4
Create a test for version macros/functions
Free-Pascal-meets-SDL-Website c00451b
Add version test to CI script for Linux and MacOS
Free-Pascal-meets-SDL-Website f6d54e5
Remove SDL init part
Free-Pascal-meets-SDL-Website 48d2ab5
Replace checks against False
Free-Pascal-meets-SDL-Website d72e8eb
Optimize: Call SDL_VERSIONNUM macro once only
Free-Pascal-meets-SDL-Website 21dd9dc
Cosmetic: Change version digits for failing "version at least"-test
Free-Pascal-meets-SDL-Website 1dd5472
Fix: Remove accidental not-operator
Free-Pascal-meets-SDL-Website File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -61,6 +61,15 @@ jobs: | |
- name: Test 1 - Run Init Test | ||
run: | | ||
./tests/testinit | ||
- name: Test 2 - Compile Version Test | ||
uses: suve/[email protected] | ||
with: | ||
source: tests/testversion.pas | ||
flags: Fl/usr/local/lib | ||
verbosity: ewnh | ||
- name: Test 2 - Run Version Test | ||
run: | | ||
./tests/testversion | ||
ubuntu-20-04: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
|
@@ -113,6 +122,14 @@ jobs: | |
mkdir ~/tmp | ||
export XDG_RUNTIME_DIR=~/tmp | ||
./tests/testinit | ||
- name: Test 2 - Compile Version Test | ||
uses: suve/[email protected] | ||
with: | ||
source: tests/testversion.pas | ||
verbosity: ewnh | ||
- name: Test 2 - Run Version Test | ||
run: | | ||
./tests/testversion | ||
windows-2022: | ||
runs-on: windows-2022 | ||
steps: | ||
|
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 testversion; | ||
|
||
{ | ||
|
||
Test version macros/functions of SDL2 system. | ||
|
||
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); | ||
|
||
var | ||
CompiledVersion: TSDL_Version = (major: 0; minor: 0; patch: 0); | ||
LinkedVersion: TSDL_Version = (major: 0; minor: 0; patch: 0); | ||
VersionNum: Cardinal = 0; | ||
begin | ||
write('Start SDL2 version test... '); | ||
|
||
try | ||
VersionNum := SDL_VERSIONNUM(1,2,3); | ||
if (VersionNum <> 1203) then | ||
raise ESDL2Error.Create('SDL_VERSIONNUM failed: 1203 expected, found: ' + IntToStr(VersionNum)); | ||
|
||
SDL_VERSION(CompiledVersion); | ||
if (SDL_COMPILEDVERSION <> SDL_VERSIONNUM(CompiledVersion.major, CompiledVersion.minor, CompiledVersion.patch)) then | ||
raise ESDL2Error.Create('SDL_VERSION or SDL_COMPILEDVERSION failed: Version results do not match!'); | ||
|
||
if not SDL_VERSION_ATLEAST(2,0,0) then | ||
raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 2.0.0 should be true!'); | ||
|
||
if SDL_VERSION_ATLEAST(3,0,0) then | ||
raise ESDL2Error.Create('SDL_VERSION_ATLEAST failed: Version at least 3.0.0 should be false!'); | ||
|
||
SDL_GetVersion(@LinkedVersion); | ||
if @LinkedVersion = nil then | ||
raise ESDL2Error.Create('SDL_GetVersion failed: ' + SDL_GetError()); | ||
|
||
if SDL_VERSIONNUM(LinkedVersion.major, LinkedVersion.minor, LinkedVersion.patch) = 0 then | ||
raise ESDL2Error.Create('SDL_GetVersion failed: Returns 0.0.0 .'); | ||
except | ||
end; | ||
|
||
writeln('finished.'); | ||
end. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? - Without this part testversion.pas is not compiled, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean strictly this line, where
-Fl/usr/local/lib
is passed to the compiler. The SDL packages installed from the repo should install libraries in/usr/lib
, which is one of the locations where the compiler looks by default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why it is there, is that without this line the sdl2 library is not found. From my memory, it is related to a new way of storing libraries on big sur, they are in fact not some files stored in a folder anymore but in a more sophisticated indexed "library file".
See. 8f7b010
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I missed that this is part of the Mac job. I suppose that since
brew
is not the official package manager, the authors decided to put stuff in/usr/local
over/usr
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see :)