From d3726004d22f8e6cab22aec2d96b9ed43d137416 Mon Sep 17 00:00:00 2001 From: ds14050 Date: Mon, 22 Oct 2018 01:20:41 +0900 Subject: [PATCH] Tell AppVeyor test results one-by-one. --- tests/run-tests.bat | 6 ++- tests/test_result_filter_tell_AppVeyor.bat | 50 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/test_result_filter_tell_AppVeyor.bat diff --git a/tests/run-tests.bat b/tests/run-tests.bat index 99ae82ed0a..0dad6934ef 100644 --- a/tests/run-tests.bat +++ b/tests/run-tests.bat @@ -3,6 +3,8 @@ set platform=%1 set configuration=%2 set ERROR_RESULT=0 +set TEST_RESULT_FILTER=%~dp0test_result_filter_tell_AppVeyor.bat + pushd %~dp0 set BUILDDIR=build\%platform% set BINARY_DIR=%BUILDDIR%\bin\%configuration% @@ -12,8 +14,8 @@ for /r %%i in (tests*.exe) do ( @echo %%i --gtest_list_tests %%i --gtest_list_tests || set ERROR_RESULT=1 - @echo %%i - %%i || set ERROR_RESULT=1 + @echo %%i |"%TEST_RESULT_FILTER%" + %%i |"%TEST_RESULT_FILTER%" || set ERROR_RESULT=1 ) popd popd diff --git a/tests/test_result_filter_tell_AppVeyor.bat b/tests/test_result_filter_tell_AppVeyor.bat new file mode 100644 index 0000000000..126be32a04 --- /dev/null +++ b/tests/test_result_filter_tell_AppVeyor.bat @@ -0,0 +1,50 @@ +@echo off +setlocal ENABLEDELAYEDEXPANSION + +set NL=^ + + +:Blank lines above are parts of the NL(New Line) definition. Do not compact them. + +::: About `appveyor` command line program: +::: https://www.appveyor.com/docs/build-worker-api/ +set AppVeyor=appveyor +where /Q "%AppVeyor%" +if errorlevel 1 ( + set AppVeyor= +) + +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!" == "," ( + start "" "%AppVeyor%" AddTest !testName! -Framework xUnit -FileName !fileName! -Outcome Passed -Duration %%C -StdOut "!testMsg!" + ) + ) else if "%%A" == "FAILED" ( + if not "!testName!,!fileName!" == "," ( + 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! + ) + ) + ) +)