Skip to content

Enable automation of MATLAB tests #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 11, 2025
Merged
25 changes: 23 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ on:
workflow_dispatch:

jobs:
build-and-test:
typescript-build-and-test:
name: ${{ matrix.os }}-${{ matrix.node-version }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Expand All @@ -37,5 +38,25 @@ jobs:
run: npm ci
- name: Build
run: npm run compile
- name: Run Unit Tests
- name: Run TypeScript Unit Tests
run: npm test

matlab-test:
env:
MATLAB_TEST_ENVIRONMENT: 1
name: ${{ matrix.matlab-version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b, R2024a, latest]
os: [windows-latest, ubuntu-latest, macos-13]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/[email protected]
with:
release: ${{ matrix.matlab-version }}
- name: Run MATLAB Unit Tests
uses: matlab-actions/[email protected]
Binary file modified matlab/+matlabls/+internal/computeCodeData.p
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
% Copyright 2025 The MathWorks, Inc.
classdef tGetFoldingRanges < matlab.unittest.TestCase
methods (TestClassSetup)
function isApplicable (testCase)
% Determine if the test should be skipped in the current environment
testCase.assumeTrue(...
~isMATLABReleaseOlderThan('R2024b'),...
"Code folding only supported in R2024b and later.");
end

function setup (~)
% Add function under test to path
addpath("../../../../../matlab");
Expand Down
10 changes: 10 additions & 0 deletions tests/matlab/matlabls/handlers/formatting/tFormatCode.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
end

methods (TestClassSetup)
function isApplicable (testCase)
% Determine if the test should be skipped in the current environment
isTestingEnvironment = ~isempty(getenv('MATLAB_TEST_ENVIRONMENT'));
shouldRun = ~(isMATLABReleaseOlderThan('R2024b') && isTestingEnvironment);

testCase.assumeTrue(...
shouldRun,...
"Document formatting test cannot run prior to 24b in GitHub test environment.");
end

function setup (~)
% Add function under test to path
addpath("../../../../../matlab");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function testParsingScriptFile (testCase)
testCase.assertEqual(result.references, expectedReferences);

expectedSections = {
struct(title = "Create Data", range = toRange(3, 1, 6, 2)),...
struct(title = "Create Data", range = toRange(3, 1, 6, 1)),...
struct(title = "Plot", range = toRange(7, 1, 8, 11))
};

Expand Down
7 changes: 7 additions & 0 deletions tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
% Copyright 2025 The MathWorks, Inc.
classdef tGetSuppressionEdits < matlab.unittest.TestCase
methods (TestClassSetup)
function isApplicable (testCase)
% Determine if the test should be skipped in the current environment
testCase.assumeTrue(...
~isMATLABReleaseOlderThan('R2022a'),...
"Diagnostic suppression tests require R2022a and later.");
end

function setup (~)
% Add function under test to path
addpath("../../../../../matlab");
Expand Down