Skip to content

Commit 6fbf1c7

Browse files
alexj0sealexjose
and
alexjose
authored
Add test for R2023a (#23)
* Add test for R2023a * Uninstall matlabengine in teardown --------- Co-authored-by: alexjose <[email protected]>
1 parent ce99ceb commit 6fbf1c7

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/qualify_23a.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Run tInstall on Ubuntu against python versions 3.10, 3.9 and 3.8
2+
3+
name: Test R2023a
4+
5+
on:
6+
push:
7+
branches:
8+
- R2023a
9+
10+
pull_request:
11+
branches:
12+
- R2023a
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
18+
19+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
20+
jobs:
21+
test-python-engine:
22+
strategy:
23+
matrix:
24+
python: ["3.10", "3.9", "3.8"]
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Set up Python
30+
uses: actions/[email protected]
31+
with:
32+
python-version: ${{ matrix.python }}
33+
34+
- name: Set up MATLAB
35+
uses: matlab-actions/setup-matlab@v1
36+
with:
37+
release: R2023a
38+
39+
- uses: actions/checkout@v3
40+
41+
- name: Run tests
42+
uses: matlab-actions/run-tests@v1

test/tInstall.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
classdef tInstall < matlab.unittest.TestCase
2+
% Verify installation of matlab engine
3+
4+
% Copyright 2023 Mathworks, Inc.
5+
6+
properties (Constant)
7+
MATLABVersion = string(ver('MATLAB').Version) % Example: 9.14
8+
end
9+
10+
methods (Test)
11+
function installNoVersionSpecified(testCase)
12+
[status, out] = system("pip install matlabengine");
13+
addTeardown(testCase, @system, "pip uninstall -y matlabengine");
14+
verifyEqual(testCase, status, 0, out)
15+
verifyInstallation(testCase)
16+
end
17+
18+
function installMatchingEngine(testCase)
19+
[status, out] = system("pip install matlabengine==" + testCase.MATLABVersion + ".*");
20+
addTeardown(testCase, @system, "pip uninstall -y matlabengine");
21+
verifyEqual(testCase, status, 0, out)
22+
verifyInstallation(testCase)
23+
end
24+
end
25+
26+
methods
27+
function verifyInstallation(testCase)
28+
% Verify installation by calling functions in matlab engine
29+
% Share this session and see if find_matlab can find it.
30+
sharedEngineName = matlab.engine.engineName;
31+
if isempty(sharedEngineName)
32+
sharedEngineName = 'MATLAB_tInstall';
33+
matlab.engine.shareEngine(sharedEngineName)
34+
end
35+
pySharedEngineName = char(py.matlab.engine.find_matlab());
36+
verifySubstring(testCase, pySharedEngineName, sharedEngineName)
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)