[clang] 38b455e - [analyzer] SATest: Add option to specify projects to test
Valeriy Savchenko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 03:31:29 PDT 2020
Author: Valeriy Savchenko
Date: 2020-06-16T13:30:01+03:00
New Revision: 38b455e91a63cc20c24b19ab4f469f7c6c60db44
URL: https://github.com/llvm/llvm-project/commit/38b455e91a63cc20c24b19ab4f469f7c6c60db44
DIFF: https://github.com/llvm/llvm-project/commit/38b455e91a63cc20c24b19ab4f469f7c6c60db44.diff
LOG: [analyzer] SATest: Add option to specify projects to test
Differential Revision: https://reviews.llvm.org/D81569
Added:
Modified:
clang/utils/analyzer/ProjectMap.py
clang/utils/analyzer/SATest.py
clang/utils/analyzer/SATestBuild.py
Removed:
################################################################################
diff --git a/clang/utils/analyzer/ProjectMap.py b/clang/utils/analyzer/ProjectMap.py
index 62b7e48fde9b..3daa70140562 100644
--- a/clang/utils/analyzer/ProjectMap.py
+++ b/clang/utils/analyzer/ProjectMap.py
@@ -28,6 +28,20 @@ class ProjectInfo(NamedTuple):
commit: str = ""
enabled: bool = True
+ def with_fields(self, **kwargs) -> "ProjectInfo":
+ """
+ Create a copy of this project info with customized fields.
+ NamedTuple is immutable and this is a way to create modified copies.
+
+ info.enabled = True
+ info.mode = 1
+
+ can be done as follows:
+
+ modified = info.with_fields(enbled=True, mode=1)
+ """
+ return ProjectInfo(**{**self._asdict(), **kwargs})
+
class ProjectMap:
"""
diff --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index 4fb7bf749947..f45f593d08ec 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -28,7 +28,29 @@ def add(parser, args):
def build(parser, args):
SATestBuild.VERBOSE = args.verbose
- tester = SATestBuild.RegressionTester(args.jobs, args.override_compiler,
+
+ project_map = ProjectMap()
+ projects = project_map.projects
+
+ if args.projects:
+ projects_arg = args.projects.split(",")
+ available_projects = [project.name
+ for project in projects]
+
+ # validate that given projects are present in the project map file
+ for manual_project in projects_arg:
+ if manual_project not in available_projects:
+ parser.error("Project '{project}' is not found in "
+ "the project map file. Available projects are "
+ "{all}.".format(project=manual_project,
+ all=available_projects))
+
+ projects = [project.with_fields(enabled=project.name in projects_arg)
+ for project in projects]
+
+ tester = SATestBuild.RegressionTester(args.jobs,
+ projects,
+ args.override_compiler,
args.extra_analyzer_config,
args.regenerate,
args.strictness)
@@ -111,6 +133,8 @@ def main():
dest="extra_analyzer_config", type=str,
default="",
help="Arguments passed to to -analyzer-config")
+ build_parser.add_argument("--projects", action="store", default="",
+ help="Comma-separated list of projects to test")
build_parser.add_argument("-v", "--verbose", action="count", default=0)
build_parser.set_defaults(func=build)
diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index d5b0710c8d61..d83ff1e7d009 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -44,7 +44,7 @@
"""
import CmpRuns
import SATestUtils
-from ProjectMap import DownloadType, ProjectInfo, ProjectMap
+from ProjectMap import DownloadType, ProjectInfo
import glob
import logging
@@ -225,10 +225,11 @@ class RegressionTester:
"""
A component aggregating all of the project testing.
"""
- def __init__(self, jobs: int, override_compiler: bool,
- extra_analyzer_config: str, regenerate: bool,
- strictness: bool):
+ def __init__(self, jobs: int, projects: List[ProjectInfo],
+ override_compiler: bool, extra_analyzer_config: str,
+ regenerate: bool, strictness: bool):
self.jobs = jobs
+ self.projects = projects
self.override_compiler = override_compiler
self.extra_analyzer_config = extra_analyzer_config
self.regenerate = regenerate
@@ -237,10 +238,8 @@ def __init__(self, jobs: int, override_compiler: bool,
def test_all(self) -> bool:
projects_to_test: List[TestInfo] = []
- project_map = ProjectMap()
-
# Test the projects.
- for project in project_map.projects:
+ for project in self.projects:
projects_to_test.append(
TestInfo(project,
self.override_compiler,
More information about the cfe-commits
mailing list