Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
c31984a3
Commit
c31984a3
authored
2 years ago
by
Federico Felici
Browse files
Options
Downloads
Patches
Plain Diff
start adding test suite
parent
5580b78d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+42
-0
42 additions, 0 deletions
.gitlab-ci.yml
run_scdds_core_tests.m
+59
-0
59 additions, 0 deletions
run_scdds_core_tests.m
test_script.sh
+30
-0
30 additions, 0 deletions
test_script.sh
tests_matlab.m
+13
-0
13 additions, 0 deletions
tests_matlab.m
with
144 additions
and
0 deletions
.gitlab-ci.yml
0 → 100644
+
42
−
0
View file @
c31984a3
# Define stages
stages
:
-
test
# MATLABCMD: Command used to launch correct matlab version for tests, builds..
# TESTCASE: Input into matlab test script to choose which tests to run.
# GIT_SUBMODULE_STRATEGY: Way to handle gitlab submodules - Recurse into all submodules
# BUILD_DIR/TEST_DIR: Target directory for builds/tests
# CLEAN: Set 1 to force cleaning of target directories
variables
:
# default values
MATLABCMD
:
"
matlab960"
TESTCASE
:
"
"
GIT_STRATEGY
:
none
GIT_SUBMODULE_STRATEGY
:
none
CLEAN
:
0
TIMEOUT
:
"
2h"
# TESTS
.test-template
:
stage
:
test
tags
:
-
scd
before_script
:
-
hostname && date
-
echo "Testing with $MATLABCMD, $TESTCASE"
-
chmod u+x ./test_script.sh
script
:
# Call test script with timeout to kill it
-
timeout -s 9 $TIMEOUT ./test_script.sh $MATLABCMD $TESTCASE
interruptible
:
true
unit-tests
:
extends
:
.test-template
variables
:
TESTCASE
:
"
unit"
template-tests
:
extends
:
.test-template
variables
:
TESTCASE
:
"
template"
This diff is collapsed.
Click to expand it.
run_scdds_core_tests.m
0 → 100644
+
59
−
0
View file @
c31984a3
function
[
passed
,
results
]
=
run_rtccode_tests
(
test_case
)
% test runner for rtccode
% F. Felici, EPFL federico.felici@epfl.ch
if
nargin
==
0
||
isempty
(
test_case
)
test_case
=
'algos'
;
% default
end
test_case
=
lower
(
test_case
);
%% Import some classes we need
import
matlab
.
unittest
.
selectors
.
HasTag
;
import
matlab
.
unittest
.
constraints
.
ContainsSubstring
;
import
matlab
.
unittest
.
selectors
.
HasName
;
%% initialize paths
rtccode_paths
%% populate suite
switch
lower
(
test_case
)
case
'algos'
fprintf
(
'populating test suite with all SCDalgo tests... \n'
)
suite
=
testsuite
(
'algos'
,
'IncludingSubfolders'
,
true
,
'superclass'
,
'SCDalgo_test'
);
fprintf
(
'done \n'
)
case
'unit'
s
=
HasTag
(
'Unit'
);
suite
=
[
matlab
.
unittest
.
TestSuite
.
fromFolder
(
'core/tests'
,
s
),
...
matlab
.
unittest
.
TestSuite
.
fromFolder
(
fullfile
(
'tbx'
,
'tests'
),
s
),
...
testsuite
(
fullfile
(
'core'
,
'classes'
),
'IncludingSubfolders'
,
true
)];
case
'expcodes'
s
=
HasTag
(
'expcodes'
);
suite
=
matlab
.
unittest
.
TestSuite
.
fromFolder
(
'core/tests'
,
s
);
otherwise
error
(
'unknown test_case %s'
,
test_case
)
end
assert
(
~
isempty
(
suite
),
'empty test suite'
);
%% run it
fprintf
(
'Start test case: %s\n%s\n\n'
,
test_case
,
datestr
(
now
));
results
=
run
(
suite
);
disp
(
table
(
results
));
fprintf
(
'\nTotal test duration: %5.2fs\n'
,
sum
(
table
(
results
)
.
Duration
))
%% Display results
if
all
([
results
.
Passed
])
fprintf
(
'\nPassed all tests\n'
)
passed
=
true
;
elseif
any
([
results
.
Failed
])
fprintf
(
'\nSome tests Failed\n'
)
disp
(
table
(
results
([
results
.
Failed
])))
passed
=
false
;
elseif
any
([
results
.
Incomplete
])
fprintf
(
'\nSome tests Incomplete\n'
)
disp
(
table
(
results
([
results
.
Incomplete
])));
passed
=
true
;
% pass tests even if some were skipped
else
error
(
'something is very wrong - please check'
)
end
This diff is collapsed.
Click to expand it.
test_script.sh
0 → 100755
+
30
−
0
View file @
c31984a3
#!/bin/bash
# testing script for Continuous Integration
# F. Felici federico.felici@epfl.ch
## test type
if
[[
-z
"
$1
"
]]
then
echo
'usage:'
echo
' Run matlab tests: '
echo
' ./test_script.sh $matlabversion $test_to_run'
echo
' will call required matlab and run >>test_matlab($test_to_run)'
echo
' $matlabcommand is the command used to launch the correct matlab version'
echo
' works on SPC lac clusters for now'
exit
1
fi
matlabbin
=
$1
testargument
=
$2
source
rtccode_env.sh
matlabcmd
=
"
$matlabbin
-nodisplay"
matlab_call
=
"tests_matlab('
$testargument
')"
full_cmd
=
"
$matlabcmd
-r
$matlab_call
"
;
echo
$full_cmd
$full_cmd
## execute
CODE
=
$?
echo
"exit with CODE"
$CODE
exit
$CODE
This diff is collapsed.
Click to expand it.
tests_matlab.m
0 → 100644
+
13
−
0
View file @
c31984a3
function
tests_matlab
(
test_case
)
% function to call tests from test_script.sh
try
fprintf
(
'\n Running test file: %s\n'
,
mfilename
(
'fullpath'
));
fprintf
(
' Time: %s\n'
,
datestr
(
now
));
passed
=
run_scdds_core_tests
(
test_case
);
% add a call to your test script here, with optional test_case input
exit_code
=
int32
(
~
passed
);
% convert to bash shell convention
catch
ME
disp
(
getReport
(
ME
))
exit_code
=
1
;
end
exit
(
exit_code
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment