| 16 | ) |
| 17 | |
| 18 | func TestMain(m *testing.M) { |
| 19 | // The test harness is an external program that also expects to have |
| 20 | // hcldec built as an external program, so we'll build both into |
| 21 | // temporary files in our working directory before running our tests |
| 22 | // here, to ensure that we're always running a build of the latest code. |
| 23 | err := build() |
| 24 | if err != nil { |
| 25 | fmt.Fprintf(os.Stderr, "%s\n", err.Error()) |
| 26 | os.Exit(1) |
| 27 | } |
| 28 | |
| 29 | // Now we can run the tests |
| 30 | os.Exit(m.Run()) |
| 31 | } |
| 32 | |
| 33 | func build() error { |
| 34 | err := goBuild("github.com/hashicorp/hcl/v2/cmd/hcldec", "tmp_hcldec") |