Initialize a new `XUnit` reporter.

@param {Runner} runner
@api public
164448
function XUnit(runner) {
  Base.call(this, runner);
  var stats = this.stats
    , tests = []
    , self = this;

  runner.on('pass', function(test){
    tests.push(test);
  });
  
  runner.on('fail', function(test){
    tests.push(test);
  });

  runner.on('end', function(){
    console.log(tag('testsuite', {
        name: 'Mocha Tests'
      , tests: stats.tests
      , failures: stats.failures
      , errors: stats.failures
      , skip: stats.tests - stats.failures - stats.passes
      , timestamp: (new Date).toUTCString()
      , time: stats.duration / 1000
    }, false));

    tests.forEach(test);
    console.log('</testsuite>');    
  });
}
1167243
function init(theConfig) {
        exports.config = theConfig;

        Inspector.on("error", _onError);
        Inspector.Inspector.on("detached", _onDetached);

        // Only listen for styleSheetAdded
        // We may get interim added/removed events when pushing incremental updates
        CSSAgent.on("styleSheetAdded.livedev", _styleSheetAdded);

        MainViewManager
            .on("currentFileChange", _onFileChanged);
        DocumentManager
            .on("documentSaved", _onDocumentSaved)
            .on("dirtyFlagChange", _onDirtyFlagChange);
        ProjectManager
            .on("beforeProjectClose beforeAppClose", close);

        // Initialize exports.status
        _setStatus(STATUS_INACTIVE);
    }
657399
function runner(options, callback) {
	// call CommonJS module
	var analyzerOpts = {
		'noOffenders': options.noOffenders,
		'preprocessor': false,
	};

	function analyze(css) {
		new analyzer(css, analyzerOpts, callback);
	}

	if (options.url) {
		debug('Fetching remote CSS file: %s', options.url);

		// @see https://www.npmjs.com/package/node-fetch#options
		var agentOptions = {},
			requestOptions = {
				url: options.url,
				headers: {
					'User-Agent': getUserAgent()
				}
			};

		// handle options

		// @see https://github.com/bitinn/node-fetch/issues/15
		// @see https://nodejs.org/api/https.html#https_https_request_options_callback
		if (options.ignoreSslErrors) {
			agentOptions.rejectUnauthorized = false;
		}

		// @see https://gist.github.com/cojohn/1772154
		if (options.authUser && options.authPass) {
			requestOptions.headers.Authorization = "Basic " + new Buffer(options.authUser + ":" + options.authPass, "utf8").toString("base64");
		}

		// @see https://nodejs.org/api/http.html#http_class_http_agent
		var client = require(/^https:/.test(options.url) ? 'https' : 'http');
		requestOptions.agent = new client.Agent(agentOptions);

		// @see http://stackoverflow.com/a/5810547
		options.proxy = options.proxy || process.env.HTTP_PROXY;

		if (options.proxy) {
			debug('Using HTTP proxy: %s', options.proxy);

			requestOptions.agent = new(require('http-proxy-agent'))(options.proxy);
		}

		request(requestOptions, function(err, css) {
			if (err) {
				err.code = analyzer.EXIT_URL_LOADING_FAILED;

				debug(err);
				callback(err);
			} else {
				analyze(css);
			}
		});
	} else if (options.file) {
		// resolve to the full path
		options.file = resolve(process.cwd(), options.file);
		debug('Loading local CSS file: %s', options.file);

		fs.readFile(options.file, {
			encoding: 'utf-8'
		}, function(err, css) {
			if (err) {
				err = new Error('Loading CSS file failed: ' + err.toString());
				err.code = analyzer.EXIT_FILE_LOADING_FAILED;

				debug(err);
				callback(err);
			} else {
				// find the matching preprocessor and use it
				if (analyzerOpts.preprocessor === false) {
					analyzerOpts.preprocessor = preprocessors.findMatchingByFileName(options.file);
				}

				// pass the name of the file being analyzed
				analyzerOpts.file = options.file;

				analyze(css);
			}
		});
	} else if (options.stdin) {
		debug('Reading from stdin');
		cli.withStdin(analyze);
	}
}
519811
@Override
	public void initialize(IAggregator aggregator, IAggregatorExtension extension,
			IExtensionRegistrar registrar) {
		final String sourceMethod = "initialize"; //$NON-NLS-1$
		final boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceMethod, sourceMethod, new Object[]{aggregator, extension});
		}
		this.aggregator = aggregator;
		isSkipResourceConversion.set(false);

		// Get the transformer javascript resource from init-params
		String xformerUri = extension.getInitParams().getValue(JSXTRANSFORMER_NAME);
		if (xformerUri == null) {
			throw new IllegalStateException("Missing transformer init-param"); //$NON-NLS-1$
		}
		try {
			xformerRes = aggregator.newResource(new URI(xformerUri));
		} catch (URISyntaxException e) {
			throw new RuntimeException(e);
		}
		if (!xformerRes.exists()) {
			throw new RuntimeException(new NotFoundException(xformerUri));
		}
		// Register a cache manager listener so that we can add our named cache after
		// the cache manager has been initialized.
		Dictionary<String,String> dict;
		dict = new Hashtable<String, String>();
		dict.put("name", aggregator.getName()); //$NON-NLS-1$
		cacheMgrListenerReg = aggregator.getPlatformServices().registerService(ICacheManagerListener.class.getName(), this, dict);

		if (ctorScopePoolSize > 0) {
			scopePoolSize = ctorScopePoolSize;
		} else {
			// Get the configured scope pool size
			if (extension != null) {
				scopePoolSize = TypeUtil.asInt(extension.getInitParams().getValue(SCOPE_POOL_SIZE_INITPARAM), DEFAULT_SCOPE_POOL_SIZE);
				// If jsx options have been specified, use them
				String options = extension.getInitParams().getValue(JSX_OPTIONS_INITPARAM);
				if (options != null && options.length() > 0) {
					jsxOptions = options;
				}
			}
		}
		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod);
		}
	}
