ChangeGuard:通过成对学习引导的执行验证代码变更
ChangeGuard: Validating Code Changes via Pairwise Learning-Guided Execution
AI总结:
针对代码变更行为一致性验证难的问题,提出基于成对学习引导执行的ChangeGuard方法,在多数据集上验证了其检测语义变更的效果优于现有回归测试。
摘要:
代码变更是软件开发流程中不可或缺的组成部分。许多代码变更旨在优化代码而不改变其功能行为,例如重构和性能提升。遗憾的是,验证代码变更是否保持行为一致性并非易事,尤其是当变更发生在复杂项目的深层位置时。本文提出ChangeGuard,这是一种利用学习引导的执行来比较修改后函数运行时行为的方法。该方法依托成对学习引导执行这一全新概念,以及一系列提升现有最先进学习引导执行技术鲁棒性与覆盖率的技术得以实现。我们的评估将ChangeGuard应用于包含224个来自热门Python开源项目的人工标注代码变更的数据集,以及三个通过应用自动化代码转换得到的代码变更数据集。结果显示,该方法识别语义变更类代码变更的精确率为77.1%,召回率为69.5%,且能够检测出自动代码重构工具引入的意外行为变更。相比之下,所分析项目的现有回归测试遗漏了绝大多数语义变更类代码变更,召回率仅为7.6%。我们认为该方法有助于在开发流程早期检测非预期的行为变更,并提升自动化代码转换的质量。
英文摘要:
Code changes are an integral part of the software development process. Many code changes are meant to improve the code without changing its functional behavior, e.g., refactorings and performance improvements. Unfortunately, validating whether a code change preserves the behavior is non-trivial, particularly when the code change is performed deep inside a complex project. This paper presents ChangeGuard, an approach that uses learning-guided execution to compare the runtime behavior of a modified function. The approach is enabled by the novel concept of pairwise learning-guided execution and by a set of techniques that improve the robustness and coverage of the state-of-the-art learning-guided execution technique. Our evaluation applies ChangeGuard to a dataset of 224 manually annotated code changes from popular Python open-source projects and to three datasets of code changes obtained by applying automated code transformations. Our results show that the approach identifies semantics-changing code changes with a precision of 77.1% and a recall of 69.5%, and that it detects unexpected behavioral changes introduced by automatic code refactoring tools. In contrast, the existing regression tests of the analyzed projects miss the vast majority of semantics-changing code changes, with a recall of only 7.6%. We envision our approach being useful for detecting unintended behavioral changes early in the development process and for improving the quality of automated code transformations.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。