pathset

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pathset contains the various path-sets for the director. These spill into a separate package on the basis of there being so many of them.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	// SavedPaths contains the save pathset for this machine.
	Saved saver.Pathset
	// ScratchPaths contains the scratch pathset for this machine.
	Scratch Scratch
}

Instance is an instance-specific pathset.

type Pathset

type Pathset struct {
	// DirSaved is the directory into which saved runs get copied.
	DirSaved string

	// DirScratch is the directory that the director uses for ephemeral run data.
	DirScratch string
}

Pathset contains the pre-computed paths used by the director.

func New

func New(root string) *Pathset

New constructs a new pathset from the directory root.

Example

ExampleNew is a runnable example for New.

package main

import (
	"fmt"
	"path/filepath"

	"github.com/c4-project/c4t/internal/director/pathset"
)

func main() {
	p := pathset.New(filepath.FromSlash("tests"))

	fmt.Println(filepath.ToSlash(p.DirScratch))
	fmt.Println(filepath.ToSlash(p.DirSaved))

}
Output:

tests/scratch
tests/saved

func (Pathset) Instance

func (p Pathset) Instance(mid id.ID) *Instance

Instance gets the instance pathset for a machine with ID mid.

Example

ExamplePathset_Instance is a runnable example for Pathset.Instance.

package main

import (
	"fmt"
	"path/filepath"

	"github.com/c4-project/c4t/internal/director/pathset"

	"github.com/c4-project/c4t/internal/id"
)

func main() {
	p := pathset.Pathset{DirSaved: "saved", DirScratch: "scratch"}
	mid := id.FromString("foo.bar.baz")
	mi := p.Instance(mid)

	for _, path := range mi.Scratch.Dirs() {
		fmt.Println(filepath.ToSlash(path))
	}
	for _, path := range mi.Saved.DirList() {
		fmt.Println(filepath.ToSlash(path))
	}

}
Output:

scratch/foo/bar/baz/fuzz
scratch/foo/bar/baz/lift
scratch/foo/bar/baz/run
saved/foo/bar/baz/flagged
saved/foo/bar/baz/compile_fail
saved/foo/bar/baz/compile_timeout
saved/foo/bar/baz/run_fail
saved/foo/bar/baz/run_timeout

func (*Pathset) Prepare

func (p *Pathset) Prepare() error

Prepare prepares this pathset by making its directories.

type Scratch

type Scratch struct {
	// DirFuzz is the directory to which fuzzed subjects will be output.
	DirFuzz string
	// DirLift is the directory to which lifter outputs will be written.
	DirLift string
	// DirRun is the directory into which c4t-mach output will go.
	DirRun string
}

Scratch contains the pre-computed paths for a machine run.

func NewScratch

func NewScratch(root string) *Scratch

NewScratch creates a machine pathset rooted at root.

Example

ExampleNewScratch is a runnable example for NewScratch.

package main

import (
	"fmt"
	"path/filepath"

	"github.com/c4-project/c4t/internal/director/pathset"
)

func main() {
	p := pathset.NewScratch("scratch")

	fmt.Println("run: ", filepath.ToSlash(p.DirRun))
	fmt.Println("lift:", filepath.ToSlash(p.DirLift))
	fmt.Println("fuzz:", filepath.ToSlash(p.DirFuzz))

}
Output:

run:  scratch/run
lift: scratch/lift
fuzz: scratch/fuzz

func (*Scratch) Dirs

func (p *Scratch) Dirs() []string

Dirs gets all of the directories in this pathset, which is useful for making and removing directories.

func (*Scratch) Prepare

func (p *Scratch) Prepare() error

Prepare prepares this pathset by making its directories.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL