Skip to content
Snippets Groups Projects
Commit 56eb97bd authored by Federico Felici's avatar Federico Felici Committed by Olivier Sauter
Browse files

Improve project path definition

parent 7d4e8e55
No related branches found
No related tags found
1 merge request!110Add test coverage and update test scripts
function [passed,results] = run_tbx_tests(test_case,coverage_report) function [passed,results] = run_gdat_tests(test_case,coverage_report)
% Test runner for generic toolbox tests % Test runner for generic toolbox tests
if nargin==0 || isempty(test_case) if nargin==0 || isempty(test_case)
...@@ -30,6 +30,8 @@ end ...@@ -30,6 +30,8 @@ end
% add path of toolbox to make sure it is in the path % add path of toolbox to make sure it is in the path
tbxpath = fileparts(mfilename('fullpath')); tbxpath = fileparts(mfilename('fullpath'));
addpath(tbxpath); % add default path addpath(tbxpath); % add default path
projectpath = getenv('CI_PROJECT_DIR');
if isempty(projectpath), projectpath = tbxpath; end
% add additional paths present in a local setpaths_* file % add additional paths present in a local setpaths_* file
setpathsfile = dir(fullfile(tbxpath,'setpaths_*')); setpathsfile = dir(fullfile(tbxpath,'setpaths_*'));
...@@ -84,7 +86,7 @@ fprintf('Start test case: %s\n%s\n\n',test_case,datestr(now)); ...@@ -84,7 +86,7 @@ fprintf('Start test case: %s\n%s\n\n',test_case,datestr(now));
runner = matlab.unittest.TestRunner.withTextOutput; runner = matlab.unittest.TestRunner.withTextOutput;
if needXML if needXML
% Add some JUnit XML file with tests results % Add some JUnit XML file with tests results
xmlFile = fullfile(getenv('CI_PROJECT_DIR'),sprintf('test_%s_%s.xml',test_case,version('-release'))); xmlFile = fullfile(projectpath,sprintf('test_%s_%s.xml',test_case,version('-release')));
fprintf('\tGenerating JUnit XML report at %s\n',xmlFile); fprintf('\tGenerating JUnit XML report at %s\n',xmlFile);
p = XMLPlugin.producingJUnitFormat(xmlFile); p = XMLPlugin.producingJUnitFormat(xmlFile);
runner.addPlugin(p) runner.addPlugin(p)
...@@ -94,11 +96,11 @@ if needCOV ...@@ -94,11 +96,11 @@ if needCOV
switch lower(test_case) switch lower(test_case)
case 'coverage' case 'coverage'
% Produce HTML report % Produce HTML report
reportFolder = sprintf('test_%s_cov',version('-release')); reportFolder = fullfile(projectpath,sprintf('test_%s_cov',version('-release')));
reportFormat = matlab.unittest.plugins.codecoverage.CoverageReport(reportFolder); reportFormat = matlab.unittest.plugins.codecoverage.CoverageReport(reportFolder);
otherwise otherwise
% Produce XML file in Cobertura format (for Gitlab MR viz.) % Produce XML file in Cobertura format (for Gitlab MR viz.)
xmlFile = fullfile(getenv('CI_PROJECT_DIR'),sprintf('test_%s_%s_cov.xml',test_case,version('-release'))); xmlFile = fullfile(projectpath,sprintf('test_%s_%s_cov.xml',test_case,version('-release')));
reportFormat = matlab.unittest.plugins.codecoverage.CoberturaFormat(xmlFile); reportFormat = matlab.unittest.plugins.codecoverage.CoberturaFormat(xmlFile);
end end
p = matlab.unittest.plugins.CodeCoveragePlugin.forFolder(fileparts(mfilename('fullpath')),... p = matlab.unittest.plugins.CodeCoveragePlugin.forFolder(fileparts(mfilename('fullpath')),...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment