@@ -324,9 +324,9 @@ class VagrantTestPlugin implements Plugin<Project> {
324
324
fi
325
325
326
326
if [ -z "\$ SYSTEM_JAVA_HOME" ]; then
327
- export SYSTEM_JAVA_HOME="${ -> convertPath (project, linuxSystemJdk.toString()) } "
327
+ export SYSTEM_JAVA_HOME="${ -> convertLinuxPath (project, linuxSystemJdk.toString()) } "
328
328
fi
329
- "${ -> convertPath (project, linuxGradleJdk.toString()) } "/bin/java -cp "\$ PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\$ {test_args[@]}"
329
+ "${ -> convertLinuxPath (project, linuxGradleJdk.toString()) } "/bin/java -cp "\$ PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\$ {test_args[@]}"
330
330
"""
331
331
}
332
332
Task createWindowsRunnerScript = project. tasks. create(' createWindowsRunnerScript' , FileContentsTask ) {
@@ -335,14 +335,20 @@ class VagrantTestPlugin implements Plugin<Project> {
335
335
// the use of $args rather than param() here is deliberate because the syntax for array (multivalued) parameters is likely
336
336
// a little trappy for those unfamiliar with powershell
337
337
contents """ \
338
- if (\$ args.Count -eq 0) {
339
- \$ testArgs = @("${ -> project.extensions.esvagrant.testClass} ")
340
- } else {
341
- \$ testArgs = \$ args
338
+ try {
339
+ if (\$ args.Count -eq 0) {
340
+ \$ testArgs = @("${ -> project.extensions.esvagrant.testClass} ")
341
+ } else {
342
+ \$ testArgs = \$ args
343
+ }
344
+ \$ Env:SYSTEM_JAVA_HOME = "${ -> convertWindowsPath(project, windowsSystemJdk.toString()) } "
345
+ & "${ -> convertWindowsPath(project, windowsGradleJdk.toString()) } /bin/java" -cp "\$ Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
346
+ exit \$ LASTEXITCODE
347
+ } catch {
348
+ # catch if we have a failure to even run the script at all above, equivalent to set -e, sort of
349
+ echo "\$ _.Exception.Message"
350
+ exit 1
342
351
}
343
- \$ Env:SYSTEM_JAVA_HOME = "${ -> convertPath(project, windowsSystemJdk.toString()) } "
344
- & "${ -> convertPath(project, windowsGradleJdk.toString()) } "/bin/java -cp "\$ Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
345
- exit \$ LASTEXITCODE
346
352
"""
347
353
}
348
354
@@ -578,7 +584,7 @@ class VagrantTestPlugin implements Plugin<Project> {
578
584
579
585
if (LINUX_BOXES . contains(box)) {
580
586
Task batsPackagingTest = project. tasks. create(" vagrant${ boxTask} #batsPackagingTest" , BatsOverVagrantTask ) {
581
- remoteCommand " export SYSTEM_JAVA_HOME=\" ${ -> convertPath (project, linuxSystemJdk.toString())} \" ; " + BATS_TEST_COMMAND
587
+ remoteCommand " export SYSTEM_JAVA_HOME=\" ${ -> convertLinuxPath (project, linuxSystemJdk.toString())} \" ; " + BATS_TEST_COMMAND
582
588
boxName box
583
589
environmentVars vagrantEnvVars
584
590
dependsOn up, setupPackagingTest, linuxSystemJdk
@@ -625,7 +631,7 @@ class VagrantTestPlugin implements Plugin<Project> {
625
631
// https://github.com/hashicorp/vagrant/blob/9c299a2a357fcf87f356bb9d56e18a037a53d138/plugins/communicators/winrm/communicator.rb#L195-L225
626
632
// https://devops-collective-inc.gitbooks.io/secrets-of-powershell-remoting/content/manuscript/accessing-remote-computers.html
627
633
javaPackagingTest. command = ' winrm'
628
- javaPackagingTest. args = [' --elevated' , ' --command' , ' powershell -File "$Env:PACKAGING_TESTS/run-tests.ps1"' ]
634
+ javaPackagingTest. args = [' --elevated' , ' --command' , ' & "$Env:PACKAGING_TESTS/run-tests.ps1"; exit $LASTEXITCODE ' ]
629
635
}
630
636
631
637
TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest. path)
@@ -658,7 +664,10 @@ class VagrantTestPlugin implements Plugin<Project> {
658
664
}
659
665
660
666
// convert the given path from an elasticsearch repo path to a VM path
661
- private String convertPath (Project project , String path ) {
667
+ private String convertLinuxPath (Project project , String path ) {
662
668
return " /elasticsearch/" + project. rootDir. toPath(). relativize(Paths . get(path));
663
669
}
670
+ private String convertWindowsPath (Project project , String path ) {
671
+ return " C:\\ elasticsearch\\ " + project. rootDir. toPath(). relativize(Paths . get(path)). toString(). replace(' /' , ' \\ ' );
672
+ }
664
673
}
0 commit comments