Skip to content

Commit

Permalink
add auto_rerun_test script for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonHX committed Apr 15, 2022
1 parent 4bf287f commit c8449e6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/auto_rerun_test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$STARCOIN_DIR = (get-item $PSScriptRoot).parent.FullName
$TEST_RESULT_FILE="$STARCOIN_DIR/target/debug/test_result.txt"
$TEST_RESULT_FAILED_FILE="$STARCOIN_DIR/target/debug/test_result_failed.txt"
Write-Host "Starcoin root dir: $STARCOIN_DIR"

$env:RUSTFLAGS="-Ccodegen-units=1 -Copt-level=0"
$env:RUSTC_BOOTSTRAP=1
$env:RUST_MIN_STACK=8*1024*1024
$env:RUST_LOG="OFF"
$env:RUST_BACKTRACE=0
cargo xtest --exclude starcoin-move-prover -j 15 -- --test-threads=10 --color never --format pretty | Tee-Object "$TEST_RESULT_FILE"

$failed_tests=Select-String -Pattern 'test .* \.\.\. FAILED' -Path "./target/debug/test_result.txt" -AllMatche
Write-Host "All failed tests are redirected to file: $TEST_RESULT_FAILED_FILE" -ForegroundColor Green
$failed_tests > "$TEST_RESULT_FAILED_FILE"

Write-Host "Retring failed test cases" -ForegroundColor Green
$env:RUST_LOG="DEBUG"
$env:RUST_BACKTRACE="FULL"
$case_status=0
$failed_tests | ForEach-Object {
$test=$_ -split ' '
$test=$test[1]
Write-Host "Rerunning test failed case: $test" -ForegroundColor Red
cargo xtest -j 15 "$test" -- --test-threads=1 --nocapture
if ($LASTEXITCODE -ne 0) {
$case_status=$LASTEXITCODE
Write-Host "Test case $test failed with $case_status" -ForegroundColor Red
}
}
exit $case_status

0 comments on commit c8449e6

Please sign in to comment.