Skip to content

Commit 9831d81

Browse files
authored
Add tests for R2021a (#27)
1 parent 6f517e0 commit 9831d81

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/qualify_21a.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Run tInstall in R2021a on Ubuntu against Python 3.8
2+
3+
name: Test R2021a
4+
5+
on:
6+
push:
7+
branches:
8+
- R2021a
9+
10+
pull_request:
11+
branches:
12+
- R2021a
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+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Set up Python
26+
uses: actions/[email protected]
27+
with:
28+
python-version: 3.8
29+
30+
- name: Set up MATLAB
31+
uses: matlab-actions/setup-matlab@v1
32+
with:
33+
release: R2021a
34+
35+
- uses: actions/checkout@v3
36+
37+
- name: Run tests
38+
uses: matlab-actions/run-tests@v1

test/tInstall.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 installMatchingEngine(testCase)
12+
[status, out] = system("pip install matlabengine==" + testCase.MATLABVersion + ".*");
13+
addTeardown(testCase, @system, "pip uninstall -y matlabengine")
14+
verifyEqual(testCase, status, 0, out)
15+
verifyInstallation(testCase)
16+
end
17+
end
18+
19+
methods
20+
function verifyInstallation(testCase)
21+
% Verify installation by calling functions in matlab engine
22+
% Share this session and see if find_matlab can find it.
23+
sharedEngineName = matlab.engine.engineName;
24+
if isempty(sharedEngineName)
25+
sharedEngineName = 'MATLAB_tInstall';
26+
matlab.engine.shareEngine(sharedEngineName)
27+
end
28+
pySharedEngineName = char(py.matlab.engine.find_matlab());
29+
verifySubstring(testCase, pySharedEngineName, sharedEngineName)
30+
end
31+
end
32+
end

0 commit comments

Comments
 (0)