gemini-testing / gemini

💀💀💀[DEPRECATED] Use hermione
https://github.com/gemini-testing/hermione
MIT License
1.5k stars 149 forks source link

How to retry only critical errors? #944

Open Astimus opened 5 years ago

Astimus commented 5 years ago

Hello. Right now retry works on critical errors and on failed diff. How to retry only on critical errors? Is there any workaround?

unekhriukova commented 5 years ago

I have the same question. I tried to make a workaround by emitting the Events.RETRY event, but that does not work. Maybe, guys, you can give some advice on that also.

'use strict';

const Gemini = require('gemini/api');
const Events = require('gemini/lib/constants/events');
const handleErrors = require('gemini/lib/cli/errors').handleErrors;

class GeminiCi {
  constructor() {
    let gemini = new Gemini();
    gemini.on(Events.ERROR, (err) => {
      if( err.name === 'GeminiError' ) {
        process.exit(handleErrors(err));
      } else {
        gemini.emit(Events.RETRY, Object.assign(err, {attempt: 0, retriesLeft: 1}));
      }
    });
    return gemini.test([], { reporters: [{ name: 'flat' }]})
      .then(stats => stats.failed > 0 ? 1 : 0);
  }
}

new GeminiCi();

"gemini": "5.9.1"