bundle up the test-running JS
765351
function createUnpackedBundle() {
  fs.mkdirp(unpackedDir, err => {
    if (err && err.code !== 'EEXIST') {
      console.log(err);
      throw err;
    }

    let unpackedFile = path.join(__dirname, 'unpacked.js');
    let b = browserify(unpackedFile).bundle();
    b.on('error', console.error);
    let unpackedBundleFile = path.join(unpackedDir, 'unpacked-bundle.js');
    const bundleFileStream = fs.createWriteStream(unpackedBundleFile);
    bundleFileStream.on('finish', () => {
      console.log('Wrote bundled JS into ' + unpackedBundleFile);
    });
    bundleFileStream.on('pipe', () => {
      console.log('Writing bundled JS...');
    });
    bundleFileStream.on('error', console.error);
    b.pipe(bundleFileStream);
    // bundleFileStream.end();  // do not do this prematurely!
  });
}
986079
function allJavascriptFiles() {
        return srcFiles().concat(otherJsFiles()).concat(unitTestFiles()).concat(unitTestHelperFiles()).concat(taskFiles()).concat(commonJsFiles());
    }
766311
def run(config, path=None, stop_on_error=True, just_tests=False):
    """"""
    if path is None:
        path = os.getcwd()
    prep(config, path=path)

    models = __import__('models')
    tests = __import__('tests')
    suites = __import__('suites')

    print('\n')
    for x in ['models', 'tests', 'suites']:
        module = __import__(x)
        assert hasattr(module, x), "'%s' module requires attribute '%s'" %\
                                   (x, x)

    if just_tests:
        for test in tests.tests:
            _run(test, models, stop_on_error)

    else:
        for suite in suites.suites:
            _run(suite, models, stop_on_error)
7542
function bundle(input, nc, options, complete) {
  const bundlePath = path.join(nc, 'lib', 'nexe.js');
  const mapfile = options.output + '.map';
  let ws = fs.createWriteStream(bundlePath);

  const igv = '__filename,__dirname,_process';
  let insertGlobalVars = { isNexe: true },
    wantedGlobalVars = igv.split(',');

  // parse insertGlobalVars.
  Object.keys(insertGlobals.vars).forEach(function(x) {
    if (wantedGlobalVars.indexOf(x) === -1) {
      insertGlobalVars[x] = undefined;
    }
  });

  let paths = [path.join(nc, 'lib')];

  if (options.browserifyPaths) {
    paths = paths.concat(options.browserifyPaths);
  }

  _log('executing browserify via API');
  let bproc = browserify([input], {
    debug: options.debug,
    commondir: false,
    paths: paths,
    builtins: false,
    insertGlobalVars: insertGlobalVars,
    detectGlobals: true,
    browserField: false,
  });

  if (options.browserifyExcludes && Array.isArray(options.browserifyExcludes)) {
    for (let i = 0; i < options.browserifyExcludes.length; i++) {
      let lib = options.browserifyExcludes[i];
      _log("Excluding '%s' from browserify bundle", lib);
      bproc.exclude(lib);
    }
  }

  // copy the excludes code for requires for now.
  if (options.browserifyRequires && Array.isArray(options.browserifyRequires)) {
    for (let i = 0; i < options.browserifyRequires.length; i++) {
      let lib = options.browserifyRequires[i];
      let name = lib.file || lib; // for  object format.
      // if `lib` is object then fetch all params without `file`
      // otherwise returns empty object
      let opts =
        (lib instanceof Object &&
          Object.keys(lib)
            .filter(key => key !== 'file')
            .reduce((acc, key) => {
              return (acc[key] = lib[key]), acc;
            }, {})) ||
        {};

      _log("Force including '%s' in browserify bundle", name);
      bproc.require(lib, opts);
    }
  }

  if (options.debug) {
    bproc.require(require.resolve('source-map-support'));
  }

  let bprocbun = bproc
    .bundle() // bundle
    .pipe(ws); // pipe to file

  // error on require errors, still can't contionue. ffs browserify
  bprocbun.on('error', function(err) {
    _log('error', '[browserify] ' + err);
  });

  ws.on('error', function(err) {
    console.log(err);
    _log('error', 'Failed to save stdout to disk');
    process.exit(1);
  });

  ws.on('close', function() {
    var source = fs.readFileSync(bundlePath, 'utf8');
    source = source.replace(/[^\x00-\x7F]/g, '');

    // write the source modified to nexe.js
    fs.writeFile(bundlePath, source, 'utf8', function(err) {
      if (err) {
        _log('error', 'failed to save source');
        process.exit(1);
      }

      complete();
    });
  });
}
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()
  });
}
1314425
def run(self):
        ''''''

        if subprocess.call(['npm', '--version']) != 0:
            raise RuntimeError('npm is required to build the HTML renderer.')

        self.check_call(['npm', 'install'], cwd=HTML_RENDERER_DIR)
        self.check_call(['npm', 'run', 'build'], cwd=HTML_RENDERER_DIR)

        self.copy_file(HTML_RENDERER_DIR+'/dist/js/app.js', 'pyinstrument/renderers/html_resources/app.js')

        setuptools.command.build_py.build_py.run(self)
