From 56eb97bd67e34103c7a519c40f56d425d003dce0 Mon Sep 17 00:00:00 2001 From: Federico Felici <federico.felici@epfl.ch> Date: Thu, 30 Sep 2021 15:39:25 +0200 Subject: [PATCH] Improve project path definition --- matlab/run_gdat_tests.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/matlab/run_gdat_tests.m b/matlab/run_gdat_tests.m index cd4b51c4..b47c4dea 100644 --- a/matlab/run_gdat_tests.m +++ b/matlab/run_gdat_tests.m @@ -1,4 +1,4 @@ -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 if nargin==0 || isempty(test_case) @@ -30,6 +30,8 @@ end % add path of toolbox to make sure it is in the path tbxpath = fileparts(mfilename('fullpath')); 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 setpathsfile = dir(fullfile(tbxpath,'setpaths_*')); @@ -84,7 +86,7 @@ fprintf('Start test case: %s\n%s\n\n',test_case,datestr(now)); runner = matlab.unittest.TestRunner.withTextOutput; if needXML % 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); p = XMLPlugin.producingJUnitFormat(xmlFile); runner.addPlugin(p) @@ -94,11 +96,11 @@ if needCOV switch lower(test_case) case 'coverage' % 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); otherwise % 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); end p = matlab.unittest.plugins.CodeCoveragePlugin.forFolder(fileparts(mfilename('fullpath')),... -- GitLab