MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / runValidatorCase

Function runValidatorCase

client/packmgr/validator.go:18–43  ·  view source on GitHub ↗
(vBin string, vCase *structs.TestlibValidatorCase)

Source from the content-addressed store, hash-verified

16)
17
18func runValidatorCase(vBin string, vCase *structs.TestlibValidatorCase) error {
19 ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
20 rel, err := utils.RunUnixShell(&structs.ShellOptions{
21 Context: ctx,
22 Name: vBin,
23 Args: nil,
24 StdWriter: nil,
25 OnStart: func(writer io.Writer) error {
26 _, err := writer.Write([]byte(vCase.Input))
27 return err
28 },
29 })
30 if err != nil {
31 return err
32 }
33 if rel.Success {
34 vCase.ValidatorVerdict = true
35 vCase.ValidatorComment = ""
36 } else {
37 log.Printf("[validator] validator error: %s", rel.Stderr)
38 vCase.ValidatorVerdict = false
39 vCase.ValidatorComment = rel.Stderr
40 }
41 vCase.Verdict = vCase.ValidatorVerdict == vCase.ExpectedVerdict
42 return nil
43}
44
45func runTestCase(configDir, vBin string, tCase *structs.TestCase) error {
46 ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)

Callers 1

RunTestlibValidatorCasesFunction · 0.85

Calls 1

RunUnixShellFunction · 0.92

Tested by

no test coverage detected