Skip to content

Commit 4765aa2

Browse files
authored
Enable automation of MATLAB tests (#59)
* Add usage of `matlab-actions/run-tests` to test automation * Set up MATLAB prior to running tests in test action * Move MATLAB testing to separate job * Specify MATLAB version * Checkout before MATLAB tests * Resolve test failures * Update assertion * Temporarily update test action to run against all supported MATLAB versions * Leverage `testCase.assumeTrue` to skip tests in certain environments * Update tFormatCode `assumeTrue` condition * Update tFormatCode isApplicable check to check Java Swing again * Return isApplicable check to checking for the testing environment * Fix message text
1 parent 073aaa1 commit 4765aa2

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

.github/workflows/test.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ on:
1616
workflow_dispatch:
1717

1818
jobs:
19-
build-and-test:
19+
typescript-build-and-test:
2020
name: ${{ matrix.os }}-${{ matrix.node-version }}
2121
runs-on: ${{ matrix.os }}
2222

2323
strategy:
24+
fail-fast: false
2425
matrix:
2526
node-version: [18.x, 20.x, 22.x]
2627
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
@@ -37,5 +38,25 @@ jobs:
3738
run: npm ci
3839
- name: Build
3940
run: npm run compile
40-
- name: Run Unit Tests
41+
- name: Run TypeScript Unit Tests
4142
run: npm test
43+
44+
matlab-test:
45+
env:
46+
MATLAB_TEST_ENVIRONMENT: 1
47+
name: ${{ matrix.matlab-version }}-${{ matrix.os }}
48+
runs-on: ${{ matrix.os }}
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b, R2024a, latest]
53+
os: [windows-latest, ubuntu-latest, macos-13]
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
- name: Set up MATLAB
58+
uses: matlab-actions/[email protected]
59+
with:
60+
release: ${{ matrix.matlab-version }}
61+
- name: Run MATLAB Unit Tests
62+
uses: matlab-actions/[email protected]
37 Bytes
Binary file not shown.

tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
% Copyright 2025 The MathWorks, Inc.
22
classdef tGetFoldingRanges < matlab.unittest.TestCase
33
methods (TestClassSetup)
4+
function isApplicable (testCase)
5+
% Determine if the test should be skipped in the current environment
6+
testCase.assumeTrue(...
7+
~isMATLABReleaseOlderThan('R2024b'),...
8+
"Code folding only supported in R2024b and later.");
9+
end
10+
411
function setup (~)
512
% Add function under test to path
613
addpath("../../../../../matlab");

tests/matlab/matlabls/handlers/formatting/tFormatCode.m

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
end
66

77
methods (TestClassSetup)
8+
function isApplicable (testCase)
9+
% Determine if the test should be skipped in the current environment
10+
isTestingEnvironment = ~isempty(getenv('MATLAB_TEST_ENVIRONMENT'));
11+
shouldRun = ~(isMATLABReleaseOlderThan('R2024b') && isTestingEnvironment);
12+
13+
testCase.assumeTrue(...
14+
shouldRun,...
15+
"Document formatting test cannot run prior to 24b in GitHub test environment.");
16+
end
17+
818
function setup (~)
919
% Add function under test to path
1020
addpath("../../../../../matlab");

tests/matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function testParsingScriptFile (testCase)
3636
testCase.assertEqual(result.references, expectedReferences);
3737

3838
expectedSections = {
39-
struct(title = "Create Data", range = toRange(3, 1, 6, 2)),...
39+
struct(title = "Create Data", range = toRange(3, 1, 6, 1)),...
4040
struct(title = "Plot", range = toRange(7, 1, 8, 11))
4141
};
4242

tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
% Copyright 2025 The MathWorks, Inc.
22
classdef tGetSuppressionEdits < matlab.unittest.TestCase
33
methods (TestClassSetup)
4+
function isApplicable (testCase)
5+
% Determine if the test should be skipped in the current environment
6+
testCase.assumeTrue(...
7+
~isMATLABReleaseOlderThan('R2022a'),...
8+
"Diagnostic suppression tests require R2022a and later.");
9+
end
10+
411
function setup (~)
512
% Add function under test to path
613
addpath("../../../../../matlab");

0 commit comments

Comments
 (0)