SYNOPSYS import "clive/zx/fstest" var Verb bool ... var AllChgFiles = []string{ "/", "/a", "/a/b", "/d", "/e", "/e/f", "/a/n", "/a/n/m", "/1", "/a/a1", "/a/a2", "/a/n/m/m1", "/2", } ... func AsAFile(t Fataler, fs zx.Fs) func Attrs(t Fataler, xfs zx.Fs) func FindGets(t Fataler, xfs zx.Fs) func Finds(t Fataler, xfs zx.Fs) func GetCtl(t Fataler, xfs zx.Fs) func Gets(t Fataler, xfs zx.Fs) func MkChgs(t Fataler, tdir string) func MkChgs2(t Fataler, tdir string) func MkTree(t Fataler, tdir string) func MkZXChgs(t Fataler, xfs zx.Fs) func MkZXChgs2(t Fataler, xfs zx.Fs) func Mkdirs(t Fataler, xfs zx.Fs) func Moves(t Fataler, xfs zx.Fs) func Puts(t Fataler, xfs zx.Fs) func Removes(t Fataler, xfs zx.Fs) func ResetTime() func Stats(t Fataler, fs zx.Fs) func Touch(path string) func TouchZX(fs zx.Wstater, path string) error func Wstats(t Fataler, xfs zx.Fs) type Fataler interface { ... } type TestFunc func(t Fataler, fs zx.Fs) DESCRIPTION Utilities to aid in tests of zx file systems packages CONSTANTS TYPES type Fataler interface { Fatalf(format string, args ...interface{}) Logf(format string, args ...interface{}) Fail() } Usually testing.T or testing.B type TestFunc func(t Fataler, fs zx.Fs) FUNCTIONS func AsAFile(t Fataler, fs zx.Fs) func Attrs(t Fataler, xfs zx.Fs) func FindGets(t Fataler, xfs zx.Fs) func Finds(t Fataler, xfs zx.Fs) func GetCtl(t Fataler, xfs zx.Fs) func Gets(t Fataler, xfs zx.Fs) func MkChgs(t Fataler, tdir string) Make some changes in the test tree. - Touch /a/a1 - Chmod /a/a2 750 - Remove /a/b/c /a/b/c/c3 - Create /a/n/ /a/n/m/ /a/n/m/m1 (750 750 640) func MkChgs2(t Fataler, tdir string) Make some changes in the test tree, another version. - Remove /2 - Create /2/n2 750 - Resize /1 to 50 bytes func MkTree(t Fataler, tdir string) Create a tree with Dirs and Files at tdir at the underlying OS func MkZXChgs(t Fataler, xfs zx.Fs) Make some changes in the test zx tree. - Touch /a/a1 - Chmod /a/a2 - Remove /a/b/c /a/b/c/c3 - Create /a/n /a/n/m /a/n/m/m1 func MkZXChgs2(t Fataler, xfs zx.Fs) Make some changes in the test zx tree, another version. - Remove /2 - Create /2/n2 - Truncate /1 func Mkdirs(t Fataler, xfs zx.Fs) func Moves(t Fataler, xfs zx.Fs) func Puts(t Fataler, xfs zx.Fs) func Removes(t Fataler, xfs zx.Fs) func ResetTime() Reset the time for files created func Stats(t Fataler, fs zx.Fs) func Touch(path string) set a fake mtime that can be predicted. func TouchZX(fs zx.Wstater, path string) error set a fake mtime that can be predicted. func Wstats(t Fataler, xfs zx.Fs) VARIABLES var ( Verb bool Printf = dbg.FlagPrintf(&Verb) // directories created Dirs = []string{"/", "/a", "/a/b", "/a/b/c", "/d", "/e", "/e/f"} // files created Files = []string{"/1", "/a/a1", "/a/a2", "/a/b/c/c3", "/2"} // dirs and files AllFiles = append(Dirs[:], Files[:]...) // file paths not in the test tree NotThere = []string{"/n", "/a/n1", "/e/f/n2"} // bad file paths; the 1st should be /, others should fail BadPaths = []string{"/a/../..", "a", "..", "/1/b"} // data stored in each file FileData = map[string][]byte{} Repeats = 1 ) var ( // dirs and files after MkChgs AllChgFiles = []string{ "/", "/a", "/a/b", "/d", "/e", "/e/f", "/a/n", "/a/n/m", "/1", "/a/a1", "/a/a2", "/a/n/m/m1", "/2", } // dirs and files after *both* MkChgs and MkChgs2 AllChg2Files = []string{ "/", "/2", "/a", "/a/b", "/d", "/e", "/e/f", "/a/n", "/a/n/m", "/1", "/2/n2", "/a/a1", "/a/a2", "/a/n/m/m1", } // all dirs and files listed using Dir.Fmt() AllFilesList = `d rwxr-xr-x 0 / - rw-r--r-- 0 /1 - rw-r--r-- 30.9k /2 d rwxr-xr-x 0 /a - rw-r--r-- 9.9k /a/a1 - rw-r--r-- 20.9k /a/a2 d rwxr-xr-x 0 /a/b d rwxr-xr-x 0 /a/b/c - rw-r--r-- 43.9k /a/b/c/c3 d rwxr-xr-x 0 /d d rwxr-xr-x 0 /e d rwxr-xr-x 0 /e/f ` // all dirs and files after MkChgs listed using Dir.Fmt() AllChgFilesList = `d rwxr-xr-x 0 / - rw-r--r-- 0 /1 - rw-r--r-- 30.9k /2 d rwxr-xr-x 0 /a - rw-r--r-- 9.9k /a/a1 - rwxr-x--- 20.9k /a/a2 d rwxr-xr-x 0 /a/b d rwxr-x--- 0 /a/n d rwxr-x--- 0 /a/n/m - rw-r----- 11 /a/n/m/m1 d rwxr-xr-x 0 /d d rwxr-xr-x 0 /e d rwxr-xr-x 0 /e/f ` // all dirs and files after MkChgs and MkChgs2 listed using Dir.Fmt() AllChg2FilesList = `d rwxr-xr-x 0 / - rw-r--r-- 50 /1 d rwxr-x--- 0 /2 d rwxr-x--- 0 /2/n2 d rwxr-xr-x 0 /a - rw-r--r-- 9.9k /a/a1 - rwxr-x--- 20.9k /a/a2 d rwxr-xr-x 0 /a/b d rwxr-x--- 0 /a/n d rwxr-x--- 0 /a/n/m - rw-r----- 11 /a/n/m/m1 d rwxr-xr-x 0 /d d rwxr-xr-x 0 /e d rwxr-xr-x 0 /e/f ` )
Clive, 2nd ed. User's manual. Section 2