Constructs a new `Spec` reporter instance.

@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options
771601
function Spec(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var indents = 0;
  var n = 0;

  function indent() {
    return Array(indents).join('  ');
  }

  runner.on(EVENT_RUN_BEGIN, function() {
    console.log();
  });

  runner.on(EVENT_SUITE_BEGIN, function(suite) {
    ++indents;
    console.log(color('suite', '%s%s'), indent(), suite.title);
  });

  runner.on(EVENT_SUITE_END, function() {
    --indents;
    if (indents === 1) {
      console.log();
    }
  });

  runner.on(EVENT_TEST_PENDING, function(test) {
    var fmt = indent() + color('pending', '  - %s');
    console.log(fmt, test.title);
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    var fmt;
    if (test.speed === 'fast') {
      fmt =
        indent() +
        color('checkmark', '  ' + Base.symbols.ok) +
        color('pass', ' %s');
      console.log(fmt, test.title);
    } else {
      fmt =
        indent() +
        color('checkmark', '  ' + Base.symbols.ok) +
        color('pass', ' %s') +
        color(test.speed, ' (%dms)');
      console.log(fmt, test.title, test.duration);
    }
  });

  runner.on(EVENT_TEST_FAIL, function(test) {
    console.log(indent() + color('fail', '  %d) %s'), ++n, test.title);
  });

  runner.once(EVENT_RUN_END, self.epilogue.bind(self));
}
281023
function Base(runner) {
  var self = this
    , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
    , failures = this.failures = [];

  if (!runner) return;
  this.runner = runner;

  runner.stats = stats;

  runner.on('start', function(){
    stats.start = new Date;
  });

  runner.on('suite', function(suite){
    stats.suites = stats.suites || 0;
    suite.root || stats.suites++;
  });

  runner.on('test end', function(test){
    stats.tests = stats.tests || 0;
    stats.tests++;
  });

  runner.on('pass', function(test){
    stats.passes = stats.passes || 0;

    var medium = test.slow() / 2;
    test.speed = test.duration > test.slow()
      ? 'slow'
      : test.duration > medium
        ? 'medium'
        : 'fast';

    stats.passes++;
  });

  runner.on('fail', function(test, err){
    stats.failures = stats.failures || 0;
    stats.failures++;
    test.err = err;
    failures.push(test);
  });

  runner.on('end', function(){
    stats.end = new Date;
    stats.duration = new Date - stats.start;
  });

  runner.on('pending', function(){
    stats.pending++;
  });
}
141007
function() {
        var self = this, tests = this.tests;

        function runInstanceWith(url) {
            return function() {
                self._runInstance(url);
            };
        }

        for(var test in tests) {
            this._addRunner(runInstanceWith(this.getTestURL(test)));
        }

        if(this.queue.length) this._runNext();
        else this.emit('complete', this.TestStatusEnum.PASS);
    }
306627
function Doc(runner) {
  Base.call(this, runner);

  var self = this
    , stats = this.stats
    , total = runner.total
    , indents = 2;

  function indent() {
    return Array(indents).join('  ');
  }

  runner.on('suite', function(suite){
    if (suite.root) return;
    ++indents;
    console.log('%s<section class="suite">', indent());
    ++indents;
    console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
    console.log('%s<dl>', indent());
  });

  runner.on('suite end', function(suite){
    if (suite.root) return;
    console.log('%s</dl>', indent());
    --indents;
    console.log('%s</section>', indent());
    --indents;
  });

  runner.on('pass', function(test){
    console.log('%s  <dt>%s</dt>', indent(), utils.escape(test.title));
    var code = utils.escape(utils.clean(test.fn.toString()));
    console.log('%s  <dd><pre><code>%s</code></pre></dd>', indent(), code);
  });
}
1312119
function Cobertura(runner) {
	var jade = require('jade')
	jade.doctypes.cobertura = '<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">'
	var file = __dirname + '/templates/cobertura.jade', 
	str = fs.readFileSync(file, 'utf8'), 
	fn = jade.compile(str, { filename: file }), 
	self = this

	JSONCov.call(this, runner, false)

	runner.on('end', 
	function(){
		self.cov.src = __dirname.split('node_modules')[0]
		process.stdout.write(fn({
			cov: self.cov
		}))
	})
}
679990
function() {
    //// SpecReporter
    //var SpecReporter = require('jasmine-spec-reporter');
    //jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'}));
    //// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));

    // debugging
    // console.log('browser.params:' + JSON.stringify(browser.params));
    jasmine.getEnv().addReporter(new Reporter( browser.params )) ;

    global.sendKeys = sendKeys;

    // Allow changing bootstrap mode to NG1 for upgrade tests
    global.setProtractorToNg1Mode = function() {
      browser.useAllAngular2AppRoots = false;
      browser.rootEl = 'body';
    };
  }