411918
function bundlePureJS() {
    const SRC_PATH = path.join(__dirname, '..', config.dir.src, config.dir.script);

    // source
    const src = fs.readFileSync(path.join(SRC_PATH, config.main.basename + '.js')).toString();
    const bundleSrc = '\ufeff' + banner('.js', config.main.basename) + src
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
    ;
    fs.writeFileSync(path.join(DST_PATH, config.main.basename + '.js'), bundleSrc);

    // d.ts
    const dts = fs.readFileSync(path.join(SRC_PATH, config.main.bundle_d_ts)).toString();
    const bundleDTS = '\ufeff' + banner('.d.ts', config.main.basename) + dts
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
    ;
    if (!fs.existsSync(path.join(DST_PATH, config.dir.types))) {
        fs.mkdirSync(path.join(DST_PATH, config.dir.types));
    }
    fs.writeFileSync(path.join(DST_PATH, config.dir.types, config.main.bundle_d_ts), bundleDTS);
}
214891
def start
      suite = TestSuite.new
      testruns = @config.files.collect do |file|
        name = file.sub(Dir.pwd+'/','')
        suite.new_case(name, file)
      end
      test_loop_runner(suite)
    end
959141
function runAfterSuccessScripts() {
  const autorelease =
    pkg.version === '0.0.0-semantically-released' &&
    parseEnv('TRAVIS', false) &&
    process.env.TRAVIS_BRANCH === 'master' &&
    !parseEnv('TRAVIS_PULL_REQUEST', false)

  const reportCoverage = hasFile('coverage') && !parseEnv('SKIP_CODECOV', false)

  if (!autorelease && !reportCoverage) {
    console.log(
      'No need to autorelease or report coverage. Skipping travis-after-success script...',
    )
  } else {
    const result = spawn.sync(
      resolveBin('concurrently'),
      getConcurrentlyArgs(
        {
          codecov: reportCoverage
            ? `echo installing codecov && npx -p codecov@3 -c 'echo running codecov && codecov'`
            : null,
          release: autorelease
            ? `echo installing semantic-release && npx -p semantic-release@15 -c 'echo running semantic-release && semantic-release'`
            : null,
        },
        {killOthers: false},
      ),
      {stdio: 'inherit'},
    )

    process.exit(result.status)
  }
}
64081
function buildExampleScripts(dev) {

  var dest = EXAMPLE_DIST_PATH;

  var opts = dev ? watchify.args : {};
  opts.debug = dev ? true : false;
  opts.hasExports = true;

  return function() {

    var common = browserify(opts),
      bundle = browserify(opts).require('./' + SRC_PATH + '/' + PACKAGE_FILE, { expose: PACKAGE_NAME }),
      example = browserify(opts).exclude(PACKAGE_NAME).add('./' + EXAMPLE_SRC_PATH + '/' + EXAMPLE_APP);

    DEPENDENCIES.forEach(function(pkg) {
      common.require(pkg);
      bundle.exclude(pkg);
      example.exclude(pkg);
    });

    if (dev) {
      watchBundle(common, 'common.js', dest);
      watchBundle(bundle, 'bundle.js', dest);
      watchBundle(example, 'app.js', dest);
    }

    return merge(
      doBundle(common, 'common.js', dest),
      doBundle(bundle, 'bundle.js', dest),
      doBundle(example, 'app.js', dest)
    );

  }

}
807413
function bundleApp(codeList, ns, domload, compile, before, npmTree, o) {
  var l = []
    , usedBuiltIns = npmTree._builtIns
    , len = 0;
  delete npmTree._builtIns;

  // 1. construct the global namespace object
  l.push("window." + ns + " = {data:{}, path:{}};");

  // 2. attach path code to the namespace object so that require.js can efficiently resolve paths
  l.push('\n// include npm::path');
  var pathCode = read(join(builtInDir, 'path.posix.js'));
  l.push('(function (exports) {\n ' + pathCode + '\n}(window.' + ns + '.path));');

  // 3. pull in serialized data
  Object.keys(o.data).forEach(function (name) {
    return l.push(ns + ".data." + name + " = " + o.data[name] + ";");
  });

  // 4. attach require code
  var config = {
    namespace : ns
  , domains   : Object.keys(o.domains) // TODO: remove npm from here
  , arbiters  : o.arbiters
  , logging   : o.logLevel
  , npmTree   : npmTree
  , builtIns  : builtIns
  , slash     : '/' //TODO: figure out if different types can coexist, if so, determine in resolver, and on client
  };

  l.push(anonWrap(read(join(dir, 'require.js'))
    .replace(/VERSION/, JSON.parse(read(join(dir, '..', 'package.json'))).version)
    .replace(/REQUIRECONFIG/, JSON.stringify(config))
  ));

  // 5. include CommonJS compatible code in the order they have to be defined
  var defineWrap = function (exportName, domain, code) {
    return ns + ".define('" + exportName + "','" + domain + "',function (require, module, exports) {\n" + code + "\n});";
  };

  // 6. harvest function splits code into app and non-app code and defineWraps
  var harvest = function (onlyMain) {
    codeList.forEach(function (pair) {
      var dom = pair[0]
        , file = pair[1]
        , basename = file.split('.')[0];
      if ((dom === 'app') !== onlyMain) {
        return;
      }
      var code = before(compile(join(o.domains[dom], file)));
      l.push(defineWrap(basename, dom, code));
    });
  };

  // 7.a) include required builtIns
  l.push("\n// node builtins\n");
  len = l.length;
  usedBuiltIns.forEach(function (b) {
    if (b === 'path') { // already included
      return;
    }
    l.push(defineWrap(b, 'npm', read(join(builtInDir, b + '.js'))));
  });
  if (l.length === len) {
    l.pop();
  }

  // 7.b) include modules not on the app domain
  l.push("\n// shared code\n");
  len = l.length;
  harvest(false);
  if (l.length === len) {
    l.pop();
  }

  // 7.c) include modules on the app domain, and wait for domloader if set
  l.push("\n// app code - safety wrapped\n\n");
  domload(harvest(true));

  // 8. use a closure to encapsulate the private internal data and APIs
  return anonWrap(l.join('\n'));
}
532131
function bundleDTS() {
    const DST_PATH = path.join(__dirname, '..', config.dir.pkg);
    const TYPE_DEF_FILE = path.join(DST_PATH, config.dir.types, config.main.bundle_d_ts);
    const SRC_DEF_FILE = path.join(__dirname, '..', config.dir.built, config.main.basename + '-all.d.ts');

    let src = '\ufeff' + banner('.d.ts', config.main.basename) + fs.readFileSync(SRC_DEF_FILE).toString()
            .replace(/^\ufeff/gm, '')
            .replace(/\r\n/gm, '\n')
    ;

    const refPathInfo = [];
    const refPathDefs = src.match(/<reference path="[\s\S]*?"/g);

    if (null != refPathDefs) {
        refPathDefs.forEach((refpath) => {
            const filePath = refpath.match(/("|')[\s\S]*?("|')/)[0].replace(/("|')/g, '');
            const fileName = path.basename(filePath);
            refPathInfo.push({
                refpath: refpath,
                path: filePath,
                file: fileName,
            });
        });
        refPathInfo.forEach((target) => {
            src = src.replace(target.refpath, '<reference path="' + target.file + '"');
        });
        // remove '_dev.dependencies.d.ts' reference.
        src = src.replace(/\/\/\/ <reference path="_dev.dependencies.d.ts"[\s\S]*?\n/g, '');
    }

    if (!fs.existsSync(path.join(DST_PATH, config.dir.types))) {
        fs.mkdirSync(path.join(DST_PATH, config.dir.types));
    }
    fs.writeFileSync(TYPE_DEF_FILE, src);
}
563866
function (test) {
        if (test.iteration >= test.cfg.repeat) {
            return completeTest(test);
        }
        test.iteration += 1;

        test.cfg.action.call(null, test.name, test.iteration - 1, generateTestCallback(test, this));
    }
