diff --git a/terraform/context.go b/terraform/context.go index 5f8731413f..bd9e80aa0d 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -907,13 +907,10 @@ func (c *Context) walk( } func (c *Context) watchStop(walker *ContextGraphWalker, doneCh <-chan struct{}) { - // Get the stop channel. runContext might be nil only during tests. - // If this is called during a proper run operation, this will never - // be nil. - var stopCh <-chan struct{} - if ctx := c.runContext; ctx != nil { - stopCh = ctx.Done() - } + // Get the stop channel. runContext will never be nil since this should + // only be called within the context of an operation started with + // acquireRun + stopCh := c.runContext.Done() // Wait for a stop or completion select { diff --git a/terraform/context_validate_test.go b/terraform/context_validate_test.go index 9e434a7be3..5bf38eb2ce 100644 --- a/terraform/context_validate_test.go +++ b/terraform/context_validate_test.go @@ -906,6 +906,7 @@ func TestContext2Validate_PlanGraphBuilder(t *testing.T) { Targets: c.targets, }).Build(RootModulePath) + defer c.acquireRun("validate-test")() walker, err := c.walk(graph, graph, walkValidate) if err != nil { t.Fatal(err)