bafa0c5ace
This relaxes our previous spec to include a special form from HCL 1: foo { bar = baz } Although we normally require each argument to be on a line of its own, as a special case we allow a block to be defined with a single nested argument all on one line. Only one nested argument definition is allowed, and a nested block definition like "foo { bar {} }" is also disallowed in order to force the more-readable split of bar {} onto a line of its own. This is a pragmatic addition for broader compatibility with HCL 1-oriented input. This single-line usage is not considered idiomatic HCL 2 and may in future be undone by the formatter, though for now it is left as-is aside from the spacing around the braces. This also changes the behavior of the source code formatter to include spaces on both sides of braces. This mimicks the formatting behavior of HCL 1 for this situation, and (subjectively) reads better even for other one-line braced expressions like object constructors and object for expressions. |
||
---|---|---|
.. | ||
tests | ||
README.md |
HCL Language Test Suite
This directory contains an implementation-agnostic test suite that can be used to verify the correct behavior not only of the HCL implementation in this repository but also of possible other implementations.
The harness for running this suite -- a Go program in this directory -- uses
the hcldec
program as a level of abstraction to avoid depending directly on
the Go implementation. As a result, other HCL implementations must also
include a version of hcldec
in order to run this spec.
The tests defined in this suite each correspond to a detail of the HCL spec. This suite is separate from and not a substitute for direct unit tests of a given implementation that would presumably also exercise that implementation's own programmatic API.
To run the suite, first build the harness using Go:
go install github.com/hashicorp/hcl2/cmd/hclspecsuite
Then run it, passing it the directory containing the test definitions (the
"tests" subdirectory of this directory) and the path to the hcldec
executable
to use.
For example, if working in the root of this repository and using the hcldec
implementation from here:
go install ./cmd/hcldec
hclspecsuite ./specsuite/tests $GOPATH/bin/hcldec
For developers working on the Go implementation of HCL from this repository,
please note that this spec suite is run as part of a normal go test ./...
execution for this whole repository and so does not need to be run separately.