Skip to content

Commit

Permalink
feat: テスト中に1つでも失敗したら全体の終了ステータスを異常終了にしたい
Browse files Browse the repository at this point in the history
  • Loading branch information
xztaityozx committed Dec 1, 2023
1 parent 7de4979 commit 0bd4544
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion test/e2e/test.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Get-ChildItem 0* | ForEach-Object {
$result = Get-ChildItem 0* | ForEach-Object {
$name=$_.Name;
$arguments=(Get-Content "$name/commandline");
$command="Get-Content $name/input | ../../../dist/sel $arguments";
Expand All @@ -7,7 +7,15 @@ Get-ChildItem 0* | ForEach-Object {
Compare-Object (Invoke-Expression "$command") (Get-Content "$name/output");
if ( $? -eq $True ) {
Write-Host "OK"
return 0
} else {
Write-Host "NG"
return 1
}
} | Measure-Object -Sum

if ($result.Sum -eq 0) {
exit 0
} else {
exit 1
}
8 changes: 6 additions & 2 deletions test/e2e/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

set -e

SEL=../../dist/sel
SEL=../../../dist/sel

EXIT_CODE=0

ls -1 | grep -v test.sh | \
while read DIR; do
commandline=$(cat ./$DIR/commandline)
input=$DIR/input
output=$DIR/output
echo -en "test $DIR: $SEL $commandline ... "
cat $input | eval "$SEL $commandline" | diff - $output && echo "OK" || ( echo "NG"; false )
cat "$input" | eval "$SEL $commandline" | diff - "$output" && echo "OK" || ( echo "NG"; false; $EXIT_CODE=1 )
done

exit "$EXIT_CODE"

0 comments on commit 0bd4544

Please sign in to comment.