- Determine variable types for ranged resources by typechecking an equivalent expression - Detect top-level await in NodeJS and generate an async main - Fix `pulumi.all` generation for NodeJS - Fix a bug in the lowering of relative traversals in Python
30 lines
848 B
Go
30 lines
848 B
Go
package python
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/hcl/v2"
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/hcl2"
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/hcl2/syntax"
|
|
"github.com/pulumi/pulumi/pkg/v2/codegen/internal/test"
|
|
)
|
|
|
|
func parseAndBindProgram(t *testing.T, text, name string, options ...hcl2.BindOption) (*hcl2.Program, hcl.Diagnostics) {
|
|
parser := syntax.NewParser()
|
|
err := parser.ParseFile(strings.NewReader(text), name)
|
|
if err != nil {
|
|
t.Fatalf("could not read %v: %v", name, err)
|
|
}
|
|
if parser.Diagnostics.HasErrors() {
|
|
t.Fatalf("failed to parse files: %v", parser.Diagnostics)
|
|
}
|
|
|
|
options = append(options, hcl2.PluginHost(test.NewHost(testdataPath)))
|
|
|
|
program, diags, err := hcl2.BindProgram(parser.Files, options...)
|
|
if err != nil {
|
|
t.Fatalf("could not bind program: %v", err)
|
|
}
|
|
return program, diags
|
|
}
|