diff --git a/tests/data/test_llvm_coverage_report.py b/tests/data/test_llvm_coverage_report.py index 0e4ec580e..9c88573b3 100644 --- a/tests/data/test_llvm_coverage_report.py +++ b/tests/data/test_llvm_coverage_report.py @@ -4,6 +4,7 @@ from collections import defaultdict from pathlib import Path from tempfile import TemporaryDirectory +from unittest.mock import patch from plumbum import colors, local @@ -407,8 +408,9 @@ def test_cov_show(self): ).replace("\x1b[41m\x1b[0m", "") self.assertEqual(cov_show_slow_color_txt, output) - @unittest.skipIf( - not module_exists("vara_feature"), "vara_feature module not installed" + @patch( + "varats.data.reports.llvm_coverage_report.CoverageReport._extract_feature_option_mapping", + lambda self, xml: None ) @run_in_test_environment( UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES diff --git a/tests/plots/test_llvm_coverage_plot.py b/tests/plots/test_llvm_coverage_plot.py index 1a2a43d64..3ebf92762 100644 --- a/tests/plots/test_llvm_coverage_plot.py +++ b/tests/plots/test_llvm_coverage_plot.py @@ -1,6 +1,6 @@ import typing as tp import unittest -from unittest.mock import create_autospec +from unittest.mock import create_autospec, patch from tests.helper_utils import run_in_test_environment, UnitTestFixtures from varats.data.reports.llvm_coverage_report import ( @@ -290,9 +290,6 @@ def confusion_matrix( self.assertEqual(confusion_matrix(region, 1.0).TN, 1) self.assertEqual(confusion_matrix(region, 0.0).TN, 1) - @unittest.skipIf( - not module_exists("vara_feature"), "vara_feature module not installed" - ) @run_in_test_environment( UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES ) @@ -303,9 +300,13 @@ def test_feature_report_interactions(self): "FeaturePerfCSCollection", commit_hash.to_short_commit_hash() ) as base_dir: - reports = setup_reports( - "test_coverage_SimpleFeatureInteraction", base_dir - ) + with patch( + "varats.data.reports.llvm_coverage_report.CoverageReport._extract_feature_option_mapping", + lambda self, xml: None + ): + reports = setup_reports( + "test_coverage_SimpleFeatureInteraction", base_dir + ) report = reports.feature_report() code_region = report.tree["src/SimpleFeatureInteraction/SFImain.cpp" @@ -340,9 +341,6 @@ def test_feature_report_interactions(self): pass self.assertIn(region.coverage_features(), ["", "+True"]) - @unittest.skipIf( - not module_exists("vara_feature"), "vara_feature module not installed" - ) @run_in_test_environment( UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES ) @@ -522,9 +520,6 @@ def test_line_feature_plot(self): ) ) - @unittest.skipIf( - not module_exists("vara_feature"), "vara_feature module not installed" - ) @run_in_test_environment( UnitTestFixtures.PAPER_CONFIGS, UnitTestFixtures.RESULT_FILES ) @@ -534,10 +529,20 @@ def test_confusion_matrices(self): with RepositoryAtCommit( "FeaturePerfCSCollection", commit_hash.to_short_commit_hash() ) as base_dir: - - reports = setup_reports( - "test_coverage_SimpleFeatureInteraction", base_dir - ) + with patch( + "varats.data.reports.llvm_coverage_report.CoverageReport._extract_feature_option_mapping", + lambda self, xml: self.__setattr__( + "featue_option_mapping", { + "root": "", + "Compression": "--compress", + "Encryption": "--enc", + "Slow": "--slow" + } + ) + ): + reports = setup_reports( + "test_coverage_SimpleFeatureInteraction", base_dir + ) feature_option_mapping = reports.feature_option_mapping() result_1 = reports.confusion_matrices( feature_option_mapping, threshold=1.0 diff --git a/varats/varats/data/reports/llvm_coverage_report.py b/varats/varats/data/reports/llvm_coverage_report.py index 45f97d154..75801687c 100644 --- a/varats/varats/data/reports/llvm_coverage_report.py +++ b/varats/varats/data/reports/llvm_coverage_report.py @@ -504,7 +504,9 @@ def __contains__(self, element: CodeRegion) -> bool: class FilenameRegionMapping(tp.Dict[str, CodeRegion]): """Mapping from function names to CodeRegion objects.""" - def __init__(self, *args, base_dir: tp.Optional[Path] = None, **kwargs): + def __init__( + self, *args, base_dir: tp.Optional[Path] = None, **kwargs + ) -> None: self.base_dir = base_dir super().__init__(*args, **kwargs)