272917
function() {
  require('coffee-script')

  var path = require('path')
  var fs = require('fs')
  var Mocha = require('mocha')

  // Allow unlimited listeners for tests.
  process.setMaxListeners(0)

  var testDir = path.resolve(__dirname, '../test')
  var files = fs.readdirSync(testDir).filter(function(f) {
    return f.match(/\.js$/)
  })

  var mocha = new Mocha({
    reporter: 'spec'
  })

  for (var i = 0; i < files.length; i++) {
    var file = files[i]
    mocha.addFile(path.resolve(testDir, file))
  }

  mocha.run(function(failures) {
    var exitCode = failures === 0 ? 0 : 1

    process.send({
      type: 'shutdown',
      code: exitCode
    })
    process.exit(failures)
  })
}
963792
function createBundle(log = logger.log.bind(logger)) {
  if (!npm.can.prepare()) {
    log('building ts-jest')
    npm.spawnSync(['-s', 'run', 'build'], { cwd: rootDir })
  }
  log('creating ts-jest bundle')
  const res = npm.spawnSync(['-s', 'pack'], { cwd: rootDir })
  return join(rootDir, res.stdout.toString().trim())
}
1270076
function ready () {

    var hash = location.hash.substr( 1 );
    if(hash !=='') demoName = hash;
    editor.load('demos/' + demoName + '.js');

}
1072474
function bundler(loader, options, modules) {
  var stack    = modules.slice(0);
  var mods     = [];
  var finished = {};

  function processModule(mod) {
    if (finished.hasOwnProperty(mod.id)) {
      return;
    }

    mod = loader.getModule(mod.id);

    // browser pack chunk
    var browserpack = {
      id     : mod.id,
      source : mod.source,
      deps   : {}
    };

    // Gather up all dependencies
    var i, length, dep;
    for (i = 0, length = mod.deps.length; i < length; i++) {
      dep = mod.deps[i];
      stack.push(dep);
      browserpack.deps[dep.id] = dep.id;
    }

    finished[mod.id] = browserpack;
    mods.unshift(browserpack);
  }

  // Process all modules
  while (stack.length) {
    processModule(stack.pop());
  }

  var stream = browserPack(options).setEncoding("utf8");
  var promise = pstream(stream);

  stream.end(JSON.stringify(mods));
  return promise;
}