222379
public Result run(Runner runner) {
        Result result = new Result();
        RunListener listener = result.createListener();
        notifier.addFirstListener(listener);
        try {
            notifier.fireTestRunStarted(runner.getDescription());
            runner.run(notifier);
            notifier.fireTestRunFinished(result);
        } finally {
            removeListener(listener);
        }
        return result;
    }
646662
private static ScriptRunner getRunner() throws IOException {
		if (sharedRunner.get() == null) {
			//create JavaScript runner
			ScriptRunner runner = ScriptRunnerFactory.createRunner();
			
			//load bundled scripts
			try {
				runner.loadScript(CSL.class.getResource("dump.js"));
				runner.loadScript(CSL.class.getResource("citeproc.js"));
				runner.loadScript(CSL.class.getResource("formats.js"));
				runner.loadScript(CSL.class.getResource("loadsys.js"));
			} catch (ScriptRunnerException e) {
				//should never happen because bundled JavaScript files
				//should be OK indeed
				throw new RuntimeException("Invalid bundled javascript file", e);
			}
			
			sharedRunner.set(runner);
		}
		return sharedRunner.get();
	}
738724
function init(generator, config, logger) {
        _generator = generator;
        _config = config;
        _logger = logger;

        _documentManager = new DocumentManager(generator, config, logger);
        _stateManager = new StateManager(generator, config, logger, _documentManager);
        _renderManager = new RenderManager(generator, config, logger);

        if (!!_config["css-enabled"]) {
            var SONToCSS = require("./lib/css/sontocss.js");
            _SONToCSSConverter = new SONToCSS(generator, config, logger, _documentManager);
        }

        // For automated tests
        exports._renderManager = _renderManager;
        exports._stateManager = _stateManager;
        exports._assetManagers = _assetManagers;
        exports._layerNameParse = require("./lib/parser").parse;

        _stateManager.on("enabled", _startAssetGeneration);
        _stateManager.on("disabled", _pauseAssetGeneration);
        _documentManager.on("openDocumentsChanged", _handleOpenDocumentsChanged);

        Headlights.init(generator, logger, _stateManager, _renderManager);
    }