91854
def run_specs(options = nil)
      options ||= {}
      files = options.fetch(:files, 'spec')
      rspec_options = options.fetch(:options, '--color')
      # We need to override the gemfile explicitely, since we have a default Gemfile in the project root
      gemfile = options.fetch(:gemfile, Gemika::Env.gemfile)
      fatal = options.fetch(:fatal, true)
      runner = binary(:gemfile => gemfile)
      bundle_exec = options.fetch(:bundle_exec) ? 'bundle exec' : nil
      command = [bundle_exec, runner, rspec_options, files].compact.join(' ')
      result = shell_out(command)
      if result
        true
      elsif fatal
        raise RSpecFailed, "RSpec failed: #{command}"
      else
        false
      end
    end
199939
function Resource(spec, options) {
  if (!(this instanceof Resource)) {
    return new Resource(spec, options);
  }

  if (typeof spec !== 'object') {
    throw new Error('resource spec must be an object');
  }

  debug('create resource %s', spec.path, spec);

  this.spec = spec;
  this.list = [];
  this.options = options || {};

  this.middleware = {};
  this.operations = {};
}
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);
	}
}
810166
function specToWatcherObj (watcherInstance, spec, options) {
  const dest = options.dest
  return new Promise((resolve, reject) => {
    const watcher = chokidar.watch(spec.files, {cwd: options.dir})
      .on('ready', () => {
        resolve({
          watcher: watcher,
          spec: spec
        })
      })
      .on('error', (err) => reject(err))
      .on('add', (path) => watcherInstance.emit('add', fileOptions.createFileUsingSpec(path, spec, dest)))
      .on('change', (path) => watcherInstance.emit('change', fileOptions.createFileUsingSpec(path, spec, dest)))
      .on('unlink', (path) => watcherInstance.emit('remove', fileOptions.createFileUsingSpec(path, spec, dest)))
  })
}
381174
function Gas (runner, options) {

  if (!(web3.currentProvider.connection || web3.currentProvider.host)) {
    console.log('the provider use for the test does not support synchronous call but eth-gas-reporter requires it \n falling back on the Spec reporter');
    mocha.reporters.Spec.call(this, runner);
    return;
  }
  Base.call(this, runner);

  const self = this
  let indents = 0
  let n = 0
  let failed = false;
  let startBlock
  let deployStartBlock
  let methodMap
  let deployMap
  let contractNameFromCodeHash;

  // Load config / keep .ethgas.js for backward compatibility
  let config;
  if (options && options.reporterOptions){
    config = options.reporterOptions
  } else {
    config = reqCwd.silent('./.ethgas.js') || {}
  }

  config.src = config.src || 'contracts'; // default contracts folder
  // TODO grab the contract srcpath from truffle / truffle config ?

  // Start getting this data when the reporter loads.
  stats.getGasAndPriceRates(config);

  // ------------------------------------  Helpers -------------------------------------------------
  const indent = () => Array(indents).join('  ')

  const methodAnalytics = (methodMap) => {
    let gasUsed = 0
    const endBlock = sync.blockNumber();

    while (startBlock <= endBlock) {
      let block = sync.getBlockByNumber(startBlock);

      if (block) {
        // Add to running tally for this test
        gasUsed += parseInt(block.gasUsed, 16);

        // Compile per method stats
        methodMap && block.transactions.forEach(tx => {
          const transaction = sync.getTransactionByHash(tx);
          const receipt = sync.getTransactionReceipt(tx);

          // Don't count methods that throw
          const threw = parseInt(receipt.status) === 0 || receipt.status === false;
          if (threw) return

          const code = sync.getCode(transaction.to);
          const hash = sha1(code);
          let contractName = contractNameFromCodeHash[hash];

          // Handle cases where we don't have a deployment record for the contract
          // or where we *do* (from migrations) but tx actually interacts with a
          // proxy / something doesn't match.
          let isProxied = false;

          if (contractName) {
            let candidateId = stats.getMethodID(contractName, transaction.input)
            isProxied = !methodMap[candidateId]
          }

          // If unfound, search by fnHash alone instead of contract_fnHash
          if (!contractName || isProxied ) {
            let key = transaction.input.slice(2, 10);
            let matches = Object.values(methodMap).filter(el => el.key === key);

            if (matches.length >= 1) {
              contractName = matches[0].contract;
            }
          }

          const id = stats.getMethodID(contractName, transaction.input)

          if (methodMap[id]) {
            methodMap[id].gasData.push(parseInt(receipt.gasUsed, 16))
            methodMap[id].numberOfCalls++
          }
        })
      }
      startBlock++
    }
    return gasUsed
  }

  const deployAnalytics = (deployMap) => {
    const endBlock = sync.blockNumber();

    while (deployStartBlock <= endBlock) {
      let block = sync.getBlockByNumber(deployStartBlock);

      block && block.transactions.forEach(tx => {
        const receipt = sync.getTransactionReceipt(tx);
        const threw = parseInt(receipt.status) === 0 || receipt.status === false;

        if (receipt.contractAddress && !threw) {
          const transaction = sync.getTransactionByHash(tx)

          const matches = deployMap.filter(contract => {
            return stats.matchBinaries(transaction.input, contract.binary);
          })

          if(matches && matches.length){
            const match = matches.find(item => item.binary !== '0x');

            if (match) {
              // We have to get code that might be linked here in
              // in order to match correctly at the method ids
              const code = sync.getCode(receipt.contractAddress);
              const hash = sha1(code);

              match.gasData.push(parseInt(receipt.gasUsed, 16));
              contractNameFromCodeHash[hash] = match.name;
            }
          }
        }
      })
      deployStartBlock++
    }
  }

  // ------------------------------------  Runners -------------------------------------------------
  runner.on('start', () => {
    ({ methodMap, deployMap, contractNameFromCodeHash } = stats.mapMethodsToContracts(artifacts, config.src))
  })

  runner.on('suite', suite => {
    ++indents
    log(color('suite', '%s%s'), indent(), suite.title)
  })

  runner.on('suite end', () => {
    --indents
    if (indents === 1) {
      log()
    }
  })

  runner.on('pending', test => {
    let fmt = indent() + color('pending', '  - %s')
    log(fmt, test.title)
  })

  runner.on('test', () => { deployStartBlock = sync.blockNumber() })

  runner.on('hook end', () => { startBlock = sync.blockNumber() + 1 })

  runner.on('pass', test => {
    let fmt
    let fmtArgs
    let gasUsedString
    deployAnalytics(deployMap)
    let gasUsed = methodAnalytics(methodMap)
    let showTimeSpent = config.showTimeSpent || false
    let timeSpentString = color(test.speed, '%dms')
    let consumptionString
    if (gasUsed) {
      gasUsedString = color('checkmark', '%d gas')

      if (showTimeSpent) {
        consumptionString = ' (' + timeSpentString + ', ' + gasUsedString + ')'
        fmtArgs = [test.title, test.duration, gasUsed]
      } else {
        consumptionString = ' (' + gasUsedString + ')'
        fmtArgs = [test.title, gasUsed]
      }

      fmt = indent() +
      color('checkmark', '  ' + Base.symbols.ok) +
      color('pass', ' %s') +
      consumptionString
    } else {
      if (showTimeSpent) {
        consumptionString = ' (' + timeSpentString + ')'
        fmtArgs = [test.title, test.duration]
      } else {
        consumptionString = ''
        fmtArgs = [test.title]
      }

      fmt = indent() +
        color('checkmark', '  ' + Base.symbols.ok) +
        color('pass', ' %s') +
        consumptionString
    }
    log.apply(null, [fmt, ...fmtArgs])
  })

  runner.on('fail', test => {
    failed = true;
    let fmt = indent() + color('fail', '  %d) %s')
    log()
    log(fmt, ++n, test.title)
  })

  runner.on('end', () => {
    stats.generateGasStatsReport(methodMap, deployMap, contractNameFromCodeHash)
    self.epilogue()
  });
}
1193641
def run_suite(self):
        '''
        
        '''
        if not self.phantomjs_runner:
            raise JsTestException('phantomjs_runner need to be defined')

        url = self.get_url()

        self.phantomjs(self.phantomjs_runner, url, title=self.title)
        self.cleanup()
