<commit_before>/*
  Provide support for running a nightwatch.js test
*/
var util = require("util");
var Q = require("q");
var _ = require("lodash");
var path = require("path");
var BaseTestrun = require("../../test_run");

var settings = require("../../settings");
var nightwatchConfigPath = path.normalize(settings.nightwatchConfigFilePath);
var rewriteNightwatchConfig = require("./rewrite_config");

var NightwatchTestrun = function (options) {
  BaseTestrun.call(this, options);

  // needed if sauce testing
  this.sauceSettings = options.sauceSettings;
  this.sauceBrowserSettings = options.sauceBrowserSettings;

  // needed if local testing
  this.seleniumPort = this.worker.portOffset + 1;

  // needed if you're using a mock
  this.mockingPort = this.worker.portOffset;

  this._createTemporaryConfigFile();
};

util.inherits(NightwatchTestrun, BaseTestrun);

  // clone a custom configuration just for this test run
NightwatchTestrun.prototype._createTemporaryConfigFile = function () {
  var sauceSettings;

  var nightwatchConfigOptions = {};

  if (this.sauceBrowserSettings) {
    sauceSettings = _.extend({}, this.sauceSettings);

    if (this.sauceSettings.useTunnels) {
      // The sauce worker allocator has a specific tunnelId for this sauce run,
      // we have to use it to avoid using the tunnels of adjacent workers.
      sauceSettings.tunnelId = this.worker.tunnelId;
    } else {
      delete sauceSettings.tunnelId;
    }

    nightwatchConfigOptions.sauceSettings = sauceSettings;
    nightwatchConfigOptions.sauceBrowserSettings = this.sauceBrowserSettings;
  } else {
    nightwatchConfigOptions.localSeleniumPort = this.seleniumPort; 
  }

  // throws exceptions
  this.configPath = rewriteNightwatchConfig(nightwatchConfigPath, this.tempAssetPath, nightwatchConfigOptions);
};

  // return the command line path to the test framework binary
NightwatchTestrun.prototype.getCommand = function () {
  return "./node_modules/nightwatch/bin/nightwatch";
};

  // return the environment
NightwatchTestrun.prototype.getEnvironment = function (env) {
  return _.extend({}, env);
};

NightwatchTestrun.prototype.getArguments = function () {
  var args = [
    "--mocking_port=" + this.mockingPort,
    // Nightwatch gets its sauce browser setting via a nightwatch configuration file
    // If we're not in sauce mode, we just pass in a browserId directly (i.e. phantomjs, chrome, firefox, etc)
    "--env=" + (this.sauceBrowserSettings ? "sauce" : this.test.browser.browserId),
    "--test=" + this.path,
    // NOTE: the --worker=1 argument tells magellan-nightwatch that it's in 
    // "worker mode" and should send IPC messages back to magellan.
    "--worker=1",
    "--config=" + this.configPath
  ];

  if (settings.aggregateScreenshots) {
    args.push("--screenshot_path=" + this.tempAssetPath);
  }

  if (this.debug) {
    args.push("--debug");
  }

  return args;
};

module.exports = NightwatchTestrun;<commit_msg>Passes --verbose flag in debug mode, resolves #38<commit_after>/*
  Provide support for running a nightwatch.js test
*/
var util = require("util");
var Q = require("q");
var _ = require("lodash");
var path = require("path");
var BaseTestrun = require("../../test_run");

var settings = require("../../settings");
var nightwatchConfigPath = path.normalize(settings.nightwatchConfigFilePath);
var rewriteNightwatchConfig = require("./rewrite_config");

var NightwatchTestrun = function (options) {
  BaseTestrun.call(this, options);

  // needed if sauce testing
  this.sauceSettings = options.sauceSettings;
  this.sauceBrowserSettings = options.sauceBrowserSettings;

  // needed if local testing
  this.seleniumPort = this.worker.portOffset + 1;

  // needed if you're using a mock
  this.mockingPort = this.worker.portOffset;

  this._createTemporaryConfigFile();
};

util.inherits(NightwatchTestrun, BaseTestrun);

  // clone a custom configuration just for this test run
NightwatchTestrun.prototype._createTemporaryConfigFile = function () {
  var sauceSettings;

  var nightwatchConfigOptions = {};

  if (this.sauceBrowserSettings) {
    sauceSettings = _.extend({}, this.sauceSettings);

    if (this.sauceSettings.useTunnels) {
      // The sauce worker allocator has a specific tunnelId for this sauce run,
      // we have to use it to avoid using the tunnels of adjacent workers.
      sauceSettings.tunnelId = this.worker.tunnelId;
    } else {
      delete sauceSettings.tunnelId;
    }

    nightwatchConfigOptions.sauceSettings = sauceSettings;
    nightwatchConfigOptions.sauceBrowserSettings = this.sauceBrowserSettings;
  } else {
    nightwatchConfigOptions.localSeleniumPort = this.seleniumPort; 
  }

  // throws exceptions
  this.configPath = rewriteNightwatchConfig(nightwatchConfigPath, this.tempAssetPath, nightwatchConfigOptions);
};

  // return the command line path to the test framework binary
NightwatchTestrun.prototype.getCommand = function () {
  return "./node_modules/nightwatch/bin/nightwatch";
};

  // return the environment
NightwatchTestrun.prototype.getEnvironment = function (env) {
  return _.extend({}, env);
};

NightwatchTestrun.prototype.getArguments = function () {
  var args = [
    "--mocking_port=" + this.mockingPort,
    // Nightwatch gets its sauce browser setting via a nightwatch configuration file
    // If we're not in sauce mode, we just pass in a browserId directly (i.e. phantomjs, chrome, firefox, etc)
    "--env=" + (this.sauceBrowserSettings ? "sauce" : this.test.browser.browserId),
    "--test=" + this.path,
    // NOTE: the --worker=1 argument tells magellan-nightwatch that it's in 
    // "worker mode" and should send IPC messages back to magellan.
    "--worker=1",
    "--config=" + this.configPath
  ];

  if (settings.aggregateScreenshots) {
    args.push("--screenshot_path=" + this.tempAssetPath);
  }

  if (this.debug) {
    args.push("--verbose");
  }

  return args;
};

module.exports = NightwatchTestrun;
{'fraction_non_alphanumeric': 0.11541049798115748, 'fraction_numerical': 0.0013458950201884253, 'mean_word_length': 3.9213576158940397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2879510', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1727, 'n_words': 456}