Documentation
¶
Index ¶
- func CopyTree(src string, dst string) error
- func PinLocalReplace(dir string, repoRoot string) error
- func RepoRoot() string
- func RequireTreeMatches(t testing.TB, wantDir string, gotDir string)
- func RunCmd(dir string, name string, args ...string) (string, error)
- func ServicePackageImportNames(t testing.TB, dir, genpkg string) []string
- func ServicePackageShadowNames(t testing.TB, dir, genpkg, marker string) []string
- type ModuleBatch
- type ModuleCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PinLocalReplace ¶
PinLocalReplace rewrites the copied fixture go.mod to point the github.com/CaliLuke/loom replace directive at repoRoot.
func RepoRoot ¶
func RepoRoot() string
RepoRoot returns the absolute repository root for the current checkout.
func RequireTreeMatches ¶ added in v1.2.1
RequireTreeMatches asserts that gotDir contains exactly the same regular files as wantDir and that each file has identical contents.
func ServicePackageImportNames ¶ added in v1.10.0
ServicePackageImportNames returns sorted external import aliases that share a generated Go file with a service or views import identified by genpkg. It skips service/view declarations themselves, blank/dot imports and imports within the application module (the parent of genpkg). Imports in separate files do not share this collision boundary, even if the files belong to the same package.
The controlled transport fixtures using this helper have no authored external custom types. Only under that assumption do these aliases identify framework imports: rendered syntax cannot establish the provenance of arbitrary external imports. Default names use Loom's import-name convention; explicit aliases are preserved. This is representative fixture coverage, not a template inventory.
func ServicePackageShadowNames ¶ added in v1.10.0
ServicePackageShadowNames returns the identifiers that the generated Go files below dir declare where a service package imported under the same name would not compile, in the packages that import a service or views package, that is a package whose import path is genpkg/<name> or genpkg/<name>/views:
- the package-level declarations, which conflict with the import;
- the receivers, parameters, results and locals in scope where a service or views package is used, which would hide it;
- in the files that do not import a service or views package, the receivers, parameters, results and locals that are the operand of a selector, such as ws in ws.Close(): a generated file keeps an import when a selector of its name remains, so the file would keep the service package import and leave it unused.
It skips the service and views packages themselves. The result is sorted. It omits struct field names, names with upper case letters, which no generated package name has, and every name that contains marker, so that a test design can mark the names it gives to generated code.
Types ¶
type ModuleBatch ¶ added in v1.10.0
type ModuleBatch struct {
// contains filtered or unexported fields
}
ModuleBatch shares dependency resolution, vet and race-test invocations across generated contracts with the same Loom source and dependencies. Each case retains a separate package namespace and test binary.
func NewModuleBatch ¶ added in v1.10.0
func NewModuleBatch(t *testing.T, source, exportDir string) *ModuleBatch
NewModuleBatch creates one temporary module using the already-resolved Loom source. A nonempty exportDir preserves standalone modules at stable case paths for opt-in artifact comparisons; Check then validates each separately.
func (*ModuleBatch) Case ¶ added in v1.10.0
func (b *ModuleBatch) Case(t *testing.T, name, originalModule string) *ModuleCase
Case allocates a unique case directory. Names are relative paths; spaces, hyphens and equals signs are normalized for use in Go import paths. Exported cases retain their original names and module paths for byte comparisons. Add cases sequentially and finish their subtests before calling Check.
func (*ModuleBatch) Check ¶ added in v1.10.0
func (b *ModuleBatch) Check(t *testing.T)
Check tidies, vets and race-tests every generated package and runtime harness. Failed setup cannot turn a partial batch into a passing result. The bounded test timeout applies to each test binary, not compilation of the batch. A -run filter may leave a batch empty; no commands run in that case. Explicit vet runs all analyzers, so the subsequent test does not repeat vet.
type ModuleCase ¶ added in v1.10.0
type ModuleCase struct {
// Dir is the directory where the caller renders generated files.
Dir string
// ModulePath is the import prefix to pass to the generator for this case.
ModulePath string
// contains filtered or unexported fields
}
ModuleCase owns the package namespace and handwritten harness of a case.