Regression test selection reduces the cost of regression testing by executing only those tests affected by a code change. Despite extensive study of RTS in statically typed languages, achieving effective and safe RTS in Python is challenging. Python's dynamic typing makes precise call-graph construction difficult, which can cause call-graph-based RTS to miss affected tests. Python's eager importing mechanism, in contrast, renders file-level dependency analysis overly conservative. This paper presents NameRTS, the first Python RTS approach based on fine-grained dependency analysis. NameRTS models a Python program as a bipartite graph of code element nodes and name nodes, with edges capturing definitions and references. RTS is formulated as a reachability problem on this graph: a test is selected if any modified code element is reachable from the names used in that test. This design avoids call-graph construction, enabling a conservative analysis amenable to safety. To control dependency cascades introduced by coarse name matching, NameRTS applies two pruning strategies that leverage prior test executions and context information to refine name matching. To evaluate NameRTS, we construct the first Python RTS dataset with a ground truth indicating which test files are affected by each commit. We compare NameRTS with the best-performing baseline, BabelRTS, an RTS technique based on coarse file-level dependencies. On this benchmark, NameRTS skips 69.90% of test files on average, outperforming BabelRTS by 146.5%. It also reduces end-to-end testing time by 45.59%, yielding a 107.7% improvement over BabelRTS. In terms of safety, NameRTS selects all affected tests for 99.6% of commits, with only rare misses in exceptional cases. In contrast, BabelRTS is safe for 76.6% of commits. These results demonstrate the effectiveness of NameRTS, paving the way for more efficient regression testing in Python.


翻译:回归测试选择通过仅执行受代码变更影响的测试,降低回归测试成本。尽管静态类型语言中RTS已被广泛研究,但在Python中实现高效且安全的RTS仍具挑战性。Python的动态类型特性导致精确调用图构建困难,这使得基于调用图的RTS可能遗漏受影响的测试。相反,Python的急切导入机制使得基于文件级的依赖分析过于保守。本文提出NameRTS——首个基于细粒度依赖分析的Python RTS方法。NameRTS将Python程序建模为代码元素节点与名称节点构成的二分图,边捕获定义与引用关系。RTS被形式化为该图上的可达性问题:若测试中使用的名称能到达任何被修改的代码元素,则选择该测试。该设计避免了调用图构建,从而通过保守分析保障安全性。为控制粗粒度名称匹配引发的依赖级联效应,NameRTS应用两种剪枝策略,利用历史测试执行信息与上下文信息优化名称匹配。为评估NameRTS,我们构建了首个包含每个提交影响哪些测试文件真实标注的Python RTS数据集。我们将NameRTS与基于粗粒度文件级依赖的RTS技术BabelRTS(当前最优基线)进行对比。在该基准测试中,NameRTS平均跳过69.90%的测试文件,性能超过BabelRTS达146.5%;端到端测试时间减少45.59%,较BabelRTS提升107.7%。安全性方面,NameRTS对99.6%的提交选出了所有受影响的测试,仅在极端情况下出现罕见遗漏,而BabelRTS对76.6%的提交保持安全。这些结果证明了NameRTS的有效性,为Python更高效的回归测试铺平了道路。

0
下载
关闭预览

相关内容

RTS:Real-Time Systems。 Explanation:实时系统。 Publisher:Springer。 SIT:http://dblp.uni-trier.de/db/journals/rts/
【新书】异常检测 Python,562页pdf
专知会员服务
44+阅读 · 2024年12月27日
【新书】《实用规范分析:使用Python优化决策制定》
专知会员服务
31+阅读 · 2024年11月23日
【2022新书】Python DevOps,245页pdf
专知会员服务
91+阅读 · 2022年7月11日
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
Python用法速查网站
Python程序员
17+阅读 · 2018年12月16日
手把手教你用Python库Keras做预测(附代码)
数据派THU
14+阅读 · 2018年5月30日
【干货】Python无监督学习的4大聚类算法
新智元
14+阅读 · 2018年5月26日
福利 | 当Python遇上大数据与机器学习,入门so easy!
Python & 机器学习之项目实践 | 赠书
人工智能头条
15+阅读 · 2017年12月26日
动手写机器学习算法:异常检测 Anomaly Detection
七月在线实验室
11+阅读 · 2017年12月8日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
0+阅读 · 6月8日
Arxiv
0+阅读 · 5月27日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
7+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
5+阅读 · 6月17日
相关资讯
一个牛逼的 Python 调试工具
机器学习算法与Python学习
15+阅读 · 2019年4月30日
Python用法速查网站
Python程序员
17+阅读 · 2018年12月16日
手把手教你用Python库Keras做预测(附代码)
数据派THU
14+阅读 · 2018年5月30日
【干货】Python无监督学习的4大聚类算法
新智元
14+阅读 · 2018年5月26日
福利 | 当Python遇上大数据与机器学习,入门so easy!
Python & 机器学习之项目实践 | 赠书
人工智能头条
15+阅读 · 2017年12月26日
动手写机器学习算法:异常检测 Anomaly Detection
七月在线实验室
11+阅读 · 2017年12月8日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
31+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员