(vBin string, vCase *structs.TestlibValidatorCase)
| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 45 | func runTestCase(configDir, vBin string, tCase *structs.TestCase) error { |
| 46 | ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) |
no test coverage detected