Commit 4b1ee195 authored by gavin@gavinsharp.com's avatar gavin@gavinsharp.com
Browse files

Bug 387455: adjust browser chrome test harness output (provide summary, don't...

Bug 387455: adjust browser chrome test harness output (provide summary, don't fail if there are no tests), r=robcee
parent 13844e53
Loading
Loading
Loading
Loading
+25 −14
Original line number Original line Diff line number Diff line
@@ -102,14 +102,18 @@


    function browserTestFile(aTestFile) {
    function browserTestFile(aTestFile) {
      this.path = aTestFile;
      this.path = aTestFile;
      this.exception = null;
      this.timedOut = false;
      this.tests = [];
      this.tests = [];
      this.scope = null;
      this.scope = null;
    }
    }
    browserTestFile.prototype = {
    browserTestFile.prototype = {
      get allPassed() {
      get passCount() {
        return !this.tests.some(function (t) !t.pass);
        return this.tests.filter(function (t) !t.todo && t.pass).length;
      },
      get todoCount() {
        return this.tests.filter(function (t) t.todo && t.pass).length;
      },
      get failCount() {
        return this.tests.filter(function (t) !t.pass).length;
      },
      },
      get log() {
      get log() {
        return this.tests.map(function (t) t.msg).join("\n");
        return this.tests.map(function (t) t.msg).join("\n");
@@ -154,16 +158,23 @@
    }
    }


    function getLogFromTests(aTests) {
    function getLogFromTests(aTests) {
      return aTests.map(function (f) {
      if (!aTests.length)
        return "PASS - No tests to run";

      var log = aTests.map(function (f) {
                             var output = f.path + "\n";
                             var output = f.path + "\n";
                             if (f.log)
                             if (f.log)
                               output += f.log + "\n";
                               output += f.log + "\n";
                          if (f.exception)
                            output += "\tFAIL - Exception thrown: " + f.exception + "\n";
                          if (f.timedOut)
                            output += "\tFAIL - Timed out\n";
                             return output;
                             return output;
                           }).join("");
                           }).join("");
      log += "\nBrowser Chrome Test Summary\n";
      function sum(a, b){ return a + b; }
      var passCount = aTests.map(function (f) f.passCount).reduce(sum);
      var failCount = aTests.map(function (f) f.failCount).reduce(sum);
      var todoCount = aTests.map(function (f) f.todoCount).reduce(sum);
      log += "\tPass: " + passCount + "\n\tFail: " + failCount + "\n\tTodo: " + todoCount + "\n";

      return log;
    }
    }


    function testsFinished(aTests) {
    function testsFinished(aTests) {
+10 −10
Original line number Original line Diff line number Diff line
@@ -70,13 +70,12 @@ Tester.prototype = {
    try {
    try {
      this.currentTest.scope.test();
      this.currentTest.scope.test();
    } catch (ex) {
    } catch (ex) {
      this.currentTest.exception = ex;
      this.currentTest.tests.push(new testResult(false, "Exception thrown", ex, false));
    }
    }


    // If the test ran synchronously, set the result and move to the next test,
    // If the test ran synchronously, move to the next test,
    // otherwise start a poller to monitor it's progress.
    // otherwise start a poller to monitor it's progress.
    if (this.currentTest.scope.done) {
    if (this.currentTest.scope.done) {
      this.currentTest.result = this.currentTest.scope.result;
      this.execTest();
      this.execTest();
    } else {
    } else {
      var self = this;
      var self = this;
@@ -90,9 +89,13 @@ function testResult(aCondition, aName, aDiag, aIsTodo) {
  aName = aName || "";
  aName = aName || "";


  this.pass = !!aCondition;
  this.pass = !!aCondition;
  if (this.pass)
  this.todo = aIsTodo;
  if (this.pass) {
    if (aIsTodo)
      this.msg = "\tTODO PASS - " + aName;
    else
      this.msg = "\tPASS - " + aName;
      this.msg = "\tPASS - " + aName;
  else {
  } else {
    this.msg = "\tFAIL - ";
    this.msg = "\tFAIL - ";
    if (aIsTodo)
    if (aIsTodo)
      this.msg += "TODO Worked? - ";
      this.msg += "TODO Worked? - ";
@@ -158,14 +161,11 @@ resultPoller.prototype = {
      self.loopCount++;
      self.loopCount++;
  
  
      if (self.loopCount > MAX_LOOP_COUNT) {
      if (self.loopCount > MAX_LOOP_COUNT) {
        self.test.timedOut = true;
        self.test.tests.push(new testResult(false, "Timed out", "", false));
        self.test.scope.done = true;
        self.test.scope.done = true;
      }
      }


      if (self.test.scope.done) {
      if (self.test.scope.done) {
        // Set the result
        self.test.result = self.test.scope.result;

        clearInterval(self.interval);
        clearInterval(self.interval);


        // Notify the callback
        // Notify the callback