In this paper, we propose an assertion-based approach to capture software evolution, through the notion of commit-relevant specification. A commit-relevant specification summarises the program properties that have changed as a consequence of a commit (understood as a specific software modification), via two sets of assertions, the delta-added assertions, properties that did not hold in the pre-commit version but hold on the post-commit, and the delta-removed assertions, those that were valid in the pre-commit, but no longer hold after the code change. We also present DeltaSpec, an approach that combines test generation and dynamic specification inference to automatically compute commit-relevant specifications from given commits. We evaluate DeltaSpec on two datasets that include a total of 57 commits (63 classes and 797 methods). We show that commit-relevant assertions can precisely describe the semantic deltas of code changes, providing a useful mechanism for validating the behavioural evolution of software. We also show that DeltaSpec can infer 88% of the manually written commit-relevant assertions expressible in the language supported by the tool. Moreover, our experiments demonstrate that DeltaSpec's inferred assertions are effective to detect regression faults. More precisely, we show that commit-relevant assertions can detect, on average, 78.3% of the artificially seeded faults that interact with the code changes. We also show that assertions in the delta are 58.3% more effective in detecting commit-relevant mutants than assertions outside the delta, and that it takes on average 169% fewer assertions when these are commit-relevant, compared to using general valid assertions, to achieve a same commit-relevant mutation score.
翻译:本文提出了一种基于断言的软件演化捕获方法,其核心概念是“提交相关规约”。提交相关规约通过两类断言——新增断言(提交前版本不成立但提交后版本成立的属性)与移除断言(提交前版本成立但代码变更后不再成立的属性)——总结因提交(即特定的软件修改)而改变的程序属性。我们进一步提出了DeltaSpec方法,该方法结合测试生成与动态规约推断技术,能够从给定提交中自动计算提交相关规约。我们在包含57个提交(涉及63个类与797个方法)的两个数据集上评估了DeltaSpec。实验表明,提交相关断言能够精确描述代码变更的语义差异,为验证软件行为演化提供了有效机制。此外,DeltaSpec可推断工具支持语言中88%的人工编写提交相关断言。实验还证明,DeltaSpec推断的断言能有效检测回归故障:提交相关断言平均可检测78.3%与代码变更交互的人工注入故障。同时,与变更无关的断言相比,变更范围内的断言检测与提交相关变异体的效率高出58.3%;相较于使用通用有效断言,达到相同提交相关变异分数时,提交相关断言的所需数量平均减少169%。