RunTestCaseGenerator 运行测试数据生成器 (APP入口)
(c *cli.Context)
| 125 | |
| 126 | // RunTestCaseGenerator 运行测试数据生成器 (APP入口) |
| 127 | func 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 | } |
nothing calls this directly
no test coverage detected