mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
provisioner/local-exec: Make "stop" test actually useful on Windows
The changes in the previous commit confirmed that this test was passing only as a false-positive when running on Windows, because the test was previously only checking that the provisioner was stopped shortly after asking it to stop, but that wasn't accounting for the possibility that it stopped due to an unrelated error. Windows Command Interpreter does not support semicolon as a command separator, so on Windows we need to use an ampersand instead. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
@@ -58,10 +58,17 @@ func TestResourceProvider_stop(t *testing.T) {
|
||||
p := New()
|
||||
schema := p.GetSchema().Provisioner
|
||||
|
||||
command := "sleep 30; sleep 30"
|
||||
if runtime.GOOS == "windows" {
|
||||
// On Windows the local-exec provisioner uses cmd.exe by default,
|
||||
// and that uses "&" as a command separator instead of ";".
|
||||
command = "sleep 30 & sleep 30"
|
||||
}
|
||||
|
||||
c, err := schema.CoerceValue(cty.ObjectVal(map[string]cty.Value{
|
||||
// bash/zsh/ksh will exec a single command in the same process. This
|
||||
// makes certain there's a subprocess in the shell.
|
||||
"command": cty.StringVal("sleep 30; sleep 30"),
|
||||
"command": cty.StringVal(command),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user