From 2308b563f2395730e3ec7d3981bcee2e8b2f9800 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Fri, 19 Jun 2026 06:54:30 -0700 Subject: [PATCH] update mtest installation requirement --- .github/workflows/bat.yml | 9 +++++++-- .../CodeCoverageSummaryPluginService.m | 18 +++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bat.yml b/.github/workflows/bat.yml index 0816983..433808e 100644 --- a/.github/workflows/bat.yml +++ b/.github/workflows/bat.yml @@ -121,12 +121,17 @@ jobs: with: source-folder: sample code-coverage-metric-level: mcdc + - name: Run MATLAB Tests for statement coverage without MATLAB Test # Test Case 2: Statement coverage without MATLAB Test, view is shown + uses: ./ + with: + source-folder: sample + code-coverage-metric-level: statement - name: Perform 'setup-matlab' with MATLAB Test uses: matlab-actions/setup-matlab@v3 with: products: | MATLAB_Test - - name: Run MATLAB Tests with other options # Test Case 2: With MATLAB Test, and other code-coverage options, no view is shown. + - name: Run MATLAB Tests with other options # Test Case 3: With MATLAB Test, and other code-coverage options, no view is shown. uses: ./ with: model-coverage-cobertura: test-results/modelcoverage.xml @@ -142,7 +147,7 @@ jobs: use-parallel: true output-detail: Detailed logging-level: Detailed - - name: Run MATLAB Tests # Test Case 3: With MATLAB Test, and only code-coverage-metric-level option, view is shown. + - name: Run MATLAB Tests # Test Case 4: With MATLAB Test, and only code-coverage-metric-level option, view is shown. uses: ./ with: source-folder: sample diff --git a/plugins/+matlab/+unittest/+internal/+services/+plugins/CodeCoverageSummaryPluginService.m b/plugins/+matlab/+unittest/+internal/+services/+plugins/CodeCoverageSummaryPluginService.m index abf3868..0697ce6 100644 --- a/plugins/+matlab/+unittest/+internal/+services/+plugins/CodeCoverageSummaryPluginService.m +++ b/plugins/+matlab/+unittest/+internal/+services/+plugins/CodeCoverageSummaryPluginService.m @@ -3,18 +3,22 @@ methods function plugins = providePlugins(~, ~) - verInfo = ver; - productNames = string({verInfo.Name}); - productName = 'MATLAB Test'; - isProductInstalled = any(productNames.matches(productName)); hasCoverageHTML = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_HTML')); hasCoverageCobertura = ~isempty(getenv('MW_INPUT_CODE_COVERAGE_COBERTURA')); hasCoverageRequest = hasCoverageHTML || hasCoverageCobertura; + metricLevel = getenv('MW_INPUT_CODE_COVERAGE_METRIC_LEVEL'); + + % MATLAB Test product installation is only required for decision, condition, and mcdc levels + requiresProductInstall = ismember(metricLevel, {'decision', 'condition', 'mcdc'}); + if requiresProductInstall + verInfo = ver; + productNames = string({verInfo.Name}); + isProductInstalled = any(productNames.matches('MATLAB Test')); + else + isProductInstalled = true; + end - % Check if MATLAB Test license is available and MATLAB Test is installed if strcmpi(getenv("MW_INPUT_GENERATE_SUMMARY"), "true") && ~hasCoverageRequest && license('test', 'matlab_test') && isProductInstalled - % Get metric level from environment variable - metricLevel = getenv('MW_INPUT_CODE_COVERAGE_METRIC_LEVEL'); % Create a shared CoverageResult format object format = matlab.unittest.plugins.codecoverage.CoverageResult;