CallGenerator 调用Generator
(ctx context.Context, tc *structs.TestCase, configDir string)
| 140 | |
| 141 | // CallGenerator 调用Generator |
| 142 | func CallGenerator(ctx context.Context, tc *structs.TestCase, configDir string) ([]byte, error) { |
| 143 | name, args, err := ParseGeneratorScript(tc.Generator) |
| 144 | if err != nil { |
| 145 | return nil, err |
| 146 | } |
| 147 | gBin, err := GetCompiledBinaryFileAbsPath("generator", name, configDir) |
| 148 | if err != nil { |
| 149 | return nil, err |
| 150 | } |
| 151 | rel, err := RunUnixShell(&structs.ShellOptions{ |
| 152 | Context: ctx, |
| 153 | Name: gBin, |
| 154 | Args: args, |
| 155 | StdWriter: nil, |
| 156 | OnStart: nil, |
| 157 | }) |
| 158 | if err != nil { |
| 159 | return nil, err |
| 160 | } |
| 161 | if rel.Success { |
| 162 | return []byte(rel.Stdout), nil |
| 163 | } |
| 164 | return nil, errors.Errorf("generator error") |
| 165 | } |
| 166 | |
| 167 | // IsZipFile 判断是否是Zip文件 |
| 168 | func IsZipFile(filePath string) (bool, error) { |
no test coverage detected