From 4eca84002148b61f35eedcf11ad73206576a8ddb Mon Sep 17 00:00:00 2001 From: alexjose Date: Thu, 11 May 2023 14:39:33 -0400 Subject: [PATCH 1/2] Add test for R2023a --- .github/workflows/qualify_23a.yml | 42 +++++++++++++++++++++++++++++++ test/tInstall.m | 38 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/qualify_23a.yml create mode 100644 test/tInstall.m diff --git a/.github/workflows/qualify_23a.yml b/.github/workflows/qualify_23a.yml new file mode 100644 index 0000000..cc3f271 --- /dev/null +++ b/.github/workflows/qualify_23a.yml @@ -0,0 +1,42 @@ +# Run tInstall on Ubuntu against python versions 3.10, 3.9 and 3.8 + +name: Test R2023a + +on: + push: + branches: + - R2023a + + pull_request: + branches: + - R2023a + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + test-python-engine: + strategy: + matrix: + python: ["3.10", "3.9", "3.8"] + + runs-on: ubuntu-latest + + steps: + - name: Set up Python + uses: actions/setup-python@v3.1.3 + with: + python-version: ${{ matrix.python }} + + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v1 + with: + release: R2023a + + - uses: actions/checkout@v3 + + - name: Run tests + uses: matlab-actions/run-tests@v1 diff --git a/test/tInstall.m b/test/tInstall.m new file mode 100644 index 0000000..76361e1 --- /dev/null +++ b/test/tInstall.m @@ -0,0 +1,38 @@ +classdef tInstall < matlab.unittest.TestCase +% Verify installation of matlab engine + +% Copyright 2023 Mathworks, Inc. + + properties (Constant) + MATLABVersion = string(ver('MATLAB').Version) % Example: 9.14 + end + + methods (Test) + function installNoVersionSpecified(testCase) + [status, out] = system("pip install matlabengine"); + verifyEqual(testCase, status, 0, out) + verifyInstallation(testCase) + end + + function installMatchingEngine(testCase) + [status, out] = system("pip install matlabengine==" + testCase.MATLABVersion + ".*"); + verifyEqual(testCase, status, 0, out) + verifyInstallation(testCase) + end + end + + methods + function verifyInstallation(testCase) + % Verify installation by calling functions in matlab engine + % Share this session and see if find_matlab can find it. + sharedEngineName = matlab.engine.engineName; + if isempty(sharedEngineName) + sharedEngineName = 'MATLAB_tInstall'; + matlab.engine.shareEngine(sharedEngineName) + end + pySharedEngineName = char(py.matlab.engine.find_matlab()); + verifySubstring(testCase, pySharedEngineName, sharedEngineName) + system("pip uninstall -y matlabengine"); + end + end +end \ No newline at end of file From c66c525bf17417efeae2d470746a0e114f75a3d8 Mon Sep 17 00:00:00 2001 From: alexj0se Date: Thu, 11 May 2023 15:36:01 -0400 Subject: [PATCH 2/2] Uninstall matlabengine in teardown --- test/tInstall.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/tInstall.m b/test/tInstall.m index 76361e1..ecd3e76 100644 --- a/test/tInstall.m +++ b/test/tInstall.m @@ -10,12 +10,14 @@ methods (Test) function installNoVersionSpecified(testCase) [status, out] = system("pip install matlabengine"); + addTeardown(testCase, @system, "pip uninstall -y matlabengine"); verifyEqual(testCase, status, 0, out) verifyInstallation(testCase) end function installMatchingEngine(testCase) [status, out] = system("pip install matlabengine==" + testCase.MATLABVersion + ".*"); + addTeardown(testCase, @system, "pip uninstall -y matlabengine"); verifyEqual(testCase, status, 0, out) verifyInstallation(testCase) end @@ -32,7 +34,6 @@ function verifyInstallation(testCase) end pySharedEngineName = char(py.matlab.engine.find_matlab()); verifySubstring(testCase, pySharedEngineName, sharedEngineName) - system("pip uninstall -y matlabengine"); end end end \ No newline at end of file