lib/common.js
function(callback) {
      var queue;

      if (exportedFunctionsNames.length === 0) {
        callback();
        return;
      }

      function taskFunc(task, callback) {
        var setUpFunc = task.setUpFunc, tearDownFunc = task.tearDownFunc;

        async.waterfall([
          function runSetUp(callback) {
            if (!setUpFunc) {
              callback();
              return;
            }

            var test = new Test(constants.SETUP_FUNCTION_NAME, setUpFunc,
                                self._scopeLeaks);
            test.run(onTestDone.bind(null, test, callback));
          },

          function runTest(callback) {
            var test = task.test;
            self._runningTest = test;
            test.run(onTestDone.bind(null, test, callback));
          },

          function runTearDown(callback) {
           if (!tearDownFunc) {
              callback();
              return;
            }

            var test = new Test(constants.TEARDOWN_FUNCTION_NAME, tearDownFunc,
                                self._scopeLeaks);
            test.run(onTestDone.bind(null, test, callback));
          }
        ], callback);
      }

      function onDrain() {
        callback();
      }

      queue = async.queue(taskFunc, self._concurrency);
      queue.drain = onDrain;

      for (i = 0; i < testsLen; i++) {
        testName = exportedFunctionsNames[i];
        testFunc = exportedFunctions[testName];

        if (!gex(self._pattern).on(testName)) {
          continue;
        }

        test = new Test(testName, testFunc, self._scopeLeaks);
        queue.push({'test': test, 'setUpFunc': setUpFunc, 'tearDownFunc': tearDownFunc});
      }

      if (queue.length() === 0) {
        // No test matched the provided pattern
        callback();
      }
    }
function(callback) {
      var queue;

      if (exportedFunctionsNames.length === 0) {
        callback();
        return;
      }

      function taskFunc(task, callback) {
        var setUpFunc = task.setUpFunc, tearDownFunc = task.tearDownFunc;

        async.waterfall([
          function runSetUp(callback) {
            if (!setUpFunc) {
              callback();
              return;
            }

            var test = new Test(constants.SETUP_FUNCTION_NAME, setUpFunc,
                                self._scopeLeaks);
            test.run(onTestDone.bind(null, test, callback));
          },

          function runTest(callback) {
            var test = task.test;
            self._runningTest = test;
            test.run(onTestDone.bind(null, test, callback));
          },

          function runTearDown(callback) {
           if (!tearDownFunc) {
              callback();
              return;
            }

            var test = new Test(constants.TEARDOWN_FUNCTION_NAME, tearDownFunc,
                                self._scopeLeaks);
            test.run(onTestDone.bind(null, test, callback));
          }
        ], callback);
      }

      function onDrain() {
        callback();
      }

      queue = async.queue(taskFunc, self._concurrency);
      queue.drain = onDrain;

      for (i = 0; i < testsLen; i++) {
        testName = exportedFunctionsNames[i];
        testFunc = exportedFunctions[testName];

        if (!gex(self._pattern).on(testName)) {
          continue;
        }

        test = new Test(testName, testFunc, self._scopeLeaks);
        queue.push({'test': test, 'setUpFunc': setUpFunc, 'tearDownFunc': tearDownFunc});
      }

      if (queue.length() === 0) {
        // No test matched the provided pattern
        callback();
      }
    }
function ( callback ) { var queue ; if ( exportedFunctionsNames . length === 0 ) { callback ( ) ; return ; } function taskFunc ( task , callback ) { var setUpFunc = task . setUpFunc , tearDownFunc = task . tearDownFunc ; async . waterfall ( [ function runSetUp ( callback ) { if ( ! setUpFunc ) { callback ( ) ; return ; } var test = new Test ( constants . SETUP_FUNCTION_NAME , setUpFunc , self . _scopeLeaks ) ; test . run ( onTestDone . bind ( null , test , callback ) ) ; } , function runTest ( callback ) { var test = task . test ; self . _runningTest = test ; test . run ( onTestDone . bind ( null , test , callback ) ) ; } , function runTearDown ( callback ) { if ( ! tearDownFunc ) { callback ( ) ; return ; } var test = new Test ( constants . TEARDOWN_FUNCTION_NAME , tearDownFunc , self . _scopeLeaks ) ; test . run ( onTestDone . bind ( null , test , callback ) ) ; } ] , callback ) ; } function onDrain ( ) { callback ( ) ; } queue = async . queue ( taskFunc , self . _concurrency ) ; queue . drain = onDrain ; for ( i = 0 ; i < testsLen ; i ++ ) { testName = exportedFunctionsNames [ i ] ; testFunc = exportedFunctions [ testName ] ; if ( ! gex ( self . _pattern ) . on ( testName ) ) { continue ; } test = new Test ( testName , testFunc , self . _scopeLeaks ) ; queue . push ( { 'test' : test , 'setUpFunc' : setUpFunc , 'tearDownFunc' : tearDownFunc } ) ; } if ( queue . length ( ) === 0 ) { // No test matched the provided pattern callback ( ) ; } }
Run the tests
Run the tests