@@ -15,8 +15,6 @@ import (
15
15
"github.com/hashicorp/terraform/internal/command/junit"
16
16
"github.com/hashicorp/terraform/internal/command/views"
17
17
"github.com/hashicorp/terraform/internal/configs"
18
- "github.com/hashicorp/terraform/internal/dag"
19
- "github.com/hashicorp/terraform/internal/logging"
20
18
"github.com/hashicorp/terraform/internal/moduletest"
21
19
"github.com/hashicorp/terraform/internal/moduletest/graph"
22
20
"github.com/hashicorp/terraform/internal/terraform"
@@ -61,7 +59,6 @@ type TestSuiteRunner struct {
61
59
Verbose bool
62
60
63
61
Concurrency int
64
- semaphore terraform.Semaphore
65
62
}
66
63
67
64
func (runner * TestSuiteRunner ) Stop () {
@@ -82,7 +79,6 @@ func (runner *TestSuiteRunner) Test() (moduletest.Status, tfdiags.Diagnostics) {
82
79
if runner .Concurrency < 1 {
83
80
runner .Concurrency = 10
84
81
}
85
- runner .semaphore = terraform .NewSemaphore (runner .Concurrency )
86
82
87
83
suite , suiteDiags := runner .collectTests ()
88
84
diags = diags .Append (suiteDiags )
@@ -124,6 +120,7 @@ func (runner *TestSuiteRunner) Test() (moduletest.Status, tfdiags.Diagnostics) {
124
120
Verbose : runner .Verbose ,
125
121
Render : runner .View ,
126
122
UnparsedVariables : currentGlobalVariables ,
123
+ Concurrency : runner .Concurrency ,
127
124
})
128
125
129
126
fileRunner := & TestFileRunner {
@@ -254,7 +251,7 @@ func (runner *TestFileRunner) Test(file *moduletest.File) {
254
251
}
255
252
256
253
// walk and execute the graph
257
- diags = diags .Append (runner . walkGraph ( g ))
254
+ diags = diags .Append (graph . Walk ( g , runner . EvalContext ))
258
255
259
256
// If the graph walk was terminated, we don't want to add the diagnostics.
260
257
// The error the user receives will just be:
@@ -269,52 +266,6 @@ func (runner *TestFileRunner) Test(file *moduletest.File) {
269
266
file .Diagnostics = file .Diagnostics .Append (diags )
270
267
}
271
268
272
- // walkGraph goes through the graph and execute each run it finds.
273
- func (runner * TestFileRunner ) walkGraph (g * terraform.Graph ) tfdiags.Diagnostics {
274
- sem := runner .Suite .semaphore
275
-
276
- // Walk the graph.
277
- walkFn := func (v dag.Vertex ) tfdiags.Diagnostics {
278
- if runner .EvalContext .Cancelled () {
279
- // If the graph walk has been cancelled, the node should just return immediately.
280
- // For now, this means a hard stop has been requested, in this case we don't
281
- // even stop to mark future test runs as having been skipped. They'll
282
- // just show up as pending in the printed summary. We will quickly
283
- // just mark the overall file status has having errored to indicate
284
- // it was interrupted.
285
- return nil
286
- }
287
-
288
- // the walkFn is called asynchronously, and needs to be recovered
289
- // separately in the case of a panic.
290
- defer logging .PanicHandler ()
291
-
292
- log .Printf ("[TRACE] vertex %q: starting visit (%T)" , dag .VertexName (v ), v )
293
-
294
- defer func () {
295
- if r := recover (); r != nil {
296
- // If the walkFn panics, we get confusing logs about how the
297
- // visit was complete. To stop this, we'll catch the panic log
298
- // that the vertex panicked without finishing and re-panic.
299
- log .Printf ("[ERROR] vertex %q panicked" , dag .VertexName (v ))
300
- panic (r ) // re-panic
301
- }
302
- log .Printf ("[TRACE] vertex %q: visit complete" , dag .VertexName (v ))
303
- }()
304
-
305
- // Acquire a lock on the semaphore
306
- sem .Acquire ()
307
- defer sem .Release ()
308
-
309
- if executable , ok := v .(graph.GraphNodeExecutable ); ok {
310
- executable .Execute (runner .EvalContext )
311
- }
312
- return nil
313
- }
314
-
315
- return g .AcyclicGraph .Walk (walkFn )
316
- }
317
-
318
269
func (runner * TestFileRunner ) renderPreWalkDiags (file * moduletest.File ) (walkCancelled bool ) {
319
270
errored := file .Diagnostics .HasErrors ()
320
271
// Some runs may have errored during the graph build, but we didn't fail immediately
0 commit comments