Skip to content

Commit bfb104a

Browse files
committed
fix(tests): normalize Windows path handling in Vim 9 CI
Treat win64 and win32unix as Windows in path and job helpers so compile_commands lookups and async command execution behave consistently on GitHub Actions. Normalize NVCC parsed filenames after absolute expansion to keep expected Windows paths stable in handler tests.
1 parent 1fccad5 commit bfb104a

4 files changed

Lines changed: 18 additions & 14 deletions

File tree

ale_linters/cuda/nvcc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
2323
\ 'lnum': str2nr(l:match[2]),
2424
\ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
2525
\ 'text': l:match[5],
26-
\ 'filename': fnamemodify(ale#path#Simplify(l:match[1]), ':p'),
26+
\ 'filename': ale#path#Simplify(fnamemodify(l:match[1], ':p')),
2727
\}
2828

2929
if !empty(l:match[3])

autoload/ale/c.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ call ale#Set('c_parse_makefile', 0)
55
call ale#Set('c_always_make', has('unix') && !has('macunix'))
66
call ale#Set('c_parse_compile_commands', 1)
77

8-
let s:sep = has('win32') ? '\' : '/'
8+
let s:is_windows = has('win32') || has('win64') || has('win32unix')
9+
let s:sep = s:is_windows ? '\' : '/'
910

1011
" Set just so tests can override it.
1112
let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt']
@@ -386,7 +387,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
386387
let l:file_list = get(a:file_lookup, l:buffer_filename, [])
387388

388389
" We may have to look for /foo/bar instead of C:\foo\bar
389-
if empty(l:file_list) && has('win32')
390+
if empty(l:file_list) && s:is_windows
390391
" Try without the drive letter.
391392
let l:no_drive = ale#path#RemoveDriveLetter(l:buffer_filename)
392393

@@ -407,7 +408,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
407408
" Try the absolute path to the directory second.
408409
let l:dir_list = get(a:dir_lookup, l:dir, [])
409410

410-
if empty(l:dir_list) && has('win32')
411+
if empty(l:dir_list) && s:is_windows
411412
let l:no_drive_dir = ale#path#RemoveDriveLetter(l:dir)
412413

413414
let l:dir_list = get(a:dir_lookup, l:no_drive_dir, [])
@@ -441,7 +442,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
441442
let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix
442443
let l:file_list = get(a:file_lookup, l:key, [])
443444

444-
if empty(l:file_list) && has('win32')
445+
if empty(l:file_list) && s:is_windows
445446
let l:file_list = get(
446447
\ a:file_lookup,
447448
\ ale#path#RemoveDriveLetter(l:key),

autoload/ale/job.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
" A setting for wrapping commands.
1212
let g:ale_command_wrapper = get(g:, 'ale_command_wrapper', '')
13+
let s:is_windows = has('win32') || has('win64') || has('win32unix')
1314

1415
if !has_key(s:, 'job_map')
1516
let s:job_map = {}
@@ -199,7 +200,7 @@ function! ale#job#PrepareCommand(buffer, command) abort
199200
return split(l:ale_shell) + split(l:shell_arguments) + [l:command]
200201
endif
201202

202-
if has('win32')
203+
if s:is_windows
203204
return 'cmd /s/c "' . l:command . '"'
204205
endif
205206

autoload/ale/path.vim

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
" Author: w0rp <devw0rp@gmail.com>
22
" Description: Functions for working with paths in the filesystem.
33

4+
let s:is_windows = has('win32') || has('win64') || has('win32unix')
5+
46
" simplify a path, and fix annoying issues with paths on Windows.
57
"
68
" Forward slashes are changed to back slashes so path equality works better
@@ -27,7 +29,7 @@ endfunction
2729
" Simplify a path without a Windows drive letter.
2830
" This function can be used for checking if paths are equal.
2931
function! ale#path#RemoveDriveLetter(path) abort
30-
return has('win32') && a:path[1:2] is# ':\'
32+
return s:is_windows && a:path[1:2] =~# '^:[/\\]$'
3133
\ ? ale#path#Simplify(a:path[2:])
3234
\ : ale#path#Simplify(a:path)
3335
endfunction
@@ -145,7 +147,7 @@ endfunction
145147

146148
" Return 1 if a path is an absolute path.
147149
function! ale#path#IsAbsolute(filename) abort
148-
if has('win32')
150+
if s:is_windows
149151
return a:filename[:0] =~# '[\\/]' || a:filename[0:2] =~? '[A-Z]:[/\\]'
150152
else
151153
return a:filename[:0] is# '/'
@@ -179,7 +181,7 @@ function! ale#path#GetAbsPath(base_directory, filename) abort
179181
return ale#path#Simplify(a:filename)
180182
endif
181183

182-
let l:sep = has('win32') ? '\' : '/'
184+
let l:sep = s:is_windows ? '\' : '/'
183185

184186
return ale#path#Simplify(a:base_directory . l:sep . a:filename)
185187
endfunction
@@ -192,7 +194,7 @@ function! ale#path#Dirname(path) abort
192194
endif
193195

194196
" For /foo/bar/ we need :h:h to get /foo
195-
if a:path[-1:] is# '/' || (has('win32') && a:path[-1:] is# '\')
197+
if a:path[-1:] is# '/' || (s:is_windows && a:path[-1:] is# '\')
196198
return fnamemodify(a:path, ':h:h')
197199
endif
198200

@@ -233,8 +235,8 @@ endfunction
233235

234236
" Given a path, return every component of the path, moving upwards.
235237
function! ale#path#Upwards(path) abort
236-
let l:pattern = has('win32') ? '\v/+|\\+' : '\v/+'
237-
let l:sep = has('win32') ? '\' : '/'
238+
let l:pattern = s:is_windows ? '\v/+|\\+' : '\v/+'
239+
let l:sep = s:is_windows ? '\' : '/'
238240
let l:parts = split(ale#path#Simplify(a:path), l:pattern)
239241
let l:path_list = []
240242

@@ -243,7 +245,7 @@ function! ale#path#Upwards(path) abort
243245
let l:parts = l:parts[:-2]
244246
endwhile
245247

246-
if has('win32') && a:path =~# '^[a-zA-z]:\'
248+
if s:is_windows && a:path =~# '^[a-zA-z]:\'
247249
" Add \ to C: for C:\, etc.
248250
let l:path_list[-1] .= '\'
249251
elseif a:path[0] is# '/'
@@ -283,7 +285,7 @@ function! ale#path#FromFileURI(uri) abort
283285
let l:path = ale#uri#Decode(l:encoded_path)
284286

285287
" If the path is like /C:/foo/bar, it should be C:\foo\bar instead.
286-
if has('win32') && l:path =~# '^/[a-zA-Z][:|]'
288+
if s:is_windows && l:path =~# '^/[a-zA-Z][:|]'
287289
let l:path = substitute(l:path[1:], '/', '\\', 'g')
288290
let l:path = l:path[0] . ':' . l:path[2:]
289291
endif

0 commit comments

Comments
 (0)