From af0c729d836ac95ff472b44052461b558282eaf7 Mon Sep 17 00:00:00 2001 From: alexj0se Date: Mon, 22 May 2023 15:45:30 -0400 Subject: [PATCH] Add tests for R2021a --- .github/workflows/qualify_21a.yml | 38 +++++++++++++++++++++++++++++++ test/tInstall.m | 32 ++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/qualify_21a.yml create mode 100644 test/tInstall.m diff --git a/.github/workflows/qualify_21a.yml b/.github/workflows/qualify_21a.yml new file mode 100644 index 0000000..29a42b3 --- /dev/null +++ b/.github/workflows/qualify_21a.yml @@ -0,0 +1,38 @@ +# Run tInstall in R2021a on Ubuntu against Python 3.8 + +name: Test R2021a + +on: + push: + branches: + - R2021a + + pull_request: + branches: + - R2021a + + # 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: + runs-on: ubuntu-latest + + steps: + - name: Set up Python + uses: actions/setup-python@v3.1.3 + with: + python-version: 3.8 + + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v1 + with: + release: R2021a + + - 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..3cc46a5 --- /dev/null +++ b/test/tInstall.m @@ -0,0 +1,32 @@ +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 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 + 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) + end + end +end \ No newline at end of file