Skip to content

Commit

Permalink
Fix #781 issue「googletest でテストに失敗しても ビルド結果が失敗にならない」 (#784)
Browse files Browse the repository at this point in the history
パイプで連結した複数のコマンドの終了コードは、最後のコマンドのもので代表されます。フィルタでテストの成功・失敗を判断しエラーレベルをセットします。

1. 失敗の条件1 失敗したテストがある
2. 失敗の条件2 パスしたテスト数の報告(※0件の場合もある)がない。(テストのビルド・実行に失敗している可能性が高い)
3. 成功の条件 失敗していないこと
  • Loading branch information
ds14050 authored Feb 5, 2019
1 parent f001bb3 commit 083f208
Showing 1 changed file with 32 additions and 25 deletions.
57 changes: 32 additions & 25 deletions tests/test_result_filter_tell_AppVeyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,46 @@ if errorlevel 1 (
set AppVeyor=
)

::: Test result
set PASSED=
set FAILED=

set fileName=
set testName=
set testMsg=
::: for each line read from stdin.
for /F "usebackq delims=" %%L in (`FINDSTR /B "^"`) do (
echo %%L

if not "%AppVeyor%" == "" (
for /F "tokens=1,2,3,5 delims=[]() " %%A in ("%%L") do (
if "%%A" == "----------" (
if not "%%D" == "" (
set fileName=%%D
)
) else if "%%A" == "RUN" (
set testName=%%B
set testMsg=
) else if "%%A" == "OK" (
if not "!testName!,!fileName!" == "," (
rem `start` does not wait for `%AppVeyor%` to return, so the main loop goes immediately.
start "" "%AppVeyor%" AddTest !testName! -Framework xUnit -FileName !fileName! -Outcome Passed -Duration %%C -StdOut "!testMsg!"
)
) else if "%%A" == "FAILED" (
if not "!testName!,!fileName!" == "," (
rem `start` does not wait for `%AppVeyor%` to return, so the main loop goes immediately.
start "" "%AppVeyor%" AddTest !testName! -Framework xUnit -FileName !fileName! -Outcome Failed -Duration %%C -ErrorMessage "!testMsg!"
)
) else if "%%A" == "PASSED" (
rem
) else if "%%A" == "==========" (
rem
) else (
set testMsg=!testMsg!%%L!NL!
for /F "tokens=1,2,3,5 delims=[]() " %%A in ("%%L") do (
if "%%A" == "----------" (
if not "%%D" == "" (
set fileName=%%D
)
) else if "%%A" == "RUN" (
set testName=%%B
set testMsg=
) else if "%%A" == "OK" (
if not "!testName!,!fileName!" == "," (
rem `start` does not wait for `%AppVeyor%` to return, so the main loop goes immediately.
if defined AppVeyor start "" "%AppVeyor%" AddTest !testName! -Framework xUnit -FileName !fileName! -Outcome Passed -Duration %%C -StdOut "!testMsg!"
)
) else if "%%A" == "FAILED" (
if not "!testName!,!fileName!" == "," (
rem `start` does not wait for `%AppVeyor%` to return, so the main loop goes immediately.
if defined AppVeyor start "" "%AppVeyor%" AddTest !testName! -Framework xUnit -FileName !fileName! -Outcome Failed -Duration %%C -ErrorMessage "!testMsg!"
)
set FAILED=FAILED
) else if "%%A" == "PASSED" (
set PASSED=PASSED
) else if "%%A" == "==========" (
rem
) else (
set testMsg=!testMsg!%%L!NL!
)
)
)

if defined FAILED exit /b 1
if not defined PASSED exit /b 1
exit /b 0

0 comments on commit 083f208

Please sign in to comment.