1069709
function List(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var n = 0;

  runner.on(EVENT_RUN_BEGIN, function() {
    console.log();
  });

  runner.on(EVENT_TEST_BEGIN, function(test) {
    process.stdout.write(color('pass', '    ' + test.fullTitle() + ': '));
  });

  runner.on(EVENT_TEST_PENDING, function(test) {
    var fmt = color('checkmark', '  -') + color('pending', ' %s');
    console.log(fmt, test.fullTitle());
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    var fmt =
      color('checkmark', '  ' + Base.symbols.ok) +
      color('pass', ' %s: ') +
      color(test.speed, '%dms');
    cursor.CR();
    console.log(fmt, test.fullTitle(), test.duration);
  });

  runner.on(EVENT_TEST_FAIL, function(test) {
    cursor.CR();
    console.log(color('fail', '  %d) %s'), ++n, test.fullTitle());
  });

  runner.once(EVENT_RUN_END, self.epilogue.bind(self));
}
1245195
def template_runner(client, parser, args):
    """"""
    if args.builtin_list:
        aomi.template.builtin_list()
    elif args.builtin_info:
        aomi.template.builtin_info(args.builtin_info)
    elif args.template and args.destination and args.vault_paths:
        aomi.render.template(client, args.template,
                             args.destination,
                             args.vault_paths,
                             args)
    else:
        parser.print_usage()
        sys.exit(2)

    sys.exit(0)
