merge method

Configuration merge(
  1. Configuration other
)

Merges this with other.

For most fields, if both configurations have values set, other's value takes precedence. However, certain fields are merged together instead. This is indicated in those fields' documentation.

Implementation

Configuration merge(Configuration other) {
  if (this == Configuration.empty) return other;
  if (other == Configuration.empty) return this;

  var foldTraceOnly = other._foldTraceOnly ?? _foldTraceOnly;
  var foldTraceExcept = other._foldTraceExcept ?? _foldTraceExcept;
  if (_foldTraceOnly != null) {
    if (other._foldTraceExcept != null) {
      foldTraceOnly = _foldTraceOnly!.difference(other._foldTraceExcept!);
    } else if (other._foldTraceOnly != null) {
      foldTraceOnly = other._foldTraceOnly!.intersection(_foldTraceOnly!);
    }
  } else if (_foldTraceExcept != null) {
    if (other._foldTraceOnly != null) {
      foldTraceOnly = other._foldTraceOnly!.difference(_foldTraceExcept!);
    } else if (other._foldTraceExcept != null) {
      foldTraceExcept = other._foldTraceExcept!.union(_foldTraceExcept!);
    }
  }

  var result = Configuration._(
      help: other._help ?? _help,
      customHtmlTemplatePath:
          other.customHtmlTemplatePath ?? customHtmlTemplatePath,
      version: other._version ?? _version,
      pauseAfterLoad: other._pauseAfterLoad ?? _pauseAfterLoad,
      debug: other._debug ?? _debug,
      color: other._color ?? _color,
      configurationPath: other._configurationPath ?? _configurationPath,
      reporter: other._reporter ?? _reporter,
      fileReporters: mergeMaps(fileReporters, other.fileReporters),
      coverage: other.coverage ?? coverage,
      concurrency: other._concurrency ?? _concurrency,
      shardIndex: other.shardIndex ?? shardIndex,
      totalShards: other.totalShards ?? totalShards,
      testSelections: other._testSelections ?? _testSelections,
      foldTraceExcept: foldTraceExcept,
      foldTraceOnly: foldTraceOnly,
      filename: other._filename ?? _filename,
      chosenPresets: chosenPresets.union(other.chosenPresets),
      presets: _mergeConfigMaps(presets, other.presets),
      overrideRuntimes: mergeUnmodifiableMaps(
          overrideRuntimes, other.overrideRuntimes,
          value: (settings1, settings2) => RuntimeSettings(
              settings1.identifier,
              settings1.identifierSpan,
              [...settings1.settings, ...settings2.settings])),
      defineRuntimes:
          mergeUnmodifiableMaps(defineRuntimes, other.defineRuntimes),
      noRetry: other._noRetry ?? _noRetry,
      testRandomizeOrderingSeed:
          other.testRandomizeOrderingSeed ?? testRandomizeOrderingSeed,
      stopOnFirstFailure: other._stopOnFirstFailure ?? _stopOnFirstFailure,
      includeTags: includeTags.intersection(other.includeTags),
      excludeTags: excludeTags.union(other.excludeTags),
      globalPatterns: globalPatterns.union(other.globalPatterns),
      suiteDefaults: suiteDefaults.merge(other.suiteDefaults));
  result = result._resolvePresets();

  // Make sure the merged config preserves any presets that were chosen and
  // discarded.
  result._knownPresets = knownPresets.union(other.knownPresets);
  return result;
}