-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f717b8e
commit 3269f21
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function run_coverage_tests | ||
% Add MOcov to path | ||
addpath(genpath('/opt/MOcov')); | ||
|
||
% Get the current directory | ||
current_dir = pwd; | ||
|
||
try | ||
% Configure MOcov | ||
cover_method = '-cover'; | ||
covered_dir = current_dir; | ||
report_file = fullfile(current_dir, 'coverage.xml'); | ||
|
||
% Run tests and generate coverage | ||
test_suite = testsuite('tests/test_myfunction.m'); | ||
results = run(test_suite); | ||
|
||
% Check if all tests passed | ||
num_failed = nnz([results.Failed]); | ||
if num_failed > 0 | ||
error('Some tests failed'); | ||
end | ||
|
||
% Generate coverage report | ||
mocov(cover_method, covered_dir, '-cover_xml_file', report_file); | ||
|
||
% Exit with success | ||
exit(0); | ||
catch e | ||
% Display error and exit with failure | ||
disp('Error running tests:'); | ||
disp(getReport(e)); | ||
exit(1); | ||
end | ||
end |