@@ -312,7 +312,7 @@ class VagrantTestPlugin implements Plugin<Project> {
312312 test_args=( "\$ @" )
313313 fi
314314
315- "${ -> convertPath (project, linuxGradleJdk.toString()) } "/bin/java -cp "\$ PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\$ {test_args[@]}"
315+ "${ -> convertLinuxPath (project, linuxGradleJdk.toString()) } "/bin/java -cp "\$ PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\$ {test_args[@]}"
316316 """
317317 }
318318 Task createWindowsRunnerScript = project. tasks. create(' createWindowsRunnerScript' , FileContentsTask ) {
@@ -321,13 +321,19 @@ class VagrantTestPlugin implements Plugin<Project> {
321321 // the use of $args rather than param() here is deliberate because the syntax for array (multivalued) parameters is likely
322322 // a little trappy for those unfamiliar with powershell
323323 contents """ \
324- if (\$ args.Count -eq 0) {
325- \$ testArgs = @("${ -> project.extensions.esvagrant.testClass} ")
326- } else {
327- \$ testArgs = \$ args
324+ try {
325+ if (\$ args.Count -eq 0) {
326+ \$ testArgs = @("${ -> project.extensions.esvagrant.testClass} ")
327+ } else {
328+ \$ testArgs = \$ args
329+ }
330+ & "${ -> convertWindowsPath(project, windowsGradleJdk.toString()) } /bin/java" -cp "\$ Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
331+ exit \$ LASTEXITCODE
332+ } catch {
333+ # catch if we have a failure to even run the script at all above, equivalent to set -e, sort of
334+ echo "\$ _.Exception.Message"
335+ exit 1
328336 }
329- & "${ -> convertPath(project, windowsGradleJdk.toString()) } "/bin/java -cp "\$ Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
330- exit \$ LASTEXITCODE
331337 """
332338 }
333339
@@ -610,7 +616,7 @@ class VagrantTestPlugin implements Plugin<Project> {
610616 // https://github.com/hashicorp/vagrant/blob/9c299a2a357fcf87f356bb9d56e18a037a53d138/plugins/communicators/winrm/communicator.rb#L195-L225
611617 // https://devops-collective-inc.gitbooks.io/secrets-of-powershell-remoting/content/manuscript/accessing-remote-computers.html
612618 javaPackagingTest. command = ' winrm'
613- javaPackagingTest. args = [' --elevated' , ' --command' , ' powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"' ]
619+ javaPackagingTest. args = [' --elevated' , ' --command' , ' & "$Env:PACKAGING_TESTS/run-tests.ps1"; exit $LASTEXITCODE ' ]
614620 }
615621
616622 TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest. path)
@@ -643,7 +649,10 @@ class VagrantTestPlugin implements Plugin<Project> {
643649 }
644650
645651 // convert the given path from an elasticsearch repo path to a VM path
646- private String convertPath (Project project , String path ) {
652+ private String convertLinuxPath (Project project , String path ) {
647653 return " /elasticsearch/" + project. rootDir. toPath(). relativize(Paths . get(path));
648654 }
655+ private String convertWindowsPath (Project project , String path ) {
656+ return " C:\\ elasticsearch\\ " + project. rootDir. toPath(). relativize(Paths . get(path)). toString(). replace(' /' , ' \\ ' );
657+ }
649658}
0 commit comments