Predicting Patch Correctness Based on the Similarity of Failing Test Cases

Author:

Tian Haoye1ORCID,Li Yinghua1,Pian Weiguo1,Kaboré Abdoul Kader1ORCID,Liu Kui2,Habib Andrew1ORCID,Klein Jacques1,Bissyandé Tegawendé F.1ORCID

Affiliation:

1. University of Luxembourg, Luxembourg

2. Software Engineering Application Technology Lab, Huawei, China

Abstract

How do we know a generated patch is correct? This is a key challenging question that automated program repair (APR) systems struggle to address given the incompleteness of available test suites. Our intuition is that we can triage correct patches by checking whether each generated patch implements code changes (i.e., behavior) that are relevant to the bug it addresses. Such a bug is commonly specified by a failing test case. Towards predicting patch correctness in APR, we propose a novel yet simple hypothesis on how the link between the patch behavior and failing test specifications can be drawn: similar failing test cases should require similar patches . We then propose BATS , an unsupervised learning-based approach to predict patch correctness by checking patch B ehavior A gainst failing T est S pecification. BATS exploits deep representation learning models for code and patches: For a given failing test case, the yielded embedding is used to compute similarity metrics in the search for historical similar test cases to identify the associated applied patches, which are then used as a proxy for assessing the correctness of the APR-generated patches. Experimentally, we first validate our hypothesis by assessing whether ground-truth developer patches cluster together in the same way that their associated failing test cases are clustered. Then, after collecting a large dataset of 1,278 plausible patches (written by developers or generated by 32 APR tools), we use BATS to predict correct patches: BATS achieves AUC between 0.557 to 0.718 and recall between 0.562 and 0.854 in identifying correct patches. Our approach outperforms state-of-the-art techniques for identifying correct patches without the need for large labeled patch datasets—as is the case with machine learning-based approaches. While BATS is constrained by the availability of similar test cases, we show that it can still be complementary to existing approaches: When combined with a recent approach that relies on supervised learning, BATS improves the overall recall in detecting correct patches. We finally show that BATS is complementary to the state-of-the-art PATCH-SIM dynamic approach for identifying correct patches generated by APR tools.

Funder

European Research Council

European Union’s Horizon 2020

National Natural Science Foundation of China

Natural Science Foundation of Jiangsu Province

Open Project Program of the State Key Laboratory of Mathematical Engineering and Advanced Computing

Publisher

Association for Computing Machinery (ACM)

Subject

Software

Reference93 articles.

1. code2seq: Generating sequences from structured representations of code;Alon Uri;arXiv preprint arXiv:1808.01400,2018

2. code2vec: learning distributed representations of code

3. David Arthur and Sergei Vassilvitskii. 2006. k-means++: The Advantages of Careful Seeding. Technical Report. Stanford University.

4. Marcel Boehme. 2014. Automated Regression Testing and Verification of Complex Code Changes. Ph.D. Dissertation. National University of Singapore.

5. Human-In-The-Loop Automatic Program Repair

Cited by 11 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. A Survey of Learning-based Automated Program Repair;ACM Transactions on Software Engineering and Methodology;2023-12-23

2. Poracle: Testing Patches under Preservation Conditions to Combat the Overfitting Problem of Program Repair;ACM Transactions on Software Engineering and Methodology;2023-12-21

3. Variable-based Fault Localization via Enhanced Decision Tree;ACM Transactions on Software Engineering and Methodology;2023-12-21

4. Enhanced evolutionary automated program repair by finer‐granularity ingredients and better search algorithms;Journal of Software: Evolution and Process;2023-10-09

5. PreciseBugCollector: Extensible, Executable and Precise Bug-Fix Collection: Solution for Challenge 8: Automating Precise Data Collection for Code Snippets with Bugs, Fixes, Locations, and Types;2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE);2023-09-11

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3