func MustLoadConfigForTests(t *testing.T, rootDir string) (*configs.Config, *configload.Loader, func()) {
	t.Helper()
	config, loader, cleanup, diags := LoadConfigForTests(t, rootDir)
	if diags.HasErrors() {
		cleanup()
		t.Fatal(diags.Err())
	}
	return config, loader, cleanup
}
MustLoadConfigForTests is a variant of LoadConfigForTests which calls
t.Fatal (or similar) if there are any errors during loading, and thus
does not return diagnostics at all.

This is useful for concisely writing tests that don't expect errors at
all. For tests that expect errors and need to assert against them, use
LoadConfigForTests instead.
package initwd
import (
	"github.com/hashicorp/terraform/registry"
	"testing"
	"github.com/hashicorp/terraform/configs"
	"github.com/hashicorp/terraform/configs/configload"
	"github.com/hashicorp/terraform/tfdiags"
)
func LoadConfigForTests(t *testing.T, rootDir string) (*configs.Config, *configload.Loader, func(), tfdiags.Diagnostics) {
	t.Helper()
	var diags tfdiags.Diagnostics
	loader, cleanup := configload.NewLoaderForTests(t)
	inst := NewModuleInstaller(loader.ModulesDir(), registry.NewClient(nil, nil))
	_, moreDiags := inst.InstallModules(rootDir, true, ModuleInstallHooksImpl{})
	diags = diags.Append(moreDiags)
	if diags.HasErrors() {
		cleanup()
		t.Fatal(diags.Err())
		return nil, nil, func() {}, diags
	}
	if err := loader.RefreshModules(); err != nil {
		t.Fatalf("failed to refresh modules after installation: %s", err)
	}
	config, hclDiags := loader.LoadConfig(rootDir)
	diags = diags.Append(hclDiags)
	return config, loader, cleanup, diags
}