@@ -312,7 +312,7 @@ class VagrantTestPlugin implements Plugin<Project> {
312
312
test_args=( "\$ @" )
313
313
fi
314
314
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[@]}"
316
316
"""
317
317
}
318
318
Task createWindowsRunnerScript = project. tasks. create(' createWindowsRunnerScript' , FileContentsTask ) {
@@ -321,13 +321,19 @@ class VagrantTestPlugin implements Plugin<Project> {
321
321
// the use of $args rather than param() here is deliberate because the syntax for array (multivalued) parameters is likely
322
322
// a little trappy for those unfamiliar with powershell
323
323
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
328
336
}
329
- & "${ -> convertPath(project, windowsGradleJdk.toString()) } "/bin/java -cp "\$ Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
330
- exit \$ LASTEXITCODE
331
337
"""
332
338
}
333
339
@@ -610,7 +616,7 @@ class VagrantTestPlugin implements Plugin<Project> {
610
616
// https://github.com/hashicorp/vagrant/blob/9c299a2a357fcf87f356bb9d56e18a037a53d138/plugins/communicators/winrm/communicator.rb#L195-L225
611
617
// https://devops-collective-inc.gitbooks.io/secrets-of-powershell-remoting/content/manuscript/accessing-remote-computers.html
612
618
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 ' ]
614
620
}
615
621
616
622
TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest. path)
@@ -643,7 +649,10 @@ class VagrantTestPlugin implements Plugin<Project> {
643
649
}
644
650
645
651
// 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 ) {
647
653
return " /elasticsearch/" + project. rootDir. toPath(). relativize(Paths . get(path));
648
654
}
655
+ private String convertWindowsPath (Project project , String path ) {
656
+ return " C:\\ elasticsearch\\ " + project. rootDir. toPath(). relativize(Paths . get(path)). toString(). replace(' /' , ' \\ ' );
657
+ }
649
658
}
0 commit comments