/**1* Copyright (c) 2014, Facebook, Inc. All rights reserved.2*3* This source code is licensed under the BSD-style license found in the4* LICENSE file in the root directory of this source tree. An additional grant5* of patent rights can be found in the PATENTS file in the same directory.6*/7'use strict';89var optimist = require('optimist');10//var q = require('q');11var TestRunner = require('./TestRunner');12var workerUtils = require('node-worker-pool/nodeWorkerUtils');1314if (require.main === module) {15try {16process.on('uncaughtException', workerUtils.respondWithError);1718var argv = optimist.demand(['config']).argv;19var config = JSON.parse(argv.config);2021var testRunner = null;22/* jshint -W082:true */23function onMessage(message) {24if (testRunner === null) {25testRunner = new TestRunner(config, {26useCachedModuleLoaderResourceMap: true,27});2829// Start require()ing config dependencies now.30//31// Config dependencies are entries in the config that are require()d (in32// order to be pluggable) such as 'moduleLoader' or33// 'testEnvironment'.34testRunner.preloadConfigDependencies();3536// Start deserializing the resource map to get a potential head-start on37// that work before the first "run-test" message comes in.38//39// This is just a perf optimization -- and it is only an optimization40// some of the time (when the there is any significant idle time between41// this first initialization message and the first "run-rest" message).42//43// It is also only an optimization so long as deserialization of the44// resource map is a bottleneck (which is the case at the time of this45// writing).46testRunner.preloadResourceMap();47}4849return testRunner.runTest(message.testFilePath)50.catch(function(err) {51throw (err.stack || err.message || err);52});53}5455workerUtils.startWorker(null, onMessage);56} catch (e) {57workerUtils.respondWithError(e);58}59}606162