@@ -501,9 +501,17 @@ function module.has_powershell()
501501return module .eval (' executable("' .. (iswin ()and ' powershell' or ' pwsh' ).. ' ")' )== 1
502502end
503503
504- function module .set_shell_powershell ()
505- local shell = iswin ()and ' powershell' or ' pwsh'
506- assert (module .has_powershell ())
504+ --- Sets Nvim shell to powershell.
505+ ---
506+ --- @param fake (boolean )If true , a fake will be used if powershell is not
507+ --- found on the system.
508+ --- @return s true if powershell was found on the system , else false.
509+ function module .set_shell_powershell (fake )
510+ local found = module .has_powershell ()
511+ if not fake then
512+ assert (found )
513+ end
514+ local shell = found and (iswin ()and ' powershell' or ' pwsh' )or module .testprg (' pwsh-test' )
507515local set_encoding = ' [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
508516local cmd = set_encoding .. ' Remove-Item -Force' .. table.concat (iswin ()
509517and {' alias:cat' ,' alias:echo' ,' alias:sleep' }
@@ -515,6 +523,7 @@ function module.set_shell_powershell()
515523 let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
516524 let &shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait'
517525]] )
526+ return found
518527end
519528
520529function module .nvim (method , ...)
@@ -774,11 +783,21 @@ function module.get_pathsep()
774783return iswin ()and ' \\ ' or ' /'
775784end
776785
786+ --- Gets the filesystem root dir, namely "/" or "C:/".
777787function module .pathroot ()
778788local pathsep = package.config :sub (1 ,1 )
779789return iswin ()and (module .nvim_dir :sub (1 ,2 ).. pathsep )or ' /'
780790end
781791
792+ --- Gets the full `…/build/bin/{name}` path of a test program produced by
793+ --- `test/functional/fixtures/CMakeLists.txt`.
794+ ---
795+ --- @param name (string )Name of the test program.
796+ function module .testprg (name )
797+ local ext = module .iswin ()and ' .exe' or ' '
798+ return (' %s/%s%s' ):format (module .nvim_dir ,name ,ext )
799+ end
800+
782801-- Returns a valid, platform-independent Nvim listen address.
783802-- Useful for communicating with child instances.
784803function module .new_pipename ()