github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/tests/testcfg/testcfg.go (about)

     1  package testcfg
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/ncruces/go-sqlite3"
     8  	"github.com/tetratelabs/wazero"
     9  )
    10  
    11  func init() {
    12  	sqlite3.RuntimeConfig = wazero.NewRuntimeConfig().
    13  		WithMemoryCapacityFromMax(true).
    14  		WithMemoryLimitPages(1024)
    15  
    16  	if os.Getenv("CI") != "" {
    17  		path := filepath.Join(os.TempDir(), "wazero")
    18  		if err := os.MkdirAll(path, 0777); err == nil {
    19  			if cache, err := wazero.NewCompilationCacheWithDir(path); err == nil {
    20  				sqlite3.RuntimeConfig.WithCompilationCache(cache)
    21  			}
    22  		}
    23  	}
    24  }