tools

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: Apache-2.0 Imports: 17 Imported by: 1

README

Some machine tools

"Expect"

This tool facilitates Machine Spec testing.

See the godoc for Session, and see ../cmd/mexpect.

Generate a Graphviz dot file for a spec

See dot.go.

Analyze a spec

See analyze.go and analyze_test.go.

Render a spec as HTML

See spec-html*.*.

Usage

Copy spec-html.js and spec-html.css to ../cmd/mcrew/httpfies. Then run mcrew:

mcrew -h :9050 -f cmd/mcrew/httpfiles/

Then try http://localhost:9050/specs/double.html.

Documentation

Overview

Package tools includes miscellaneous tooling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(spec *Spec, w io.WriteCloser, fromNode, toNode string) error

Dot makes a Graphviz dot file for the given machine. A really ugly dot file.

The optional fromNode and toNode can be names of nodes during a transition. If non-zero, then the fromNode will be black and the toNode will be red. Maybe.

func Inline

func Inline(bs []byte, f func(string) ([]byte, error)) ([]byte, error)

Inline replaces '%inline("NAME")' with f(NAME).

func Mermaid

func Mermaid(spec *Spec, w io.WriteCloser, opts *MermaidOpts, fromNode, toNode string) error

Mermaid makes a Mermaid (https://mermaidjs.github.io/) input file for the given graph.

func PNG

func PNG(spec *Spec, basename string, fromNode, toNode string) (string, error)

PNG generates a PNG image based on output from Dot.

This function with write two files: basename.dot and basename.png, where the basename is the given string.

func ReadAllWithInlines

func ReadAllWithInlines(in io.Reader, dir string) ([]byte, error)

ReadFileWithInlines is a replacement for ioutil.ReadAll that adds automation Inline()ing based on the given directory.

'%inline("NAME")' is replaced with ReadFile(NAME).

func ReadAndRenderSpecPage

func ReadAndRenderSpecPage(filename string, cssFiles []string, out io.Writer, includeGraph bool) error

func ReadFileWithInlines

func ReadFileWithInlines(filename string) ([]byte, error)

ReadFileWithInlines is a replacement for ioutil.ReadFile that adds automation Inline()ing based on the directory obtained from the filename.

'%inline("NAME")' is replaced with ReadFile(NAME).

func RenderSpecHTML

func RenderSpecHTML(s *core.Spec, out io.Writer) error

func RenderSpecPage

func RenderSpecPage(s *core.Spec, out io.Writer, cssFiles []string, includeGraph bool) error

Types

type MermaidOpts

type MermaidOpts struct {
	// ShowPatterns will result in a branch label that's theJSON
	// representation of the branch pattern (if any).
	ShowPatterns bool `json:"showPatterns"`

	// ActionFill is the fill color of for action nodes.  Does not
	// apply if ActionClass is set.
	ActionFill string `json:"actionFill,omitempty"`

	// ActionClass will be the CSS class for action nodes.  Not
	// yet implemented.
	ActionClass string `json:"actionClass,omitempty"`

	PrettyPatterns bool `json:"prettyPatterns,omitempty"`
}

type SpecAnalysis

type SpecAnalysis struct {
	Errors                []string
	NodeCount             int
	Branches              int
	Actions               int
	Guards                int
	TerminalNodes         []string
	Orphans               []string
	EmptyTargets          []string
	MissingTargets        []string
	BranchTargetVariables []string

	Interpreters []string
	// contains filtered or unexported fields
}

func Analyze

func Analyze(s *core.Spec) (*SpecAnalysis, error)

Directories

Path Synopsis
Package expect is a tool for testing machine specifications.
Package expect is a tool for testing machine specifications.

Jump to

Keyboard shortcuts

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