982368
function Runner(conf) {
  component.Component.call(this, 'runner', conf);
  var that = this;
  this._default_controller = defaults.controllerfuncname(conf);
  this._dbconn = conf.dbconn;
  this.registerGearman(conf.servers, { client: true });
  this.on('connect', function() {
    that.startPolling();
  });
  this.on('disconnect', function() {
    if (that.db_poll_stop)
      that.db_poll_stop();
  });
}
501825
function Progress(runner, options) {
  Base.call(this, runner, options);

  var self = this;
  var width = (Base.window.width * 0.5) | 0;
  var total = runner.total;
  var complete = 0;
  var lastN = -1;

  // default chars
  options = options || {};
  var reporterOptions = options.reporterOptions || {};

  options.open = reporterOptions.open || '[';
  options.complete = reporterOptions.complete || '▬';
  options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
  options.close = reporterOptions.close || ']';
  options.verbose = reporterOptions.verbose || false;

  // tests started
  runner.on(EVENT_RUN_BEGIN, function() {
    console.log();
    cursor.hide();
  });

  // tests complete
  runner.on(EVENT_TEST_END, function() {
    complete++;

    var percent = complete / total;
    var n = (width * percent) | 0;
    var i = width - n;

    if (n === lastN && !options.verbose) {
      // Don't re-render the line if it hasn't changed
      return;
    }
    lastN = n;

    cursor.CR();
    process.stdout.write('\u001b[J');
    process.stdout.write(color('progress', '  ' + options.open));
    process.stdout.write(Array(n).join(options.complete));
    process.stdout.write(Array(i).join(options.incomplete));
    process.stdout.write(color('progress', options.close));
    if (options.verbose) {
      process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
    }
  });

  // tests are complete, output some stats
  // and the failures if any
  runner.once(EVENT_RUN_END, function() {
    cursor.show();
    console.log();
    self.epilogue();
  });
}
337740
function GherkinSpec(runner) {
  Base.call(this, runner);

  let indents = 0;
  let n       = 0;

  if (!Base.useColors) {
    colors.enabled = false;
  }

  function indent() {
    return Array(indents).join('  ');
  }

  runner.on('start', () => {
    console.log();
  });

  runner.on('suite', (suite) => {
    indents += 1;

    let text = suite.title;
    switch (suite.name) {
      case 'Feature':
        text = colors.underline.bold(suite.title);
        suite.stories.forEach((story) => {
          text += `\n${indent()}  ${story}`;
        });
        break;
      case 'Scenario':
        text = colors.green(suite.title);
        break;
      default:
        text = Base.color('suite', text);
    }
    console.log(indent() + text);
  });

  runner.on('suite end', () => {
    indents -= 1;
    if (indents === 1) {
      console.log();
    }
  });

  runner.on('pending', (test) => {
    console.log(`${indent()}  ${colors.cyan(`- ${test.title}`)}`);
  });

  runner.on('pass', (test) => {
    let fmt = indent() + colors.green(`  ${Base.symbols.ok} %s`);
    if (test.speed === 'fast') {
      cursor.CR();
      console.log(fmt, test.title);
    } else {
      fmt += Base.color(test.speed, ' (%dms)');
      cursor.CR();
      console.log(fmt, test.title, test.duration);
    }
  });

  runner.on('fail', (test) => {
    cursor.CR();
    n += 1;
    console.log(`${indent()}  ${colors.red('%d) %s')}`, n, test.title);
  });

  runner.on('end', this.epilogue.bind(this));
}