-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,78 @@ | ||
## Introduction | ||
|
||
一個產生級數數列的工具 | ||
這是 git bisect 指令的參考範例,相關實作測試流程可以參考一下說明。 | ||
|
||
## Requirement | ||
|
||
1. PHP 7.0 以上 | ||
2. Composer | ||
|
||
## Installation | ||
|
||
Run this command to add this library to your composer.json file: | ||
* Step 1. 安裝 | ||
|
||
```sh | ||
git clone [email protected]:mouson/20170110-demo-bisect.git demo-bisect | ||
cd demo-bisect | ||
composer install --prefer-dist | ||
``` | ||
|
||
* Step 2. 執行第一次測試,應發生測試錯誤 | ||
|
||
```sh | ||
./vendor/bin/phpunit | ||
``` | ||
|
||
## 手動 git bisect 測試 | ||
|
||
* Step 1. 啟用二分法測試,執行後應跳到目前 HEAD 與 v2.0 這個版本間的 commit | ||
|
||
```sh | ||
git bisect start HEAD v2.0 | ||
``` | ||
|
||
* Step 2. 執行 phpunit 出現錯誤,設定目前 commit 為錯誤 | ||
|
||
```sh | ||
./vendor/bin/phpunit | ||
git bisect bad | ||
``` | ||
composer require mouson/sequence-helper | ||
|
||
* Step 3. 執行 phpunit 通過測試,設定目前 commit 為正確 | ||
|
||
```sh | ||
./vendor/bin/phpunit | ||
git bisect good | ||
``` | ||
|
||
* Step 4. 執行 phpunit 出現錯誤,此為發生問題的 commit,重置回到 master HEAD | ||
|
||
```sh | ||
git bisect reset | ||
``` | ||
|
||
> ps. 可以透過 tig 指令或 source 查看錯誤的原因並且找到造成錯誤的點 | ||
## 自動動 git bisect 測試 | ||
|
||
* Step 1. 啟用二分法測試 | ||
```sh | ||
git bisect start HEAD v2.0 | ||
``` | ||
|
||
## Quick Start Guide | ||
* Step 2. 執行自動化測試,並找到錯誤的 commit | ||
|
||
```=php | ||
use Mouson\Helpers\SequenceHelper; | ||
```sh | ||
git bisect run ./vendor/bin/phpunit | ||
``` | ||
|
||
* Step 3. 執行 phpunit 出現錯誤,此為發生問題的 commit,重置回到 master HEAD | ||
|
||
$helper = SequenceHelper::make('Fibonacci'); | ||
```sh | ||
git bisect reset | ||
``` | ||
|
||
$value = 30; | ||
$result = sprintf( | ||
"%s Sequence %d is %d", | ||
$helper->getSequenceName(), | ||
$value, | ||
$helper->calculate($value) | ||
); | ||
## 相關參考文件: | ||
|
||
echo $result . PHP_EOL; // Fibonacci Sequence 30 is 832040 | ||
1. [Git \- 使用 Git 做 Debug](https://git-scm.com/book/zh-tw/v1/Git-%E5%B7%A5%E5%85%B7-%E4%BD%BF%E7%94%A8-Git-%E5%81%9A-Debug) | ||
|
||
``` |