diff --git a/cmd/cptest/executable.go b/cmd/cptest/executable.go index 0374f4c..fa216f1 100644 --- a/cmd/cptest/executable.go +++ b/cmd/cptest/executable.go @@ -17,42 +17,42 @@ func (e *Executable) Run(r io.Reader) (cptest.ProcessResult, error) { cmd := exec.Command(e.Path) cmd.Stdin = r - stdoutPipe, err := cmd.StdoutPipe() - if err != nil { - return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) - } - - stderrPipe, err := cmd.StderrPipe() - if err != nil { - return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) - } - - err = cmd.Start() - if err != nil { - return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) - } - - stdErr, err := ioutil.ReadAll(stderrPipe) - if err != nil { - return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) - } - - stdOut, err := ioutil.ReadAll(stdoutPipe) - if err != nil { - return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) - } - - out := cptest.ProcessResult{ - ExitCode: 0, - Stdout: string(stdOut), - Stderr: string(stdErr), - } - - err = cmd.Wait() + stdoutPipe, err := cmd.StdoutPipe() + if err != nil { + return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) + } + + stderrPipe, err := cmd.StderrPipe() + if err != nil { + return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) + } + + err = cmd.Start() + if err != nil { + return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) + } + + stdErr, err := ioutil.ReadAll(stderrPipe) + if err != nil { + return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) + } + + stdOut, err := ioutil.ReadAll(stdoutPipe) + if err != nil { + return cptest.ProcessResult{}, fmt.Errorf("executable: %v", err) + } + + out := cptest.ProcessResult{ + ExitCode: 0, + Stdout: string(stdOut), + Stderr: string(stdErr), + } + + err = cmd.Wait() if ee, ok := err.(*exec.ExitError); ok { - out.ExitCode = ee.ExitCode() - return out, nil + out.ExitCode = ee.ExitCode() + return out, nil } if err != nil { diff --git a/cmd/cptest/main.go b/cmd/cptest/main.go index b618161..760e87a 100644 --- a/cmd/cptest/main.go +++ b/cmd/cptest/main.go @@ -7,7 +7,7 @@ import ( "github.com/alexflint/go-arg" "github.com/kuredoro/cptest" "github.com/logrusorgru/aurora" - "github.com/mattn/go-colorable" + "github.com/mattn/go-colorable" ) var wd = "." @@ -15,15 +15,15 @@ var wd = "." var stdout = colorable.NewColorableStdout() type appArgs struct { - Inputs string `arg:"-i" default:"inputs.txt" help:"file with tests"` - Executable string `arg:"positional,required"` - NoColors bool `arg:"--no-colors" help:"disable colored output"` + Inputs string `arg:"-i" default:"inputs.txt" help:"file with tests"` + Executable string `arg:"positional,required"` + NoColors bool `arg:"--no-colors" help:"disable colored output"` } var args appArgs func (appArgs) Description() string { - return `Feed programs fixed inputs, compare their outputs against expected ones. + return `Feed programs fixed inputs, compare their outputs against expected ones. Author: @kuredoro User manual: https://github.com/kuredoro/cptest @@ -31,23 +31,23 @@ User manual: https://github.com/kuredoro/cptest } func (appArgs) Version() string { - return "cptest 1.02a" + return "cptest 1.02a" } func init() { - arg.MustParse(&args) - - if args.NoColors { - cptest.Au = aurora.NewAurora(false) - } - - verdictStr = map[cptest.Verdict]aurora.Value{ - cptest.OK: cptest.Au.Bold("OK").Green(), - cptest.IE: cptest.Au.Bold("IE").Bold(), - cptest.WA: cptest.Au.Bold("WA").Red(), - cptest.RE: cptest.Au.Bold("RE").Magenta(), - cptest.TL: cptest.Au.Bold("TL").Yellow(), - } + arg.MustParse(&args) + + if args.NoColors { + cptest.Au = aurora.NewAurora(false) + } + + verdictStr = map[cptest.Verdict]aurora.Value{ + cptest.OK: cptest.Au.Bold("OK").Green(), + cptest.IE: cptest.Au.Bold("IE").Bold(), + cptest.WA: cptest.Au.Bold("WA").Red(), + cptest.RE: cptest.Au.Bold("RE").Magenta(), + cptest.TL: cptest.Au.Bold("TL").Yellow(), + } } func main() { @@ -57,7 +57,7 @@ func main() { return } - inputsPath := joinIfRelative(wd, args.Inputs) + inputsPath := joinIfRelative(wd, args.Inputs) inputs, errs := readInputs(inputsPath) if errs != nil { @@ -68,7 +68,7 @@ func main() { return } - execPath := joinIfRelative(wd, args.Executable) + execPath := joinIfRelative(wd, args.Executable) proc := &Executable{ Path: execPath, } @@ -82,7 +82,7 @@ func main() { batch := cptest.NewTestingBatch(inputs, proc, swatch) - fmt.Printf("floating point precision: %d digit(s)\n", batch.Lx.Precision) + fmt.Printf("floating point precision: %d digit(s)\n", batch.Lx.Precision) batch.TestStartCallback = runPrinter batch.TestEndCallback = verboseResultPrinter diff --git a/cmd/cptest/printer.go b/cmd/cptest/printer.go index 70bc178..d5a52cf 100644 --- a/cmd/cptest/printer.go +++ b/cmd/cptest/printer.go @@ -34,9 +34,9 @@ func verboseResultPrinter(b *cptest.TestingBatch, test cptest.Test, id int) { fmt.Printf("Stderr:\n%s\n", b.Outs[id].Stderr) } else if verdict == cptest.WA { fmt.Fprintf(stdout, "Output:\n%s\n", cptest.DumpLexemes(b.RichOuts[id], diffColor)) - if b.Outs[id].Stderr != "" { - fmt.Printf("Stderr:\n%s\n", b.Outs[id].Stderr) - } + if b.Outs[id].Stderr != "" { + fmt.Printf("Stderr:\n%s\n", b.Outs[id].Stderr) + } } else if verdict == cptest.IE { fmt.Printf("Error:\n%v\n\n", b.Errs[id]) } diff --git a/dump_lexemes.go b/dump_lexemes.go index 3fc2fb9..a5f4e2d 100644 --- a/dump_lexemes.go +++ b/dump_lexemes.go @@ -1,8 +1,8 @@ package cptest import ( - "strings" "github.com/logrusorgru/aurora" + "strings" ) // AltLineFeed is the representation of LF in textual form, that replaces LF @@ -16,27 +16,26 @@ const AltLineFeed = "\\n" func DumpLexemes(xms []RichText, color aurora.Color) string { var str strings.Builder - x := 0 - for _, xm := range xms { - if x != 0 && xm.Str != "\n" { - str.WriteRune(' ') - } + x := 0 + for _, xm := range xms { + if x != 0 && xm.Str != "\n" { + str.WriteRune(' ') + } - if xm.Str == "\n" { - x = -1 + if xm.Str == "\n" { + x = -1 - if xm.Colorful() { - str.WriteString(Au.Colorize(AltLineFeed, color).String()) - str.WriteRune('\n') - x++ - continue - } - } + if xm.Colorful() { + str.WriteString(Au.Colorize(AltLineFeed, color).String()) + str.WriteRune('\n') + x++ + continue + } + } - str.WriteString(xm.Colorize(color)) - x++ - } + str.WriteString(xm.Colorize(color)) + x++ + } return str.String() } - diff --git a/dump_lexemes_test.go b/dump_lexemes_test.go index 2d4c8dd..5c234c5 100644 --- a/dump_lexemes_test.go +++ b/dump_lexemes_test.go @@ -8,73 +8,73 @@ import ( ) func TestDumpLexemes(t *testing.T) { - t.Run("single lexeme", func(t *testing.T) { - xms := []cptest.RichText{ - {"foo", []bool{false, false, false}}, - } - - got := cptest.DumpLexemes(xms, aurora.RedFg) - want := "foo" - - cptest.AssertText(t, got, want) - }) - - t.Run("multiple on one line", func(t *testing.T) { - xms := []cptest.RichText{ - {"foo", []bool{false, false, false}}, - {"bar", []bool{true, true, true}}, - } - - got := cptest.DumpLexemes(xms, aurora.BoldFm) - want := "foo " + aurora.Bold("bar").String() - - cptest.AssertText(t, got, want) - }) - - t.Run("with one new line", func(t *testing.T) { - xms := []cptest.RichText{ - {"foo", []bool{false, false, false}}, - {"bar", []bool{true, true, true}}, - {"\n", []bool{false}}, - } - - got := cptest.DumpLexemes(xms, aurora.BoldFm) - want := "foo " + aurora.Bold("bar").String() + "\n" - - cptest.AssertText(t, got, want) - }) - - t.Run("multiple lines", func(t *testing.T) { - xms := []cptest.RichText{ - {"foo", []bool{false, false, false}}, - {"bar", []bool{true, true, true}}, - {"\n", []bool{false}}, - {"bar", []bool{false, false, false}}, - {"foo", []bool{true, true, true}}, - {"\n", []bool{false}}, - } - - got := cptest.DumpLexemes(xms, aurora.BoldFm) - want := "foo " + aurora.Bold("bar").String() + "\n" - want += "bar " + aurora.Bold("foo").String() + "\n" - - cptest.AssertText(t, got, want) - }) - - t.Run("colorized new line", func(t *testing.T) { - xms := []cptest.RichText{ - {"foo", []bool{false, false, false}}, - {"\n", []bool{true}}, - {"\n", []bool{true}}, - {"bar", []bool{true, true, true}}, - {"\n", []bool{false}}, - } - - got := cptest.DumpLexemes(xms, aurora.BoldFm) - - colorizedLF := aurora.Bold(cptest.AltLineFeed).String() + "\n" - want := "foo" + colorizedLF + colorizedLF + aurora.Bold("bar").String() + "\n" - - cptest.AssertText(t, got, want) - }) + t.Run("single lexeme", func(t *testing.T) { + xms := []cptest.RichText{ + {"foo", []bool{false, false, false}}, + } + + got := cptest.DumpLexemes(xms, aurora.RedFg) + want := "foo" + + cptest.AssertText(t, got, want) + }) + + t.Run("multiple on one line", func(t *testing.T) { + xms := []cptest.RichText{ + {"foo", []bool{false, false, false}}, + {"bar", []bool{true, true, true}}, + } + + got := cptest.DumpLexemes(xms, aurora.BoldFm) + want := "foo " + aurora.Bold("bar").String() + + cptest.AssertText(t, got, want) + }) + + t.Run("with one new line", func(t *testing.T) { + xms := []cptest.RichText{ + {"foo", []bool{false, false, false}}, + {"bar", []bool{true, true, true}}, + {"\n", []bool{false}}, + } + + got := cptest.DumpLexemes(xms, aurora.BoldFm) + want := "foo " + aurora.Bold("bar").String() + "\n" + + cptest.AssertText(t, got, want) + }) + + t.Run("multiple lines", func(t *testing.T) { + xms := []cptest.RichText{ + {"foo", []bool{false, false, false}}, + {"bar", []bool{true, true, true}}, + {"\n", []bool{false}}, + {"bar", []bool{false, false, false}}, + {"foo", []bool{true, true, true}}, + {"\n", []bool{false}}, + } + + got := cptest.DumpLexemes(xms, aurora.BoldFm) + want := "foo " + aurora.Bold("bar").String() + "\n" + want += "bar " + aurora.Bold("foo").String() + "\n" + + cptest.AssertText(t, got, want) + }) + + t.Run("colorized new line", func(t *testing.T) { + xms := []cptest.RichText{ + {"foo", []bool{false, false, false}}, + {"\n", []bool{true}}, + {"\n", []bool{true}}, + {"bar", []bool{true, true, true}}, + {"\n", []bool{false}}, + } + + got := cptest.DumpLexemes(xms, aurora.BoldFm) + + colorizedLF := aurora.Bold(cptest.AltLineFeed).String() + "\n" + want := "foo" + colorizedLF + colorizedLF + aurora.Bold("bar").String() + "\n" + + cptest.AssertText(t, got, want) + }) } diff --git a/lexer.go b/lexer.go index 3210f13..fbd8c1c 100644 --- a/lexer.go +++ b/lexer.go @@ -165,27 +165,27 @@ func (l *Lexer) Compare(target, source []string) (rts []RichText, ok bool) { rts = make([]RichText, len(target)) ok = true - ti, si := 0, 0 + ti, si := 0, 0 for ; ti < len(target) && si < len(source); ti, si = ti+1, si+1 { - // Skip spurious LFs - if source[si] != "\n" { - for ti < len(target) && target[ti] == "\n" { - rts[ti].Str = "\n" - rts[ti].Mask = []bool{true} - ok = false - ti++ - } - } else if target[ti] != "\n" { - for si < len(source) && source[si] == "\n" { - si++ - } - } - - if ti == len(target) || si == len(source) { - break - } - - xm := target[ti] + // Skip spurious LFs + if source[si] != "\n" { + for ti < len(target) && target[ti] == "\n" { + rts[ti].Str = "\n" + rts[ti].Mask = []bool{true} + ok = false + ti++ + } + } else if target[ti] != "\n" { + for si < len(source) && source[si] == "\n" { + si++ + } + } + + if ti == len(target) || si == len(source) { + break + } + + xm := target[ti] rts[ti].Str = xm rts[ti].Mask = l.GenerateMask(xm, source[si]) @@ -196,7 +196,7 @@ func (l *Lexer) Compare(target, source []string) (rts []RichText, ok bool) { for ; ti < len(target); ti++ { rts[ti].Str = target[ti] - rts[ti].Mask = l.GenMaskForString(target[ti], "") + rts[ti].Mask = l.GenMaskForString(target[ti], "") ok = false } @@ -221,15 +221,15 @@ func DeduceLexemeType(xm string) lexemeType { // GenerateMask is a wrapper function that finds the common type of the two // lexems and generates a color mask for the target based on source. func (l *Lexer) GenerateMask(target, source string) []bool { - targetType := DeduceLexemeType(target) - sourceType := DeduceLexemeType(source) + targetType := DeduceLexemeType(target) + sourceType := DeduceLexemeType(source) - commonType := targetType - if sourceType < commonType { - commonType = sourceType - } + commonType := targetType + if sourceType < commonType { + commonType = sourceType + } - return MaskGenerators[commonType](l, target, source) + return MaskGenerators[commonType](l, target, source) } // GenMaskForString will highlight mismatching characters. @@ -299,14 +299,14 @@ func (l *Lexer) GenMaskForFloat(target, source string) (mask []bool) { mask = l.GenMaskForInt(targetWhole, sourceWhole) - if targetWhole == target { - return - } + if targetWhole == target { + return + } // dot is never colored mask = append(mask, false) - // This one is never 0, because of the if up there that returns + // This one is never 0, because of the if up there that returns targetFracStart := strings.IndexRune(target, '.') + 1 sourceFracStart := strings.IndexRune(source, '.') + 1 diff --git a/processer.go b/processer.go index cf6b93d..e7d75eb 100644 --- a/processer.go +++ b/processer.go @@ -8,9 +8,9 @@ import ( // ProcessResult contains the text printed to stdout and stderr by the process // and the exit code returned upon termination. type ProcessResult struct { - ExitCode int - Stdout string - Stderr string + ExitCode int + Stdout string + Stderr string } // Processer interface abstracts away the concept of the executable under diff --git a/testing.go b/testing.go index eeb550f..ec82e36 100644 --- a/testing.go +++ b/testing.go @@ -217,23 +217,23 @@ func AssertRichTextMask(t *testing.T, got, want []bool) { func AssertEnrichedLexSequence(t *testing.T, got, want []RichText) { t.Helper() - gotStr := DumpLexemes(got, aurora.BoldFm) - gotStr = strings.ReplaceAll(gotStr, "\n", "\\n") + gotStr := DumpLexemes(got, aurora.BoldFm) + gotStr = strings.ReplaceAll(gotStr, "\n", "\\n") - wantStr := DumpLexemes(want, aurora.BoldFm) - wantStr = strings.ReplaceAll(wantStr, "\n", "\\n") + wantStr := DumpLexemes(want, aurora.BoldFm) + wantStr = strings.ReplaceAll(wantStr, "\n", "\\n") - if gotStr != wantStr { - t.Errorf("got lexemes '%s', want '%s'", gotStr, wantStr) - } + if gotStr != wantStr { + t.Errorf("got lexemes '%s', want '%s'", gotStr, wantStr) + } } func AssertText(t *testing.T, got, want string) { - t.Helper() + t.Helper() - if got != want { - got = strings.ReplaceAll(got, "\n", "\\n") - want = strings.ReplaceAll(want, "\n", "\\n") - t.Errorf("got text '%s', want '%s'", got, want) - } + if got != want { + got = strings.ReplaceAll(got, "\n", "\\n") + want = strings.ReplaceAll(want, "\n", "\\n") + t.Errorf("got text '%s', want '%s'", got, want) + } } diff --git a/testing_batch.go b/testing_batch.go index 3352d20..5b37947 100644 --- a/testing_batch.go +++ b/testing_batch.go @@ -66,7 +66,7 @@ type TestingBatch struct { Outs map[int]ProcessResult RichOuts map[int][]RichText RichAnswers map[int][]RichText - Lx *Lexer + Lx *Lexer Verdicts map[int]Verdict Times map[int]time.Duration @@ -81,10 +81,10 @@ type TestingBatch struct { // NewTestingBatch will initialize channels and maps inside TestingBatch and // will assign respective dependency injections. func NewTestingBatch(inputs Inputs, proc Processer, swatch Stopwatcher) *TestingBatch { - precision, err := strconv.Atoi(inputs.Config["prec"]) - if err != nil{ - precision = int(DefaultPrecision) - } + precision, err := strconv.Atoi(inputs.Config["prec"]) + if err != nil { + precision = int(DefaultPrecision) + } return &TestingBatch{ inputs: inputs, @@ -95,9 +95,9 @@ func NewTestingBatch(inputs Inputs, proc Processer, swatch Stopwatcher) *Testing RichOuts: make(map[int][]RichText), RichAnswers: make(map[int][]RichText), - Lx: &Lexer{ - Precision: uint(precision), - }, + Lx: &Lexer{ + Precision: uint(precision), + }, Verdicts: make(map[int]Verdict), Times: make(map[int]time.Duration), @@ -116,7 +116,7 @@ func (b *TestingBatch) launchTest(id int, in string) { b.complete <- TestResult{ ID: id, Err: fmt.Errorf("internal: %v", e), - Out: ProcessResult{}, + Out: ProcessResult{}, } } }() @@ -172,9 +172,9 @@ func (b *TestingBatch) Run() { b.RichAnswers[id], _ = b.Lx.Compare(answerLexemes, nil) if err := b.Errs[id]; err != nil { - b.Verdicts[id] = IE + b.Verdicts[id] = IE } else if b.Outs[id].ExitCode != 0 { - b.Verdicts[id] = RE + b.Verdicts[id] = RE } else { got := b.Lx.Scan(b.Outs[id].Stdout) diff --git a/testing_batch_test.go b/testing_batch_test.go index 6c44552..dc2ab6f 100644 --- a/testing_batch_test.go +++ b/testing_batch_test.go @@ -15,86 +15,86 @@ func ProcFuncMultiply(in io.Reader) (cptest.ProcessResult, error) { var a, b int fmt.Fscan(in, &a, &b) - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: fmt.Sprintln(a*b), - Stderr: "", - }, nil + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: fmt.Sprintln(a * b), + Stderr: "", + }, nil } func ProcFuncIntegerSequence(in io.Reader) (cptest.ProcessResult, error) { var n int fmt.Fscan(in, &n) - buf := &bytes.Buffer{} + buf := &bytes.Buffer{} for i := 1; i <= n; i++ { fmt.Fprint(buf, i, " ") } fmt.Fprintln(buf) - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: buf.String(), - Stderr: "", - }, nil + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: buf.String(), + Stderr: "", + }, nil } func ProcFuncBogusFloatingPoint(in io.Reader) (cptest.ProcessResult, error) { var n int fmt.Fscan(in, &n) - out := "" - if n == 1 { - out = "1.234567\n" - } else if n == 2 { - out = "2.345678\n" - } - - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: out, - Stderr: "", - }, nil + out := "" + if n == 1 { + out = "1.234567\n" + } else if n == 2 { + out = "2.345678\n" + } + + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: out, + Stderr: "", + }, nil } func ProcFuncAnswer(in io.Reader) (cptest.ProcessResult, error) { - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: "42", - Stderr: "", - }, nil + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: "42", + Stderr: "", + }, nil } func TestNewTestingBatch(t *testing.T) { - t.Run("no state altering configs", func(t *testing.T) { - inputs := cptest.Inputs{ - Tests: nil, - Config: map[string]string{}, - } - - batch := cptest.NewTestingBatch(inputs, nil, nil) - - if batch.Lx.Precision != cptest.DefaultPrecision { - t.Errorf("got lexer precision %d, but want default value %d", - batch.Lx.Precision, cptest.DefaultPrecision) - } - }) - - t.Run("prec option", func(t *testing.T) { - inputs := cptest.Inputs{ - Tests: nil, - Config: map[string]string{ - "prec": "22", - }, - } - - batch := cptest.NewTestingBatch(inputs, nil, nil) - - if batch.Lx.Precision != 22 { - t.Errorf("got lexer precision %d, but want 22", batch.Lx.Precision) - } - }) + t.Run("no state altering configs", func(t *testing.T) { + inputs := cptest.Inputs{ + Tests: nil, + Config: map[string]string{}, + } + + batch := cptest.NewTestingBatch(inputs, nil, nil) + + if batch.Lx.Precision != cptest.DefaultPrecision { + t.Errorf("got lexer precision %d, but want default value %d", + batch.Lx.Precision, cptest.DefaultPrecision) + } + }) + + t.Run("prec option", func(t *testing.T) { + inputs := cptest.Inputs{ + Tests: nil, + Config: map[string]string{ + "prec": "22", + }, + } + + batch := cptest.NewTestingBatch(inputs, nil, nil) + + if batch.Lx.Precision != 22 { + t.Errorf("got lexer precision %d, but want 22", batch.Lx.Precision) + } + }) } // IDEA: Add support for presentation errors... @@ -185,9 +185,9 @@ func TestTestingBatch(t *testing.T) { Output: "2.5\n", }, }, - Config: map[string]string{ - "prec": "1", - }, + Config: map[string]string{ + "prec": "1", + }, } proc := &cptest.SpyProcesser{ @@ -277,22 +277,22 @@ func TestTestingBatch(t *testing.T) { fmt.Fscan(r, &num) if num == 3 { - return cptest.ProcessResult{ - ExitCode: 1, - Stdout: "", - Stderr: "segfault. (core dumped)", - }, nil + return cptest.ProcessResult{ + ExitCode: 1, + Stdout: "", + Stderr: "segfault. (core dumped)", + }, nil } if num == 5 { panic("brrrr") } - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: "1\n", - Stderr: "", - }, nil + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: "1\n", + Stderr: "", + }, nil }), } @@ -313,9 +313,9 @@ func TestTestingBatch(t *testing.T) { cptest.AssertVerdicts(t, batch.Verdicts, want) cptest.AssertCallCount(t, proc.CallCount(), 5) - if len(batch.RichAnswers[3]) == 0 || len(batch.RichAnswers[5]) == 0 { - t.Errorf("got wrong rich answers, %s", litter.Sdump(batch.RichAnswers)) - } + if len(batch.RichAnswers[3]) == 0 || len(batch.RichAnswers[5]) == 0 { + t.Errorf("got wrong rich answers, %s", litter.Sdump(batch.RichAnswers)) + } }) t.Run("test cases may be abandoned at TL", @@ -338,11 +338,11 @@ func TestTestingBatch(t *testing.T) { dur := time.Duration(num) time.Sleep(5 * dur * time.Millisecond) - return cptest.ProcessResult{ - ExitCode: 0, - Stdout: fmt.Sprintln(num), - Stderr: "", - }, nil + return cptest.ProcessResult{ + ExitCode: 0, + Stdout: fmt.Sprintln(num), + Stderr: "", + }, nil }), }