392403
function initProfiler(name) {
        checkInit();
        var profiler = profilerInstances[name];
        if (profiler === void 0) {
            profilerInstances[name] = profiler = new Profiler(name, "ms");
            container.appendChild(profiler.widget.element);
        }
    }
524638
function(configFile, additionalConfig) {

  var runnerErrorCount = 0; 

  var configParser = new ConfigParser();
  if (configFile) {
    configParser.addFileConfig(configFile);
  }
  if (additionalConfig) {
    configParser.addConfig(additionalConfig);
  }
  var config = configParser.getConfig();
  var scheduler = new TaskScheduler(config);

  /**
   * A fork of a runner for running a specified task. The RunnerFork will
   * start a new process that calls on '/runFromLauncher.js' and report the
   * result to a reporter.
   *
   * @constructor
   * @param {object} task Task to run.
   */
  var RunnerFork = function(task) {
    this.capability = task.capability;
    this.specs = task.specs;
    this.process = child.fork(
      __dirname + '/runFromLauncher.js',
      process.argv.slice(2), {
        cwd: process.cwd(),
        silent: true
      }
    );
    this.reporter = reporter.addTaskReporter(task, this.process.pid);
  };

  /**
   * Add handlers for the RunnerFork for events like stdout, stderr, testsDone,
   * testPass, testFail, error, and exit. Optionally, you can pass in a 
   * callback function to be called when a test completes.
   *
   * @param {function()} testsDoneCallback Callback function for testsDone events.
   */
  RunnerFork.prototype.addEventHandlers = function(testsDoneCallback) {
    var self = this;

    // stdout pipe
    this.process.stdout.on('data', function(chunk) {
      self.reporter.logStdout(chunk);
    });

    // stderr pipe
    this.process.stderr.on('data', function(chunk) {
      self.reporter.logStderr(chunk);
    });

    this.process.on('message', function(m) {
      switch (m.event) {
        case 'testPass':
          process.stdout.write('.');
          break;
        case 'testFail':
          process.stdout.write('F');
          break;
        case 'testsDone':
          self.reporter.testsDone(m.failedCount);
          break;
      }
    });

    this.process.on('error', function(err) {
      self.reporter.flush();
      log_('Runner Process(' + self.process.pid + ') Error: ' + err);
      runnerErrorCount += 1;
    });

    this.process.on('exit', function(code) {
      self.reporter.flush();
      if (code) {
        log_('Runner Process Exited With Error Code: ' + code);
        runnerErrorCount += 1;
      }
      self.reporter.exitCode = code;
      if (typeof testsDoneCallback === 'function') {
        testsDoneCallback();
      }
      log_(scheduler.countActiveTasks() + 
        ' instance(s) of WebDriver still running');
    }); 
  };

  /**
   * Sends the run command.
   */
  RunnerFork.prototype.run = function() {
    this.process.send({
      command: 'run',
      configFile: configFile,
      additionalConfig: additionalConfig,
      capability: this.capability,
      specs: this.specs
    });
    this.reporter.reportHeader_();
  };

  // Don't start new process if there is only 1 task.
  var totalTasks = scheduler.numTasksRemaining(); 
  if (totalTasks === 1) {
    var Runner = require('./runner');
    var task = scheduler.nextTask();
    config.capabilities = task.capability; 
    config.specs = task.specs;

    var runner = new Runner(config);
    runner.run().then(function(exitCode) {
      process.exit(exitCode);
    }).catch(function(err) {
      log_('Error: ' + err.message);
      process.exit(1);
    });
  } else {
    if (config.debug) {
      throw new Error('Cannot run in debug mode with ' + 
        'multiCapabilities, count > 1, or sharding');
    }
    for (var i = 0; i < scheduler.maxConcurrentTasks(); ++i) {
      var createNextRunnerFork = function() {
        var task = scheduler.nextTask();
        if (task) {
          var done = function() {
            task.done();
            createNextRunnerFork();
          };
          var runnerFork = new RunnerFork(task);
          runnerFork.addEventHandlers(done);
          runnerFork.run();
        }
      };
      createNextRunnerFork();
    }
    log_('Running ' + scheduler.countActiveTasks() + ' instances of WebDriver');

    process.on('exit', function(code) {
      if (code) {
        log_('Process exited with error code ' + code);
        process.exit(code);
      } else if (runnerErrorCount > 0) {
        reporter.reportSummary();
        process.exit(RUNNERS_FAILED_EXIT_CODE);
      } else {
        if (scheduler.numTasksRemaining() > 0) {
          throw new Error('BUG: launcher exited with ' + 
              scheduler.numTasksRemaining() + ' tasks remaining');
        }
        reporter.reportSummary();
        process.exit(0);
      }
    });
  }
}
1309697
function NyanCat(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var width = (Base.window.width * 0.75) | 0;
  var nyanCatWidth = (this.nyanCatWidth = 11);

  this.colorIndex = 0;
  this.numberOfLines = 4;
  this.rainbowColors = self.generateColors();
  this.scoreboardWidth = 5;
  this.tick = 0;
  this.trajectories = [[], [], [], []];
  this.trajectoryWidthMax = width - nyanCatWidth;

  runner.on(EVENT_RUN_BEGIN, function() {
    Base.cursor.hide();
    self.draw();
  });

  runner.on(EVENT_TEST_PENDING, function() {
    self.draw();
  });

  runner.on(EVENT_TEST_PASS, function() {
    self.draw();
  });

  runner.on(EVENT_TEST_FAIL, function() {
    self.draw();
  });

  runner.once(EVENT_RUN_END, function() {
    Base.cursor.show();
    for (var i = 0; i < self.numberOfLines; i++) {
      write('\n');
    }
    self.epilogue();
  });
}
1007566
private void initReporter() {
    String reporterType =
      System.getProperty("net.spy.metrics.reporter.type", DEFAULT_REPORTER_TYPE);
    String reporterInterval =
      System.getProperty("net.spy.metrics.reporter.interval", DEFAULT_REPORTER_INTERVAL);
    String reporterDir =
      System.getProperty("net.spy.metrics.reporter.outdir", DEFAULT_REPORTER_OUTDIR);

    if(reporterType.equals("console")) {
      final ConsoleReporter reporter = ConsoleReporter.forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.SECONDS)
        .build();
      reporter.start(Integer.parseInt(reporterInterval), TimeUnit.SECONDS);
    } else if (reporterType.equals("jmx")) {
      final JmxReporter reporter = JmxReporter.forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.SECONDS)
        .build();
      reporter.start();
    } else if (reporterType.equals("csv")) {
      final CsvReporter reporter = CsvReporter.forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.SECONDS)
        .build(new File(reporterDir));
      reporter.start(Integer.parseInt(reporterInterval), TimeUnit.SECONDS);
    } else if (reporterType.equals("slf4j")) {
      final Slf4jReporter reporter = Slf4jReporter.forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.SECONDS)
        .outputTo(LoggerFactory.getLogger(MetricCollector.class))
        .build();
      reporter.start(Integer.parseInt(reporterInterval), TimeUnit.SECONDS);
    } else {
        throw new IllegalStateException("Unknown Metrics Reporter Type: " + reporterType);
    }
  }
