github.com/hashicorp/terraform-plugin-sdk@v1.17.2/acctest/helper.go (about)

     1  package acctest
     2  
     3  import (
     4  	"log"
     5  	"os"
     6  
     7  	"github.com/hashicorp/terraform-plugin-sdk/plugin"
     8  	tftest "github.com/hashicorp/terraform-plugin-test/v2"
     9  )
    10  
    11  var TestHelper *tftest.Helper
    12  
    13  func UseBinaryDriver(name string, providerFunc plugin.ProviderFunc) {
    14  	log.Println("[DEBUG] not using binary driver name, it's no longer needed")
    15  	sourceDir, err := os.Getwd()
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	if tftest.RunningAsPlugin() {
    21  		plugin.Serve(&plugin.ServeOpts{
    22  			ProviderFunc: providerFunc,
    23  		})
    24  		os.Exit(0)
    25  	} else {
    26  		TestHelper = tftest.AutoInitProviderHelper(sourceDir)
    27  	}
    28  }