Documentation ¶
Overview ¶
Package normaliser provides utilities for archiving and transferring plans, corpora, and subjects.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCollision = errors.New("path already mapped by normaliser")
ErrCollision occurs if the normaliser tries to map two files to the same normalised path. Usually, this is an internal error.
Functions ¶
This section is empty.
Types ¶
type Corpus ¶
type Corpus struct { // Mappings contains the merged mapping table across all subjects. Mappings Map // BySubject contains the normalisers for each subject, which, in turn, contain the mappings. BySubject map[string]*Normaliser // contains filtered or unexported fields }
Corpus is a corpus-level normaliser.
type Entry ¶
type Entry struct { // Original is the original path. Original string // Kind is the kind of path to which this mapping belongs. Kind filekind.Kind // Loc is an abstraction of the location of the path to which this mapping belongs. Loc filekind.Loc }
Entry is a record in the normaliser's mappings. This exists mainly to make it possible to use a Normaliser to work out how to copy a plan to another host, but only copy selective subsets of files.
type Map ¶
Map is the type of normalisation mappings.
func (Map) RenamesMatching ¶
RenamesMatching filters this map to only the files matching kind k and location l.
Example ¶
ExampleMap_RenamesMatching is a runnable example for RenamesMatching.
package main import ( "fmt" "path" "github.com/c4-project/c4t/internal/subject/compilation" "github.com/c4-project/c4t/internal/id" "github.com/c4-project/c4t/internal/model/litmus" "github.com/c4-project/c4t/internal/model/recipe" "github.com/c4-project/c4t/internal/model/filekind" "github.com/c4-project/c4t/internal/subject" "github.com/c4-project/c4t/internal/subject/normaliser" "github.com/c4-project/c4t/internal/subject/status" ) func main() { n := normaliser.New("root") l, _ := litmus.New(path.Join("foo", "bar", "baz.litmus")) f, _ := litmus.New(path.Join("barbaz", "baz.1.litmus")) s, _ := subject.New(l, subject.WithFuzz(&subject.Fuzz{Litmus: *f, Trace: path.Join("barbaz", "baz.1.trace")}), subject.WithCompile(id.FromString("clang"), compilation.CompileResult{ Result: compilation.Result{Status: status.Ok}, Files: compilation.CompileFileset{ Bin: path.Join("foobaz", "clang", "a.out"), Log: path.Join("foobaz", "clang", "errors"), }, }, ), subject.WithRecipe(id.FromString("arm"), recipe.Recipe{ Dir: path.Join("burble", "armv8"), Files: []string{"inky.c", "pinky.c"}, }, ), subject.WithRecipe(id.FromString("x86"), recipe.Recipe{ Dir: path.Join("burble", "i386"), Files: []string{"inky.c", "pinky.c"}, }, ), ) _, _ = n.Normalise(*s) for k, v := range n.Mappings.RenamesMatching(filekind.Any, filekind.InRecipe) { fmt.Println(k, "<-", v) } }
Output: root/recipes/arm/inky.c <- burble/armv8/inky.c root/recipes/arm/pinky.c <- burble/armv8/pinky.c root/recipes/x86/inky.c <- burble/i386/inky.c root/recipes/x86/pinky.c <- burble/i386/pinky.c
type Normaliser ¶
type Normaliser struct { // Mappings contains maps from normalised names to original names. // (The mappings are this way around to help us notice collisions.) Mappings Map // contains filtered or unexported fields }
Normaliser contains state necessary to normalise a single subject's paths. This is useful for archiving the subject inside a tarball, or copying it to another host.