Skip to content

Commit

Permalink
Add MATLAB unit tests and update build process for Windows
Browse files Browse the repository at this point in the history
Updated `build.yml` to include steps for running MATLAB unit tests on Windows runners:
- Copy `MEXlibCZI.mexw64` to `tests/MATLAB` if it exists.
- Run MATLAB tests using `matlab-actions/run-command@v2`.

Added `TestMEXlibCZI_Basic_Operation` class in `TestMEXlibCZI_Basic_Operation.m`:
- `testGetVersion_VersionString`: Verifies `VersionString`.
- `testGetVersion_libCZIVersion`: Verifies `libCZIVersion`.
- `testGetVersion_CompilerIdentification`: Verifies `CompilerIdentification`.

Defined `checkVersionString` function to validate version strings.
  • Loading branch information
ptahmose committed Oct 19, 2024
1 parent 08a67af commit 928a870
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ jobs:
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
- name: Prepare MATLAB unit tests
if: runner.os == 'Windows'
shell: bash
run: |
# if on Windows, then this is the mex-file we need to copy to the tests/MATLAB folder
if [ -f "build/MEXlibCZI/Release/MEXlibCZI.mexw64" ]; then
cp "build/MEXlibCZI/Release/MEXlibCZI.mexw64" tests/MATLAB/
fi
- name: Run statements
if: runner.os == 'Windows'
uses: matlab-actions/run-command@v2
with:
command: cd tests/MATLAB; results = runtests, assertSuccess(results);
- name: Prepare MATLAB artifact (Linux)
id: prepare_linux_matlab_artifact
if: runner.os == 'Linux'
Expand Down
31 changes: 31 additions & 0 deletions tests/MATLAB/TestMEXlibCZI_Basic_Operation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
% File: test_basic_operation.m
classdef TestMEXlibCZI_Basic_Operation < matlab.unittest.TestCase

methods (Test)
function testGetVersion_VersionString(testCase)
version = MEXlibCZI('GetVersion');
testCase.verifyTrue(checkVersionString(version.VersionString));
end

function testGetVersion_libCZIVersion(testCase)
version = MEXlibCZI('GetVersion');
testCase.verifyTrue(checkVersionString(version.libCZIVersion));
end

function testGetVersion_CompilerIdentification(testCase)
version = MEXlibCZI('GetVersion');
testCase.verifyTrue(~isempty(version.CompilerIdentification));
end
end
end

% Local function outside of the class definition
function result = checkVersionString(versionString)
% Check if the VersionString starts with '0.3.0'
match = regexp(versionString, '^\d{1,3}\.\d{1,3}\.\d{1,3}', 'once');
if isempty(match)
result = false; % No match found, return false
else
result = true; % Match found, return true
end
end

0 comments on commit 928a870

Please sign in to comment.