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

Function RunTestCaseGenerator

client/packmgr/generator.go:127–164  ·  view source on GitHub ↗

RunTestCaseGenerator 运行测试数据生成器 (APP入口)

(c *cli.Context)

Source from the content-addressed store, hash-verified

125
126// RunTestCaseGenerator 运行测试数据生成器 (APP入口)
127func RunTestCaseGenerator(c *cli.Context) error {
128 configFile := c.Args().Get(0)
129 _, err := os.Stat(configFile)
130 if err != nil && os.IsNotExist(err) {
131 return errors.Errorf("[generator] problem config file (%s) not found", configFile)
132 }
133 session, err := executor.NewSession(configFile)
134 if err != nil {
135 return err
136 }
137
138 if !c.Bool("silence") {
139 fmt.Print("[generator] Operation will cover all files, continue? [y/N] ")
140 ans := ""
141 _, err := fmt.Scanf("%s", &ans)
142 if err != nil {
143 return nil // don't crash at EOF
144 }
145 if len(ans) > 0 && strings.ToLower(ans[:1]) != "y" {
146 return nil
147 }
148 }
149
150 withAnswer := c.Bool("with-answer")
151 answerCaseIndex := c.Uint("answer")
152 testCaseIndex := c.Int("case")
153
154 // 编译答案代码
155 if withAnswer {
156 err = initWork(session, answerCaseIndex)
157 if err != nil {
158 return err
159 }
160 defer session.Clean()
161 }
162
163 return runTestCaseGenerator(session, testCaseIndex, withAnswer)
164}

Callers

nothing calls this directly

Calls 6

NewSessionFunction · 0.92
initWorkFunction · 0.85
runTestCaseGeneratorFunction · 0.85
ErrorfMethod · 0.80
PrintMethod · 0.80
CleanMethod · 0.65

Tested by

no test coverage detected