555276
function ForwardMochaReporter(mochaRunner, options) {
    Base.call(this, mochaRunner, options);
    forwardEvent(mochaRunner, runner, 'start');
    forwardEvent(mochaRunner, runner, 'suite');
    forwardEvent(mochaRunner, runner, 'suite end');
    forwardEvent(mochaRunner, runner, 'pending');
    forwardEvent(mochaRunner, runner, 'pass');
    forwardEvent(mochaRunner, runner, 'fail');
    // when runner output should be captured, it is done for the end event only.
    mochaRunner.on('end', function () {
        try {
            if (outputFile) {
                console.log(outputFile);
                captureStdout(outputFile);
            }
            var args = Array.prototype.slice.call(arguments, 0);
            runner.emit.apply(runner, ['end'].concat(args));
            releaseStdout();
        } catch (e) {
            releaseStdout();
        }
    });
  }
617793
function _doLaunchAfterServerReady(initialDoc) {
        // update status
        _setStatus(STATUS_CONNECTING);
        _createLiveDocumentForFrame(initialDoc);

        // start listening for requests
        _server.start();

        // Install a one-time event handler when connected to the launcher page
        Inspector.one("connect", _onConnect);

        // open browser to the interstitial page to prepare for loading agents
        _openInterstitialPage();

        // Once all agents loaded (see _onInterstitialPageLoad()), begin Live Highlighting for preprocessor documents
        _openDeferred.done(function () {
            // Setup activeEditorChange event listener so that we can track cursor positions in
            // CSS preprocessor files and perform live preview highlighting on all elements with
            // the current selector in the preprocessor file.
            EditorManager.on("activeEditorChange", onActiveEditorChange);

            // Explicitly trigger onActiveEditorChange so that live preview highlighting
            // can be set up for the preprocessor files.
            onActiveEditorChange(null, EditorManager.getActiveEditor(), null);
        });
    }
