Skip to content

Commit c631252

Browse files
rhysdda-x
authored andcommitted
RustTest: specify module name to run exact one test case
1 parent 15a5049 commit c631252

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

autoload/rust.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ function! rust#Test(all, options) abort
485485
return
486486
endif
487487

488+
let mod_name = expand('%:t:r')
489+
if mod_name ==# ''
490+
echohl ErrorMsg
491+
echo 'Cannot extract a module name from file name. Please add ! to command if you want to run all tests'
492+
echohl None
493+
return
494+
endif
495+
488496
let saved = getpos('.')
489497
try
490498
let func_name = s:SearchTestFunctionNameUnderCursor()
@@ -494,10 +502,11 @@ function! rust#Test(all, options) abort
494502
echohl None
495503
return
496504
endif
505+
let spec = mod_name . '::' . func_name
497506
if a:options ==# ''
498-
execute cmd . 'cargo test --manifest-path' manifest func_name
507+
execute cmd . 'cargo test --manifest-path' manifest spec
499508
else
500-
execute cmd . 'cargo test --manifest-path' manifest func_name a:options
509+
execute cmd . 'cargo test --manifest-path' manifest spec a:options
501510
endif
502511
return
503512
finally

0 commit comments

Comments
 (0)