Commit Graph

10 Commits

Author SHA1 Message Date
Martin Atkins 6c4344623b Unfold the "hcl" directory up into the root
The main HCL package is more visible this way, and so it's easier than
having to pick it out from dozens of other package directories.
2019-09-09 16:08:19 -07:00
Martin Atkins 3327dee567 Change module path to github.com/hashicorp/hcl/v2
This is in preparation for the first v2 release from the main HCL
repository.
2019-09-09 15:46:40 -07:00
Martin Atkins 2934d2f033 cmd/hclspecsuite: Generate correct ranges in diagnostic-diagnostics
We were taking a pointer to a for loop iterator variable and thus
capturing the final iteration value rather than each one separately. By
using the .Ptr() method instead, we force a copy of the range which we
then take a pointer to.
2018-12-14 11:33:28 -08:00
Martin Atkins ef5c50bb09 hcl/spectests: run the spec testsuite as part of "go test"
Although the spec testsuite and associated harness is designed to be
usable by other implementations of HCL not written in Go, it's convenient
to run it as part of our own "go test" test suite here so there isn't
an additional thing to run on each change.

To achieve this, the new package hcl/spectests will build both hcldec and
hclspecsuite from latest source and then run the latter to execute the
test suite, capturing the output and converting it (sloppily) into
testing.T method calls to produce something vaguely reasonable.

Other than the small amount of "parsing" to make it look in the output
like a normal Go test, there's nothing special going on here and so it's
still valid to run the spec suite manually with a build of hcldec from
this codebase, which should produce the same result.
2018-08-12 18:22:10 -07:00
Martin Atkins 74466f4d35 cmd/hclspecsuite: show source snippets for errors in .hcldec files 2018-08-12 10:29:13 -07:00
Martin Atkins a5c0f7fdcc cmd/hclspecsuite: Check for expected diagnostics
When a test file declares one or more expected diagnostics, we check those
instead of checking the result value. The severities and source ranges
must match.

We don't test the error messages themselves because they are not part of
the specification and may vary between implementations or, in future, be
translated into other languages.
2018-08-12 10:08:27 -07:00
Martin Atkins 767fb36174 cmd/hclspecsuite: Check for traversals when requested 2018-08-12 09:31:28 -07:00
Martin Atkins 95b1859585 cmd/hclspecsuite: Decode expected traversals and diagnostics
These are not used by the test harness yet, but they can now be decoded
from a test spec file.
2018-08-11 20:21:32 -07:00
Martin Atkins 48039c0368 cmd/hclspecsuite: basic runner functionality for successful cases
The harness can now run tests that decode successfully and compare the
result with a given value. Further work is required in later commits to
deal with other cases, such as tests that intentionally produce errors.
2018-08-10 08:49:43 -07:00
Martin Atkins 0956c193b7 specsuite: Start of the harness for the specification test suite 2018-08-09 19:29:32 -07:00