| 258 | } |
| 259 | |
| 260 | async function execImageDiffCommand(cmd: string) { |
| 261 | return await new Promise<string>((resolve, reject) => { |
| 262 | let commandOutput = ''; |
| 263 | try { |
| 264 | commandOutput = childProcess.execSync(cmd, {encoding: 'utf8'}); |
| 265 | resolve(commandOutput); |
| 266 | } catch (e) { |
| 267 | // image_diff will exit with a status code of 1 if the diff is too big, so |
| 268 | // this needs to be caught, but the outcome is the same - we want to send |
| 269 | // back the string for processing. |
| 270 | if (e.stdout && e.stdout.indexOf('diff') === -1) { |
| 271 | reject(new Error(`Comparing diff failed. stdout: "${e.stdout}"`)); |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | resolve(e.stdout); |
| 276 | } |
| 277 | }); |
| 278 | } |
| 279 | |
| 280 | async function compare(golden: string, generated: string, maximumDiffThreshold: number, isInDiffUpdateMode: boolean) { |
| 281 | const isOnBot = process.env.LUCI_CONTEXT !== undefined; |