RunInvalidDSL returns the error resulting from running the given DSL. It is used only in tests.
(t *testing.T, dsl func())
| 28 | // RunInvalidDSL returns the error resulting from running the given DSL. |
| 29 | // It is used only in tests. |
| 30 | func RunInvalidDSL(t *testing.T, dsl func()) error { |
| 31 | t.Helper() |
| 32 | ResetDSL(t) |
| 33 | |
| 34 | // run DSL (first pass) |
| 35 | if !eval.Execute(dsl, nil) { |
| 36 | return eval.Context.Errors |
| 37 | } |
| 38 | |
| 39 | // run DSL (second pass) |
| 40 | if err := eval.RunDSL(); err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | // expected an error - didn't get one |
| 45 | t.Fatal("expected a DSL evaluation error - got none") |
| 46 | |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | // CreateTempFile creates a temporary file and writes the given content. |
| 51 | // It is used only for testing. |