BonesUITestRunner constructor

BonesUITestRunner({
  1. List<String>? args,
  2. Directory? compileDir,
  3. String bonesUITestConfigFileName = 'bones_ui_test_config.yaml',
  4. String bonesUITestTemplateFileName = 'bones_ui_test.html.tpl',
})

Implementation

BonesUITestRunner(
    {List<String>? args,
    Directory? compileDir,
    String bonesUITestConfigFileName = 'bones_ui_test_config.yaml',
    this.bonesUITestTemplateFileName = 'bones_ui_test.html.tpl'})
    : args = args ?? <String>[],
      bonesUICompiler = BonesUICompiler(compileDir: compileDir) {
  var args = this.args.toList();

  bonesUiTestConfigFile =
      File(pack_path.join(bonesUICompileDir.path, bonesUITestConfigFileName));

  var argHeadless = args.remove('--headless');
  var argShowUI = args.remove('--show-ui');

  var argEnableDeferredLibraries =
      args.remove('--enable-deferred-libraries') ||
          args.remove('--enable-deferred-library');
  var argDisableDeferredLibraries =
      args.remove('--disable-deferred-libraries') ||
          args.remove('--disable-deferred-library');

  String? logDir;
  {
    var idx = args.indexOf('--log-dir');
    if (idx < 0) {
      idx = args.indexOf('--log-directory');
    }

    if (idx >= 0) {
      args.removeAt(idx);
      var dir = args.removeAt(idx);
      dir = pack_path.normalize(dir.trim());
      if (dir.isNotEmpty) {
        logDir = dir;
      }
    }
  }

  showUI = argShowUI && !argHeadless;

  if (argDisableDeferredLibraries) {
    enableDeferredLibraries = false;
  } else if (argEnableDeferredLibraries) {
    enableDeferredLibraries = true;
  } else {
    //enableDeferredLibraries = null;

    // Disabled by default due issue:
    // https://github.com/dart-lang/test/issues/2088
    enableDeferredLibraries = false;
  }

  logDirectory = logDir != null ? Directory(logDir) : null;

  var configuration =
      args.isNotEmpty ? Configuration.parse(args) : Configuration.empty;

  try {
    if (File(configuration.configurationPath).existsSync()) {
      var fileConfiguration =
          Configuration.load(configuration.configurationPath);

      configuration = fileConfiguration.merge(configuration);
    }
  } catch (_) {}

  parsedArgs = configuration;
}