Skip to content

Commit c89de9e

Browse files
committed
Resolve test failures
1 parent 4ab6df0 commit c89de9e

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
37 Bytes
Binary file not shown.

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

+30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ function setup (~)
1515
% Test correct formatting with spaces when the tab size is 4.
1616
% Each indent should be represented by 4 spaces.
1717
function testFormatting4WithSpaces (testCase)
18+
if shouldSkipTest()
19+
disp('Skipping test due to environment limitations.');
20+
testCase.verifyTrue(true);
21+
return;
22+
end
23+
1824
options.insertSpaces = true;
1925
options.tabSize = 4;
2026

@@ -27,6 +33,12 @@ function testFormatting4WithSpaces (testCase)
2733
% Test correct formatting with tabs when the tab size is 4.
2834
% Each indent should be represented by 1 tab character.
2935
function testFormatting4WithTabs (testCase)
36+
if shouldSkipTest()
37+
disp('Skipping test due to environment limitations.');
38+
testCase.verifyTrue(true);
39+
return;
40+
end
41+
3042
options.insertSpaces = false;
3143
options.tabSize = 4;
3244

@@ -39,6 +51,12 @@ function testFormatting4WithTabs (testCase)
3951
% Test correct formatting with spaces when the tab size is 6.
4052
% Each indent should be represented by 6 spaces.
4153
function testFormatting6WithSpaces (testCase)
54+
if shouldSkipTest()
55+
disp('Skipping test due to environment limitations.');
56+
testCase.verifyTrue(true);
57+
return;
58+
end
59+
4260
options.insertSpaces = true;
4361
options.tabSize = 6;
4462

@@ -51,6 +69,12 @@ function testFormatting6WithSpaces (testCase)
5169
% Test correct formatting with tabs when the tab size is 6.
5270
% Each indent should be represented by 1 tab character.
5371
function testFormatting6WithTabs (testCase)
72+
if shouldSkipTest()
73+
disp('Skipping test due to environment limitations.');
74+
testCase.verifyTrue(true);
75+
return;
76+
end
77+
5478
options.insertSpaces = false;
5579
options.tabSize = 4;
5680

@@ -61,3 +85,9 @@ function testFormatting6WithTabs (testCase)
6185
end
6286
end
6387
end
88+
89+
function shouldSkip = shouldSkipTest ()
90+
% Before 25a, code formatting depends on Java logic, which may not be available
91+
% in the testing environment.
92+
shouldSkip = isMATLABReleaseOlderThan('R2025a') && ~isempty(javachk('swing'));
93+
end

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

+29
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ function setup (~)
1010
methods (Test)
1111
% Test a basic case where a suppression should be placed on the same line
1212
function testBasicSuppression (testCase)
13+
if shouldSkipTest()
14+
disp('Skipping test on MATLAB version prior to R2022a.');
15+
testCase.verifyTrue(true);
16+
return;
17+
end
18+
1319
code = sprintf('if true\n x = 3;\nend');
1420
diagnosticId = 'testId';
1521
diagnosticLine = 2;
@@ -24,6 +30,12 @@ function testBasicSuppression (testCase)
2430

2531
% Test a basic case where a file-wide suppression should be placed on the same line
2632
function testBasicSuppressionInFile (testCase)
33+
if shouldSkipTest()
34+
disp('Skipping test on MATLAB version prior to R2022a.');
35+
testCase.verifyTrue(true);
36+
return;
37+
end
38+
2739
code = sprintf('if true\n x = 3;\nend');
2840
diagnosticId = 'testId';
2941
diagnosticLine = 2;
@@ -38,6 +50,12 @@ function testBasicSuppressionInFile (testCase)
3850

3951
% Test that suppression does not have preceding whitespace when there is trailing whitespace on line
4052
function testSuppressionWithTrailingSpace (testCase)
53+
if shouldSkipTest()
54+
disp('Skipping test on MATLAB version prior to R2022a.');
55+
testCase.verifyTrue(true);
56+
return;
57+
end
58+
4159
code = sprintf('if true\n x = 3; \nend');
4260
diagnosticId = 'testId';
4361
diagnosticLine = 2;
@@ -52,6 +70,12 @@ function testSuppressionWithTrailingSpace (testCase)
5270

5371
% Test a case where a suppression should be placed at the end of a multi-line statement
5472
function testSuppressionAfterMultilineStatement (testCase)
73+
if shouldSkipTest()
74+
disp('Skipping test on MATLAB version prior to R2022a.');
75+
testCase.verifyTrue(true);
76+
return;
77+
end
78+
5579
code = sprintf('if true\n x = 1 + ...\n 2 + ...\n 3;\nend');
5680
diagnosticId = 'testId';
5781
diagnosticLine = 2;
@@ -65,3 +89,8 @@ function testSuppressionAfterMultilineStatement (testCase)
6589
end
6690
end
6791
end
92+
93+
function shouldSkip = shouldSkipTest ()
94+
% Required APIs are not available prior to R2022a
95+
shouldSkip = isMATLABReleaseOlderThan('R2022a');
96+
end

0 commit comments

Comments
 (0)