Skip to content

Commit d2e4a30

Browse files
committed
Improve CI test execution robustness for macOS and Windows
Windows PowerShell improvements: - Change ErrorActionPreference to Continue for better error handling - Use script blocks for reliable output capture (stdout + stderr) - Improve exit code detection (handle null LASTEXITCODE) - Better error detection logic (distinguish Vim errors from test failures) - Remove unnecessary temp file usage - Add PowerShell version and OS info for debugging macOS/Linux bash improvements: - Check if --not-a-term flag is supported before using it - Better timeout command detection and fallback logic - Add platform and Vim path info for debugging - More robust timeout command verification in workflow These changes improve error handling and provide better diagnostics for CI failures on both platforms.
1 parent bf41277 commit d2e4a30

File tree

3 files changed

+59
-25
lines changed

3 files changed

+59
-25
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ jobs:
8989
which vim
9090
vim --version
9191
# Verify timeout is available (from coreutils)
92+
# On macOS, coreutils installs commands with 'g' prefix, but PATH should have both
9293
which timeout || which gtimeout || echo "Warning: timeout command not found"
94+
# Test timeout command
95+
timeout --version || gtimeout --version || echo "Warning: timeout not working"
9396
9497
- name: Run Vader test suite
9598
run: |

scripts/cicd/run_vader_tests_direct.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ cd "${PROJECT_ROOT}"
3535
log_info "Project root: ${PROJECT_ROOT}"
3636
log_info "Python version: $(python3 --version 2>&1 || echo 'not available')"
3737
log_info "Vim version: $(vim --version | head -1 || echo 'not available')"
38+
log_info "Vim path: $(which vim || echo 'not found')"
39+
log_info "Platform: $(uname -s)"
3840

3941
# Check prerequisites
4042
if ! command -v vim &> /dev/null; then
@@ -182,20 +184,30 @@ for test_file in "${TEST_FILES[@]}"; do
182184
# Run Vader test with timeout
183185
# macOS doesn't have timeout by default, so use gtimeout if available, or run without timeout
184186
set +e # Don't exit on error, we'll check exit code
187+
188+
# Check if --not-a-term is supported (some Vim versions don't support it)
189+
VIM_TERM_FLAG=""
190+
if vim --help 2>&1 | grep -q "\-\-not-a-term"; then
191+
VIM_TERM_FLAG="--not-a-term"
192+
fi
193+
194+
# Determine timeout command
195+
TIMEOUT_CMD=""
185196
if command -v timeout &> /dev/null; then
186-
timeout 120 vim \
187-
--not-a-term \
188-
-es \
189-
-i NONE \
190-
-u "${CI_VIMRC}" \
191-
-c "Vader! ${TEST_FILE_ABS}" \
192-
-c "qa!" \
193-
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
194-
EXIT_CODE=$?
197+
TIMEOUT_CMD="timeout 120"
195198
elif command -v gtimeout &> /dev/null; then
196199
# macOS with GNU coreutils installed via Homebrew
197-
gtimeout 120 vim \
198-
--not-a-term \
200+
TIMEOUT_CMD="gtimeout 120"
201+
else
202+
# No timeout available (macOS without GNU coreutils)
203+
log_warn "timeout command not available, running without timeout"
204+
TIMEOUT_CMD=""
205+
fi
206+
207+
# Build vim command
208+
if [ -n "$TIMEOUT_CMD" ]; then
209+
$TIMEOUT_CMD vim \
210+
${VIM_TERM_FLAG} \
199211
-es \
200212
-i NONE \
201213
-u "${CI_VIMRC}" \
@@ -204,11 +216,8 @@ for test_file in "${TEST_FILES[@]}"; do
204216
< /dev/null > "${VIM_OUTPUT_FILE}" 2>&1
205217
EXIT_CODE=$?
206218
else
207-
# No timeout available (macOS without GNU coreutils)
208-
# Run without timeout - tests should complete quickly anyway
209-
log_warn "timeout command not available, running without timeout"
210219
vim \
211-
--not-a-term \
220+
${VIM_TERM_FLAG} \
212221
-es \
213222
-i NONE \
214223
-u "${CI_VIMRC}" \

scripts/cicd/run_vader_tests_windows.ps1

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# PowerShell script for running Vader tests on Windows
22
# This script is designed to run in GitHub Actions CI environment on Windows
33

4-
$ErrorActionPreference = "Stop"
4+
# Set error action preference but allow continue on some errors
5+
$ErrorActionPreference = "Continue"
56

67
# Colors for output
78
function Write-Info {
@@ -31,6 +32,8 @@ $ProjectRoot = Resolve-Path (Join-Path $ScriptDir "..\..")
3132
Set-Location $ProjectRoot
3233

3334
Write-Info "Project root: $ProjectRoot"
35+
Write-Info "PowerShell version: $($PSVersionTable.PSVersion)"
36+
Write-Info "OS: $([System.Environment]::OSVersion.VersionString)"
3437

3538
# Try python3 first, then python, then py
3639
$PythonCmd = $null
@@ -199,9 +202,6 @@ foreach ($TestFile in $TestFiles) {
199202
# Convert Windows path to Unix-style for Vim (Vim on Windows can handle both)
200203
$TestFileUnix = $TestFile -replace '\\', '/'
201204

202-
# Create output file for this test
203-
$VimOutputFile = New-TemporaryFile
204-
205205
# Run Vader test
206206
$VimArgs = @(
207207
"-es",
@@ -213,15 +213,35 @@ foreach ($TestFile in $TestFiles) {
213213

214214
try {
215215
# Capture both stdout and stderr
216-
$Output = & $VimCmd $VimArgs 2>&1 | Out-String
216+
# Use a script block to capture all streams
217+
$Output = & {
218+
& $VimCmd $VimArgs 2>&1
219+
} | Out-String
220+
221+
# Get exit code - PowerShell sets $LASTEXITCODE for native commands
217222
$ExitCode = $LASTEXITCODE
218223

219-
# If LASTEXITCODE is not set, check the actual exit code
224+
# If LASTEXITCODE is not set (PowerShell < 6), try to determine from $?
220225
if ($null -eq $ExitCode) {
221-
if ($Output -match "error|Error|ERROR|failed|Failed|FAILED") {
222-
$ExitCode = 1
223-
} else {
226+
if ($?) {
224227
$ExitCode = 0
228+
} else {
229+
$ExitCode = 1
230+
}
231+
}
232+
233+
# If exit code is 0 but we have errors in output, check more carefully
234+
if ($ExitCode -eq 0) {
235+
# Check if Vim actually ran successfully by looking at output
236+
if ($Output -match "E\d+|error|Error|ERROR") {
237+
# Might be an error, but check if it's a Vader test failure vs Vim error
238+
if ($Output -notmatch "Success/Total:") {
239+
# No success message, likely a Vim error
240+
# But don't change exit code if we see Vader output
241+
if ($Output -notmatch "Vader|vader") {
242+
$ExitCode = 1
243+
}
244+
}
225245
}
226246
}
227247

@@ -269,9 +289,11 @@ foreach ($TestFile in $TestFiles) {
269289
}
270290
} catch {
271291
Write-Error "Exception running test $TestName : $_"
292+
Write-Error "Exception details: $($_.Exception.Message)"
293+
Write-Error "Stack trace: $($_.ScriptStackTrace)"
272294
$FailedTests += $TestName
273295
} finally {
274-
Remove-Item $VimOutputFile -ErrorAction SilentlyContinue
296+
# Cleanup if needed
275297
}
276298
}
277299

0 commit comments

Comments
 (0)