Skip to content

Commit 71856c4

Browse files
authored
Update testing suite (#113)
* remove slprj folder automatically for local tests * update Actions actions versions * remove bdclose call in testMost
1 parent ffeabc6 commit 71856c4

33 files changed

Lines changed: 303 additions & 57 deletions

File tree

.github/workflows/all-tests-reusable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ jobs:
2020
steps:
2121
- run: echo "Triggered by WEC-Sim commit ${{ fromJSON(inputs.client_payload).sha }}"
2222
- name: Check out repository
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v7
2424
with:
2525
lfs: true
2626
ref: ${{ fromJSON(inputs.client_payload).branch }}
2727
- name: Install MATLAB
28-
uses: matlab-actions/setup-matlab@v2
28+
uses: matlab-actions/setup-matlab@v3
2929
with:
3030
release: R2024b
3131
- name: Get test target folder
32-
uses: matlab-actions/run-command@v2
32+
uses: matlab-actions/run-command@v3
3333
with:
3434
command: getTestTargets
3535
- name: Save output

.github/workflows/changed-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ jobs:
2424
if: github.event_name != 'repository_dispatch'
2525
steps:
2626
- name: Check out repository
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@v7
2828
with:
2929
lfs: true
3030
fetch-depth: 0
3131
- name: Generate git diff
32-
uses: GrantBirki/git-diff-action@v2
32+
uses: GrantBirki/git-diff-action@v3
3333
id: git-diff-action
3434
with:
3535
json_diff_file_output: diff.json
3636
file_output_only: "true"
3737
- name: Install MATLAB
38-
uses: matlab-actions/setup-matlab@v2
38+
uses: matlab-actions/setup-matlab@v3
3939
with:
4040
release: R2024b
4141
- name: Get test target folder
42-
uses: matlab-actions/run-command@v2
42+
uses: matlab-actions/run-command@v3
4343
with:
4444
command: getTestTargets("diff.json")
4545
- name: Save output

.github/workflows/run-tests-reusable.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ jobs:
3333
timeout-minutes: 45
3434
steps:
3535
- name: Check out repository
36-
uses: actions/checkout@v4
36+
uses: actions/checkout@v7
3737
with:
3838
lfs: true
3939
ref: ${{ inputs.head_ref }}
4040
repository: ${{ inputs.repository }}
4141
- name: Checkout LFS objects
4242
run: git lfs checkout
4343
- name: Check out WEC-Sim
44-
uses: actions/checkout@v4
44+
uses: actions/checkout@v7
4545
with:
4646
repository: WEC-Sim/WEC-Sim
4747
ref: ${{ inputs.base_ref }}
4848
path: './WEC-Sim'
4949
- name: Check out MoorDyn
5050
if: matrix.folder == 'Mooring' || matrix.folder == 'OWC' || matrix.folder == 'Paraview_Visualization'
51-
uses: actions/checkout@v4
51+
uses: actions/checkout@v7
5252
with:
5353
repository: WEC-Sim/MoorDyn
5454
path: './MoorDyn'
@@ -60,7 +60,7 @@ jobs:
6060
shell: bash
6161
working-directory: './MoorDyn'
6262
- name: Install MATLAB
63-
uses: matlab-actions/setup-matlab@v2
63+
uses: matlab-actions/setup-matlab@v3
6464
with:
6565
products: ${{ matrix.products }}
6666
release: ${{ matrix.release }}
@@ -71,7 +71,7 @@ jobs:
7171
Xvfb :99 &
7272
echo "DISPLAY=:99" >> $GITHUB_ENV
7373
- name: Install WEC-Sim, run tests and generate artifacts
74-
uses: matlab-actions/run-command@v2
74+
uses: matlab-actions/run-command@v3
7575
with:
7676
command: |
7777
addpath(genpath('WEC-Sim/source'));

Body-to-Body_Interactions/TestB2B.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function killPlots (~)
2121
end
2222

2323
methods(TestClassSetup)
24+
function removeProjectFolder(~)
25+
d = dir('**');
26+
d = d([d.isdir]);
27+
d = d(string({d.name})=="slprj");
28+
for i = 1:length(d)
29+
rmdir(fullfile(d(i).folder, d(i).name), 's')
30+
end
31+
end
2432
function captureVisibility(testCase)
2533
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
2634
end

Cable/TestCable.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ function killPlots (~)
2222
end
2323

2424
methods(TestClassSetup)
25-
2625
function captureVisibility(testCase)
2726
testCase.OriginalDefault = get(0, 'DefaultFigureVisible');
2827
end
29-
28+
function removeProjectFolder(~)
29+
d = dir('**');
30+
d = d([d.isdir]);
31+
d = d(string({d.name})=="slprj");
32+
for i = 1:length(d)
33+
rmdir(fullfile(d(i).folder, d(i).name), 's')
34+
end
35+
end
3036
function runBemio(testCase)
3137
cd(testCase.h5Dir);
3238
if isfile(testCase.h5Name)
@@ -40,18 +46,17 @@ function runBemio(testCase)
4046
end
4147

4248
methods(TestClassTeardown)
43-
4449
function checkVisibilityRestored(testCase)
4550
set(0, 'DefaultFigureVisible', testCase.OriginalDefault);
4651
testCase.assertEqual(get(0, 'DefaultFigureVisible'), ...
4752
testCase.OriginalDefault);
4853
end
49-
5054
end
5155

5256
methods(Test)
5357
function testCable(testCase)
5458
wecSim
59+
close_system('MBARI_cable',0)
5560
end
5661
end
5762

Controls/TestControls.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ function killPlots (~)
2424
function captureVisibility(testCase)
2525
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
2626
end
27+
function removeProjectFolder(~)
28+
d = dir('**');
29+
d = d([d.isdir]);
30+
d = d(string({d.name})=="slprj");
31+
for i = 1:length(d)
32+
rmdir(fullfile(d(i).folder, d(i).name), 's')
33+
end
34+
end
2735
function runBemio(testCase)
2836
cd(testCase.h5Dir);
2937
if isfile(testCase.h5Name)
@@ -53,26 +61,32 @@ function checkVisibilityRestored(testCase)
5361
function testPassive(testCase)
5462
cd('Passive (P)')
5563
wecSim
64+
close_system('passive',0)
5665
end
5766
function testReactive(testCase)
5867
cd('Reactive (PI)')
5968
wecSim
69+
close_system('reactive',0)
6070
end
6171
function testLatching(testCase)
6272
cd('Latching')
6373
wecSim
74+
close_system('latchTime',0)
6475
end
6576
function testDeclutching(testCase)
6677
cd('Declutching')
6778
wecSim
79+
close_system('declutch',0)
6880
end
6981
function testMPC(testCase)
7082
cd('MPC')
7183
wecSim
84+
close_system('sphereMPC',0)
7285
end
7386
function testReactiveWithPTO(testCase)
7487
cd('ReactiveWithPTO')
7588
wecSim
89+
close_system('reactiveWithPTO',0)
7690
end
7791
end
7892
end

Desalination/TestDesalination.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ function killPlots (~)
2424
methods(TestClassSetup)
2525
function captureVisibility(testCase)
2626
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
27-
end
27+
end
28+
function removeProjectFolder(~)
29+
d = dir('**');
30+
d = d([d.isdir]);
31+
d = d(string({d.name})=="slprj");
32+
for i = 1:length(d)
33+
rmdir(fullfile(d(i).folder, d(i).name), 's')
34+
end
35+
end
2836
function runBemio(testCase)
2937
% Check for Simscape Fluids
3038
assumeEqual(testCase, ...
@@ -38,7 +46,7 @@ function runBemio(testCase)
3846
end
3947
cd(testCase.testDir)
4048
testCase.hasH5 = true;
41-
end
49+
end
4250
end
4351

4452
methods(TestClassTeardown)
@@ -52,6 +60,7 @@ function checkVisibilityRestored(testCase)
5260
methods(Test)
5361
function testDesalination(testCase)
5462
wecSim
63+
close_system('OSWEC_RO',0)
5564
end
5665
end
5766
end

End_Stops/TestEndStops.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ function killPlots (~)
2323
methods(TestClassSetup)
2424
function captureVisibility(testCase)
2525
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
26-
end
26+
end
27+
function removeProjectFolder(~)
28+
d = dir('**');
29+
d = d([d.isdir]);
30+
d = d(string({d.name})=="slprj");
31+
for i = 1:length(d)
32+
rmdir(fullfile(d(i).folder, d(i).name), 's')
33+
end
34+
end
2735
function runBemio(testCase)
2836
cd(testCase.h5Dir);
2937
if isfile(testCase.h5Name)
@@ -34,7 +42,7 @@ function runBemio(testCase)
3442
cd(testCase.testDir)
3543
end
3644
end
37-
45+
3846
methods(TestClassTeardown)
3947
function checkVisibilityRestored(testCase)
4048
set(0,'DefaultFigureVisible',testCase.OriginalDefault);
@@ -46,6 +54,7 @@ function checkVisibilityRestored(testCase)
4654
methods(Test)
4755
function testEnd_Stops(testCase)
4856
wecSim
57+
close_system('RM3',0)
4958
end
5059
end
5160
end

Free_Decay/TestFreeDecay.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ function killPlots (~)
2323
methods(TestClassSetup)
2424
function captureVisibility(testCase)
2525
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
26-
end
26+
end
27+
function removeProjectFolder(~)
28+
d = dir('**');
29+
d = d([d.isdir]);
30+
d = d(string({d.name})=="slprj");
31+
for i = 1:length(d)
32+
rmdir(fullfile(d(i).folder, d(i).name), 's')
33+
end
34+
end
2735
function runBemio(testCase)
2836
cd(testCase.h5Dir);
2937
if isfile(testCase.h5Name)

Full_Directional_Waves/TestFullDirectionalWaves.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@ function killPlots (~)
2323
methods(TestClassSetup)
2424
function captureVisibility(testCase)
2525
testCase.OriginalDefault = get(0,'DefaultFigureVisible');
26-
end
26+
end
27+
function removeProjectFolder(~)
28+
d = dir('**');
29+
d = d([d.isdir]);
30+
d = d(string({d.name})=="slprj");
31+
for i = 1:length(d)
32+
rmdir(fullfile(d(i).folder, d(i).name), 's')
33+
end
34+
end
2735
function runBemio(testCase)
2836
cd(testCase.h5Dir);
2937
if isfile(testCase.h5Name)
@@ -52,6 +60,7 @@ function checkVisibilityRestored(testCase)
5260
methods(Test)
5361
function testFullDirectionalWaves(testCase)
5462
wecSim
55-
end
63+
close_system('OSWEC',0)
64+
end
5665
end
5766
end

0 commit comments

Comments
 (0)