[PATCH] D84303: [analyzer][tests] Fix SATest update functionality
Valeriy Savchenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 3 08:21:57 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10851f9db5f7: [analyzer][tests] Fix SATest update functionality (authored by vsavchenko).
Herald added a subscriber: steakhal.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84303/new/
https://reviews.llvm.org/D84303
Files:
clang/utils/analyzer/SATest.py
clang/utils/analyzer/SATestUpdateDiffs.py
Index: clang/utils/analyzer/SATestUpdateDiffs.py
===================================================================
--- clang/utils/analyzer/SATestUpdateDiffs.py
+++ clang/utils/analyzer/SATestUpdateDiffs.py
@@ -15,7 +15,7 @@
Verbose = 0
-def update_reference_results(project: ProjectInfo):
+def update_reference_results(project: ProjectInfo, git: bool = False):
test_info = SATestBuild.TestInfo(project)
tester = SATestBuild.ProjectTester(test_info)
project_dir = tester.get_project_dir()
@@ -27,9 +27,10 @@
created_results_path = tester.get_output_dir()
if not os.path.exists(created_results_path):
- print("New results not found, was SATestBuild.py previously run?",
+ print(f"Skipping project '{project.name}', "
+ f"it doesn't have newer results.",
file=sys.stderr)
- sys.exit(1)
+ return
build_log_path = SATestBuild.get_build_log_path(ref_results_path)
build_log_dir = os.path.dirname(os.path.abspath(build_log_path))
@@ -45,7 +46,8 @@
# Remove reference results: in git, and then again for a good measure
# with rm, as git might not remove things fully if there are empty
# directories involved.
- run_cmd(f"git rm -r -q '{ref_results_path}'")
+ if git:
+ run_cmd(f"git rm -r -q '{ref_results_path}'")
shutil.rmtree(ref_results_path)
# Replace reference results with a freshly computed once.
@@ -60,22 +62,11 @@
# Clean up the generated difference results.
SATestBuild.cleanup_reference_results(ref_results_path)
- run_cmd(f"git add '{ref_results_path}'")
+ if git:
+ run_cmd(f"git add '{ref_results_path}'")
-# TODO: use argparse
-def main(argv):
- if len(argv) == 2 and argv[1] in ("-h", "--help"):
- print("Update static analyzer reference results based "
- "\non the previous run of SATestBuild.py.\n"
- "\nN.B.: Assumes that SATestBuild.py was just run",
- file=sys.stderr)
- sys.exit(1)
-
- project_map = ProjectMap()
- for project in project_map.projects:
- update_reference_results(project)
-
-
-if __name__ == '__main__':
- main(sys.argv)
+if __name__ == "__main__":
+ print("SATestUpdateDiffs.py should not be used on its own.")
+ print("Please use 'SATest.py update' instead")
+ sys.exit(1)
Index: clang/utils/analyzer/SATest.py
===================================================================
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -78,7 +78,7 @@
project_map = ProjectMap()
for project in project_map.projects:
- SATestUpdateDiffs.update_reference_results(project)
+ SATestUpdateDiffs.update_reference_results(project, args.git)
def benchmark(parser, args):
@@ -277,7 +277,8 @@
"update",
help="Update static analyzer reference results based on the previous "
"run of SATest build. Assumes that SATest build was just run.")
- # TODO: add option to decide whether we should use git
+ upd_parser.add_argument("--git", action="store_true",
+ help="Stage updated results using git.")
upd_parser.set_defaults(func=update)
# docker subcommand
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84303.282632.patch
Type: text/x-patch
Size: 3299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200803/dbab7161/attachment.bin>
More information about the cfe-commits
mailing list