From bc1bde8861d5248d4913436f17e6a1bc1fe9b1ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 8 May 2023 11:31:51 +0100 Subject: [PATCH] all: remove some unused code Primarily testscript's code to support calling testing.MainStart; we originally needed that to implement our own deep code coverage, but thankfully `go test` does that for us automatically now. --- gotooltest/setup.go | 9 -------- testscript/exe.go | 34 ----------------------------- testscript/exe_go118.go | 48 ----------------------------------------- 3 files changed, 91 deletions(-) delete mode 100644 testscript/exe_go118.go diff --git a/gotooltest/setup.go b/gotooltest/setup.go index 5ce75a18..c8d9ec07 100644 --- a/gotooltest/setup.go +++ b/gotooltest/setup.go @@ -172,12 +172,3 @@ func (e0 *environ) get(name string) string { } return "" } - -func (e *environ) set(name, val string) { - *e = append(*e, name+"="+val) -} - -func (e *environ) unset(name string) { - // TODO actually remove the name from the environment. - e.set(name, "") -} diff --git a/testscript/exe.go b/testscript/exe.go index 9b383542..95e90b92 100644 --- a/testscript/exe.go +++ b/testscript/exe.go @@ -139,37 +139,3 @@ func copyBinary(from, to string) error { _, err = io.Copy(writer, reader) return err } - -type nopTestDeps struct{} - -func (nopTestDeps) MatchString(pat, str string) (result bool, err error) { - return false, nil -} - -func (nopTestDeps) StartCPUProfile(w io.Writer) error { - return nil -} - -func (nopTestDeps) StopCPUProfile() {} - -func (nopTestDeps) WriteProfileTo(name string, w io.Writer, debug int) error { - return nil -} - -func (nopTestDeps) ImportPath() string { - return "" -} -func (nopTestDeps) StartTestLog(w io.Writer) {} - -func (nopTestDeps) StopTestLog() error { - return nil -} - -// Note: WriteHeapProfile is needed for Go 1.10 but not Go 1.11. -func (nopTestDeps) WriteHeapProfile(io.Writer) error { - // Not needed for Go 1.10. - return nil -} - -// Note: SetPanicOnExit0 was added in Go 1.16. -func (nopTestDeps) SetPanicOnExit0(bool) {} diff --git a/testscript/exe_go118.go b/testscript/exe_go118.go deleted file mode 100644 index a9bdd810..00000000 --- a/testscript/exe_go118.go +++ /dev/null @@ -1,48 +0,0 @@ -package testscript - -import ( - "reflect" - "testing" - "time" -) - -func mainStart() *testing.M { - // Note: testing.MainStart acquired an extra argument in Go 1.18. - return testing.MainStart(nopTestDeps{}, nil, nil, nil, nil) -} - -// Note: corpusEntry is an anonymous struct type used by some method stubs. -type corpusEntry = struct { - Parent string - Path string - Data []byte - Values []interface{} - Generation int - IsSeed bool -} - -// Note: CoordinateFuzzing was added in Go 1.18. -func (nopTestDeps) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error { - return nil -} - -// Note: RunFuzzWorker was added in Go 1.18. -func (nopTestDeps) RunFuzzWorker(func(corpusEntry) error) error { - return nil -} - -// Note: ReadCorpus was added in Go 1.18. -func (nopTestDeps) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) { - return nil, nil -} - -// Note: CheckCorpus was added in Go 1.18. -func (nopTestDeps) CheckCorpus([]interface{}, []reflect.Type) error { - return nil -} - -// Note: ResetCoverage was added in Go 1.18. -func (nopTestDeps) ResetCoverage() {} - -// Note: SnapshotCoverage was added in Go 1.18. -func (nopTestDeps) SnapshotCoverage() {}