From c5023cba75af4f04b4440f7573fd967c1eecfcda Mon Sep 17 00:00:00 2001 From: Duncan Lilley Date: Thu, 6 Mar 2025 13:17:22 -0500 Subject: [PATCH 01/13] Add usage of `matlab-actions/run-tests` to test automation --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c2455bc..ad7037a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,5 +37,7 @@ jobs: run: npm ci - name: Build run: npm run compile - - name: Run Unit Tests + - name: Run TypeScript Unit Tests run: npm test + - name: Run MATLAB Unit Tests + uses: matlab-actions/run-tests@v2.1.1 From 3a2794a31eefdf78f7fb8c29a9802a626633da9c Mon Sep 17 00:00:00 2001 From: Duncan Lilley Date: Thu, 6 Mar 2025 13:21:49 -0500 Subject: [PATCH 02/13] Set up MATLAB prior to running tests in test action --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad7037a..1304f8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,5 +39,7 @@ jobs: run: npm run compile - name: Run TypeScript Unit Tests run: npm test + - name: Set up MATLAB + uses: matlab-actions/setup-matlab@v2.2.0 - name: Run MATLAB Unit Tests uses: matlab-actions/run-tests@v2.1.1 From e2498e2bdb384fc1a99a3ae9dd8e7d7ccafceb0b Mon Sep 17 00:00:00 2001 From: dlilley Date: Thu, 6 Mar 2025 13:50:06 -0500 Subject: [PATCH 03/13] Move MATLAB testing to separate job --- .github/workflows/test.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1304f8b..cb6e18d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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/ @@ -39,6 +40,16 @@ jobs: run: npm run compile - name: Run TypeScript Unit Tests run: npm test + + matlab-test: + name: ${{ matrix.matlab-version }}-${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + matlab-version: [R2021b, R2022a, R2022b, latest] + os: [windows-latest, ubuntu-latest, macos-13] + steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2.2.0 - name: Run MATLAB Unit Tests From a5fa1e987dc1a712731f88807f9241ee85836fa7 Mon Sep 17 00:00:00 2001 From: dlilley Date: Thu, 6 Mar 2025 13:52:00 -0500 Subject: [PATCH 04/13] Specify MATLAB version --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cb6e18d..5f4aad0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,5 +52,7 @@ jobs: steps: - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2.2.0 + with: + release: ${{ matrix.matlab-version }} - name: Run MATLAB Unit Tests uses: matlab-actions/run-tests@v2.1.1 From 4ab6df09e66d2bc6bcba9f610a9a61ef627d1f4b Mon Sep 17 00:00:00 2001 From: dlilley Date: Thu, 6 Mar 2025 13:59:17 -0500 Subject: [PATCH 05/13] Checkout before MATLAB tests --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f4aad0..0894881 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,6 +50,8 @@ jobs: matlab-version: [R2021b, R2022a, R2022b, latest] os: [windows-latest, ubuntu-latest, macos-13] steps: + - name: Checkout + uses: actions/checkout@v4 - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2.2.0 with: From c89de9ee707e0c2b10492000ace3c88d1a6a46ec Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 11:09:44 -0500 Subject: [PATCH 06/13] Resolve test failures --- matlab/+matlabls/+internal/computeCodeData.p | Bin 3355 -> 3392 bytes .../handlers/formatting/tFormatCode.m | 30 ++++++++++++++++++ .../handlers/linting/tGetSuppressionEdits.m | 29 +++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/matlab/+matlabls/+internal/computeCodeData.p b/matlab/+matlabls/+internal/computeCodeData.p index 5eb7b413ab411bc59f06a6b5d9fd25f514071f05..1b1e94ba1b8d12510309ef8bb4c07cd0fcf6b2a7 100644 GIT binary patch literal 3392 zcmV-G4ZresFflGLFm^C7E-)|v2|yh1I=`_101J))01Y4j02&q$4a{mTRn_AuY+a%7 zqd&ay(i5y|THm2aL<2s_?|5+MBkz7#)^$nIRJRZL;O;_wI{na}@A8lY1WAe0-Luw* zJ#*ulL!bwa87wu+zFp1`;n4M03Y;%ajM)`BGY_$0-)0-ly_%1FKtakC?VvG5m`3)QXFAvzBu%}A-CEczNZyS%K zp~BROlgv#i!7@h6W?Lka;xaIo*W=Pn`W7`N^W-6#g7x@+XmPa7V+qLCJRJTX@&Rv2 z0y@{zSU0nXPD>>U5qKS>hR!2c+%gQu|9i^WpUqYn$_GuifTA(eI#ITcsL@3xJqcG3 z1VeTi`N$%aptbc7FQYbQjx0-sB_{ToO{|sCRyybbq*Lm?G~?*KkgDMAUwVj&$P7%QT~RnX3xTP%_^B!U zb)QhetVrM!Mw9m8;=iS*JtOf)UKiCY3+F=OVWKUA1kS@(uJb8!Rv)MNH7&_+BS3eD zLi&JolKvS8*BM1|tQmKv!!;klO`thKpg1Xycz?ZAyVmh%ZJa6VChI`-@`!x7sMrJLsdJw-c(3m&|LqnK|69)gJdlKXzWOtcJqiJ$3 zs3VGo@L^IbD+eXCtt@s6!`_l(i4x>u4-(c{sFGh+aZ~A}jmnalm=JS2IF^A=9^!F< zUrX}Nmq8K>t&!3qGA~6?fQ7@!*m|t3`T~=mozpH^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mF1^GvEClW;+1aP!9HVMn zsO3CK1hUG!lxm669s%H42ML!89=w^?dQcQ?q4)|ZBdB9m1`F!j|0aZ5-)meCH&Bf! z4?Ik`#{ORX(zNpm>@{=zIv)&WnP+iod~QU_C;(+K!6;#n78%L?Abg3yvy{QmVayuo zBsRbx31fzjrkBFUUhmOCi39PAcqUft6lxl!9sdOE(9jv>pE|iEh}!cIV*WlnENy!5 zNa{e#aXBf3;9+;q@dmBh`uGJV1%yAWXpOg`_A&pU#|=DKThwb|$1D6S;V z`Q?I(4gM__K*e0>XNh$=d>D>#Z^PosfI03jOx&eB;6ymT!(9!i3cJBZg?`?raV5+~ z)df?q73Yn1n;!3uU|YAlMKflKEaFkZdc97BEjmRsy`)K?sxQjQn7jbm| zhgd&WF}D}`qpHcrIjyt66XUWx&)I*dBV Date: Fri, 7 Mar 2025 11:24:30 -0500 Subject: [PATCH 07/13] Update assertion --- .../matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m b/tests/matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m index b477f25..8133464 100644 --- a/tests/matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m +++ b/tests/matlab/matlabls/handlers/indexing/tParseInfoFromDocument.m @@ -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)) }; From be462a3b8f7fa09062d5590a48731d32d225e886 Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 11:55:53 -0500 Subject: [PATCH 08/13] Temporarily update test action to run against all supported MATLAB versions --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0894881..3b3982a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,7 +47,7 @@ jobs: strategy: fail-fast: false matrix: - matlab-version: [R2021b, R2022a, R2022b, latest] + matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b, R2024a, latest] os: [windows-latest, ubuntu-latest, macos-13] steps: - name: Checkout From 91f043e78939e69d5e4e26ad65e533d04f853565 Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 14:31:34 -0500 Subject: [PATCH 09/13] Leverage `testCase.assumeTrue` to skip tests in certain environments --- .github/workflows/test.yml | 2 + .../handlers/folding/tGetFoldingRanges.m | 7 ++++ .../handlers/formatting/tFormatCode.m | 40 +++++-------------- .../handlers/linting/tGetSuppressionEdits.m | 36 ++++------------- 4 files changed, 26 insertions(+), 59 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b3982a..64bef4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,6 +42,8 @@ jobs: run: npm test matlab-test: + env: + MATLAB_TEST_ENVIRONMENT: 1 name: ${{ matrix.matlab-version }}-${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: diff --git a/tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m b/tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m index 301b2ee..8fffa1f 100644 --- a/tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m +++ b/tests/matlab/matlabls/handlers/folding/tGetFoldingRanges.m @@ -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"); diff --git a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m index 14dc90e..2dc0ed2 100644 --- a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m +++ b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m @@ -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('R2025a') && isTestingEnvironment); + + testCase.assumeTrue(... + shouldRun,... + "Document formatting test cannot run prior to 25a in GitHub test environment."); + end + function setup (~) % Add function under test to path addpath("../../../../../matlab"); @@ -15,12 +25,6 @@ function setup (~) % Test correct formatting with spaces when the tab size is 4. % Each indent should be represented by 4 spaces. function testFormatting4WithSpaces (testCase) - if shouldSkipTest() - disp('Skipping test due to environment limitations.'); - testCase.verifyTrue(true); - return; - end - options.insertSpaces = true; options.tabSize = 4; @@ -33,12 +37,6 @@ function testFormatting4WithSpaces (testCase) % Test correct formatting with tabs when the tab size is 4. % Each indent should be represented by 1 tab character. function testFormatting4WithTabs (testCase) - if shouldSkipTest() - disp('Skipping test due to environment limitations.'); - testCase.verifyTrue(true); - return; - end - options.insertSpaces = false; options.tabSize = 4; @@ -51,12 +49,6 @@ function testFormatting4WithTabs (testCase) % Test correct formatting with spaces when the tab size is 6. % Each indent should be represented by 6 spaces. function testFormatting6WithSpaces (testCase) - if shouldSkipTest() - disp('Skipping test due to environment limitations.'); - testCase.verifyTrue(true); - return; - end - options.insertSpaces = true; options.tabSize = 6; @@ -69,12 +61,6 @@ function testFormatting6WithSpaces (testCase) % Test correct formatting with tabs when the tab size is 6. % Each indent should be represented by 1 tab character. function testFormatting6WithTabs (testCase) - if shouldSkipTest() - disp('Skipping test due to environment limitations.'); - testCase.verifyTrue(true); - return; - end - options.insertSpaces = false; options.tabSize = 4; @@ -85,9 +71,3 @@ function testFormatting6WithTabs (testCase) end end end - -function shouldSkip = shouldSkipTest () - % Before 25a, code formatting depends on Java logic, which may not be available - % in the testing environment. - shouldSkip = isMATLABReleaseOlderThan('R2025a') && ~isempty(javachk('swing')); -end diff --git a/tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m b/tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m index d70b763..429268b 100644 --- a/tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m +++ b/tests/matlab/matlabls/handlers/linting/tGetSuppressionEdits.m @@ -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"); @@ -10,12 +17,6 @@ function setup (~) methods (Test) % Test a basic case where a suppression should be placed on the same line function testBasicSuppression (testCase) - if shouldSkipTest() - disp('Skipping test on MATLAB version prior to R2022a.'); - testCase.verifyTrue(true); - return; - end - code = sprintf('if true\n x = 3;\nend'); diagnosticId = 'testId'; diagnosticLine = 2; @@ -30,12 +31,6 @@ function testBasicSuppression (testCase) % Test a basic case where a file-wide suppression should be placed on the same line function testBasicSuppressionInFile (testCase) - if shouldSkipTest() - disp('Skipping test on MATLAB version prior to R2022a.'); - testCase.verifyTrue(true); - return; - end - code = sprintf('if true\n x = 3;\nend'); diagnosticId = 'testId'; diagnosticLine = 2; @@ -50,12 +45,6 @@ function testBasicSuppressionInFile (testCase) % Test that suppression does not have preceding whitespace when there is trailing whitespace on line function testSuppressionWithTrailingSpace (testCase) - if shouldSkipTest() - disp('Skipping test on MATLAB version prior to R2022a.'); - testCase.verifyTrue(true); - return; - end - code = sprintf('if true\n x = 3; \nend'); diagnosticId = 'testId'; diagnosticLine = 2; @@ -70,12 +59,6 @@ function testSuppressionWithTrailingSpace (testCase) % Test a case where a suppression should be placed at the end of a multi-line statement function testSuppressionAfterMultilineStatement (testCase) - if shouldSkipTest() - disp('Skipping test on MATLAB version prior to R2022a.'); - testCase.verifyTrue(true); - return; - end - code = sprintf('if true\n x = 1 + ...\n 2 + ...\n 3;\nend'); diagnosticId = 'testId'; diagnosticLine = 2; @@ -89,8 +72,3 @@ function testSuppressionAfterMultilineStatement (testCase) end end end - -function shouldSkip = shouldSkipTest () - % Required APIs are not available prior to R2022a - shouldSkip = isMATLABReleaseOlderThan('R2022a'); -end From 3909f9f04a0ae26fe1e59425eb851fb9862ebc9b Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 14:42:32 -0500 Subject: [PATCH 10/13] Update tFormatCode `assumeTrue` condition --- tests/matlab/matlabls/handlers/formatting/tFormatCode.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m index 2dc0ed2..330e9cb 100644 --- a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m +++ b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m @@ -8,11 +8,11 @@ function isApplicable (testCase) % Determine if the test should be skipped in the current environment isTestingEnvironment = ~isempty(getenv('MATLAB_TEST_ENVIRONMENT')); - shouldRun = ~(isMATLABReleaseOlderThan('R2025a') && isTestingEnvironment); + shouldRun = ~(isMATLABReleaseOlderThan('R2023b') && isTestingEnvironment); testCase.assumeTrue(... shouldRun,... - "Document formatting test cannot run prior to 25a in GitHub test environment."); + "Document formatting test cannot run prior to 23b in GitHub test environment."); end function setup (~) From 1cbb1a908e857db81bae78c790ba3a83d2f05bfc Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 14:47:00 -0500 Subject: [PATCH 11/13] Update tFormatCode isApplicable check to check Java Swing again --- tests/matlab/matlabls/handlers/formatting/tFormatCode.m | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m index 330e9cb..f4e6d58 100644 --- a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m +++ b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m @@ -9,6 +9,7 @@ function isApplicable (testCase) % Determine if the test should be skipped in the current environment isTestingEnvironment = ~isempty(getenv('MATLAB_TEST_ENVIRONMENT')); shouldRun = ~(isMATLABReleaseOlderThan('R2023b') && isTestingEnvironment); + shouldRun = ~isMATLABReleaseOlderThan('R2025a') || isempty(javachk('swing')); testCase.assumeTrue(... shouldRun,... From 0c6a6eef0cb8a5c99fb4521f34cef30f66aa84ad Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 14:56:32 -0500 Subject: [PATCH 12/13] Return isApplicable check to checking for the testing environment --- tests/matlab/matlabls/handlers/formatting/tFormatCode.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m index f4e6d58..c4640eb 100644 --- a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m +++ b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m @@ -8,8 +8,7 @@ function isApplicable (testCase) % Determine if the test should be skipped in the current environment isTestingEnvironment = ~isempty(getenv('MATLAB_TEST_ENVIRONMENT')); - shouldRun = ~(isMATLABReleaseOlderThan('R2023b') && isTestingEnvironment); - shouldRun = ~isMATLABReleaseOlderThan('R2025a') || isempty(javachk('swing')); + shouldRun = ~(isMATLABReleaseOlderThan('R2024b') && isTestingEnvironment); testCase.assumeTrue(... shouldRun,... From 89fa760e81a3032b3f7340e7827d65e081c08e70 Mon Sep 17 00:00:00 2001 From: dlilley Date: Fri, 7 Mar 2025 15:52:58 -0500 Subject: [PATCH 13/13] Fix message text --- tests/matlab/matlabls/handlers/formatting/tFormatCode.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m index c4640eb..7df9ca5 100644 --- a/tests/matlab/matlabls/handlers/formatting/tFormatCode.m +++ b/tests/matlab/matlabls/handlers/formatting/tFormatCode.m @@ -12,7 +12,7 @@ function isApplicable (testCase) testCase.assumeTrue(... shouldRun,... - "Document formatting test cannot run prior to 23b in GitHub test environment."); + "Document formatting test cannot run prior to 24b in GitHub test environment."); end function setup (~)