| 1 |
if ~exist('OCTAVE_VERSION', 'builtin') && ~verLessThan('matlab', '23.1') && matlab.internal.parallel.isPCTInstalled |
| 2 |
f = findobj('Tag', 'dynare-figure'); |
| 3 |
delete(f); |
| 4 |
clear; |
| 5 |
|
| 6 |
import matlab.unittest.plugins.CodeCoveragePlugin |
| 7 |
import matlab.unittest.plugins.codecoverage.* ; % in newer MATLAB "import matlab.unittest.plugins.codecoverage.CoverageResult" would be sufficient, but creates lint error in R2020a |
| 8 |
|
| 9 |
source_dir = getenv('source_root'); |
| 10 |
addpath([source_dir filesep 'matlab']); |
| 11 |
|
| 12 |
|
| 13 |
suite = testsuite("tParallel"); |
| 14 |
|
| 15 |
runner = testrunner("textoutput"); |
| 16 |
format = CoverageResult; %available after R2023a |
| 17 |
% This only covers the main MATLAB process, but that should be enough |
| 18 |
p = CodeCoveragePlugin.forFile(fullfile(source_dir,'matlab','estimation','posterior_sampler_core.m'),'Producing',format); % to prevent lint error in older MATLAB, use old name-value syntax |
| 19 |
runner.addPlugin(p) |
| 20 |
|
| 21 |
runner.run(suite); |
| 22 |
|
| 23 |
result = format.Result; |
| 24 |
summary = coverageSummary(result,"statement"); |
| 25 |
assert(summary(1)/summary(2) > 0.7, 'Not enough coverage') |
| 26 |
end |
| 27 |
|
| 28 |
% generateHTMLReport(result) |