| 1 | package guestos |
| 2 | |
| 3 | import ( |
| 4 | "os/exec" |
| 5 | "path/filepath" |
| 6 | "runtime" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestWindowsStoragePowerShellTransition(t *testing.T) { |
| 11 | command := "pwsh" |
| 12 | if runtime.GOOS == "windows" { |
| 13 | command = "powershell.exe" |
| 14 | } |
| 15 | powershell, err := exec.LookPath(command) |
| 16 | if err != nil { |
| 17 | t.Skip("requires PowerShell for the native storage command contract") |
| 18 | } |
| 19 | source, err := filepath.Abs("windows_storage.ps1") |
| 20 | if err != nil { |
| 21 | t.Fatal(err) |
| 22 | } |
| 23 | test, err := filepath.Abs(filepath.Join("testdata", "windows_storage.ps1")) |
| 24 | if err != nil { |
| 25 | t.Fatal(err) |
| 26 | } |
| 27 | output, err := exec.Command(powershell, "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", test, "-Implementation", source).CombinedOutput() |
| 28 | if err != nil { |
| 29 | t.Fatalf("native storage contract: %v\n%s", err, output) |
| 30 | } |
| 31 | t.Log(string(output)) |
| 32 | } |