1089194
function Reporter(MochaReporter, coverage, root, reporterOptions) {
  if(typeof MochaReporter === 'string') {
    if(mocha.reporters[MochaReporter]) {
      MochaReporter = mocha.reporters[MochaReporter];
    } else {
      try {
        MochaReporter = require(MochaReporter);
      } catch (e) {
        throw new Error('reporter "' + MochaReporter + '" does not exist');
      }
    }
  }

  // The event emitter used to emit the final events
  var runner = this.runner = new EventEmitter();
  // A store (by data GUID) for the Mocha objects we created.
  // The handler for buffering simultaneous test runs
  this.buffers = new BufferManager(runner);
  // The actual (suite and test) objects we can feed to the Mocha runner
  this._mochaObjects = {};
  // The instantiated Mocha reporter
  this.reporter = new MochaReporter(runner, {reporterOptions: reporterOptions});
  // This is where we store errors so that we can report them all
  // at once at the end
  this.errors = [];
  // Options for reporting code coverage
  this.coverage = coverage;
  // Option for root path
  this.root = root;
}
690556
protected function setRunner()
	{
		$this->runner = new Runner;
		$this->runner->addPass(new MergePrefix);
		$this->runner->addPass(new GroupSingleCharacters);
		$this->runner->addPass(new Recurse($this->runner));
		$this->runner->addPass(new PromoteSingleStrings);
		$this->runner->addPass(new CoalesceOptionalStrings);
		$this->runner->addPass(new MergeSuffix);
		$this->runner->addPass(new CoalesceSingleCharacterPrefix);
	}
985943
function initialize() {
    var getRenderer = require( config.getRenderer ?
      path.join( './../../../', config.getRenderer ) :
      markedRenderer
    );
    var renderer = getRenderer( marked );
    filingCabinet = new FilingCabinet( config );

    readControls(
      config.controls,
      filingCabinet
    );
    readReferences(
      config.components,
      config.referenceFile,
      filingCabinet
    );
    readComponents(
      config.components,
      config.referenceFile,
      config.localeFile,
      config.layoutSegment,
      config.contentSegment,
      filingCabinet,
      renderer
    );
    readContents(
      config.contents,
      config.submenuFile,
      filingCabinet,
      renderer
    );

    logger.showInfo( '*** Validating elements...' );
    filingCabinet.finalize();
    logger.showInfo( '*** Content manager is initialized.' );

    contextFactory = new ContextFactory( config, filingCabinet );
  }
494286
function HTMLCov(runner) {
  var jade = require('jade')
    , file = __dirname + '/templates/coverage.jade'
    , str = fs.readFileSync(file, 'utf8')
    , fn = jade.compile(str, { filename: file })
    , self = this;

  JSONCov.call(this, runner, false);

  runner.on('end', function(){
    process.stdout.write(fn({
        cov: self.cov
      , coverageClass: coverageClass
    }));
  });
}