0

假设我之前为遗留系统设置了一个超级嗖嗖的测试框架。那就是特征 A 早在对特征 A 的测试之前就已经存在特征 B、C 和 D 出现了,而我们没有意识到,在某个时候打破了对特征 A 的测试。

我们想找出是哪些功能做到了这一点。

现在我想运行:

git bisect <bad> <good>
git run ./swish_test_suite.sh

问题是测试功能 A 的代码文件介于<bad><good>. 我试过手动提取代码,然后是各种配置和测试数据中断的路径(脆弱的代码?)。

有没有办法告诉git bisect忽略文件夹?我可以想象有时会出现可怕的错误,但我猜这可能比其他方法更容易。

此处未解决如何在进行 Git bisect 时忽略目录?因为这涵盖了构建文件夹,解决方案是将它们从存储库中删除,但我想保持我的测试提交!

这个带有功能分支的 git bisect / 需要稍后提交来构建也有点不同,因为我没有使用补丁或功能分支(我应该吗?)而且解决方案似乎只是用于手动运行它,而不是git bisect run它!

4

1 回答 1

1

对于这样的情况,编写测试脚本的方式是在每个步骤中添加您需要的内容。该git help bisect手册有一个示例,您可以根据自己的需要进行调整。即,在该示例执行的情况下git merge hotfix,执行任何您需要的操作来获取所需的测试文件。根据具体情况,合并可能不是您想要的,但您可能会从某个地方挑选您的测试,或者只是事先将它们复制到其他目录(在 bisect 操作之前)并将它们复制到cp.

   ·   Automatically bisect with temporary modifications (hot-fix):

           $ cat ~/test.sh
           #!/bin/sh

           # tweak the working tree by merging the hot-fix branch
           # and then attempt a build
           if      git merge --no-commit hot-fix &&
                   make
           then
                   # run project specific test and report its status
                   ~/check_test_case.sh
                   status=$?
           else
                   # tell the caller this is untestable
                   status=125
           fi

           # undo the tweak to allow clean flipping to the next commit
           git reset --hard

           # return control
           exit $status
于 2016-08-03T09:11:58.760 回答