'Writes results based on the given ``settings``  or ``options``.
:param settings: :class:`~robot.conf.settings.RebotSettings` object
to configure result writing.
:param options: Used to construct new
:class:`~robot.conf.settings.RebotSettings` object if ``settings``
are not given.'

def write_results(self, settings=None, **options):

    settings = (settings or RebotSettings(options))
    results = Results(settings, *self._sources)
    if settings.output:
        self._write_output(results.result, settings.output)
    if settings.xunit:
        self._write_xunit(results.result, settings.xunit, settings.xunit_skip_noncritical)
    if settings.log:
        config = dict(settings.log_config, minLevel=results.js_result.min_level)
        self._write_log(results.js_result, settings.log, config)
    if settings.report:
        results.js_result.remove_data_not_needed_in_report()
        self._write_report(results.js_result, settings.report, settings.report_config)
    return results.return_code
