Open Bug 421474 Opened 16 years ago Updated 2 years ago

mochitest: display "file n of N" at the top when executing tests, add a "stop tests" button

Categories

(Testing :: Mochitest, enhancement)

enhancement

Tracking

(Not tracked)

REOPENED

People

(Reporter: MatsPalmgren_bugz, Unassigned)

References

Details

Attachments

(1 file)

It's hard to see how far down in the file list it has reached
(it scrolls out of view when running all tests) and I generally
don't want to touch the window while the tests are running since
it can make some tests fail, 
so a "file n of N" counter at the top would be helpful.
Component: Testing → Mochitest
Product: Core → Testing
QA Contact: testing → mochitest
Version: Trunk → unspecified
I figured this was already filed somewhere. This adds a "File X / Y (Z%)" above the "Pass / Fail / Todo" lines, and also updates the document title with the progress. While I was there, I also made the "Run Tests" link change to "Stop Tests" when the test run starts. (clicking "Stop Tests" changes it to "Restart Tests", and clicking that reloads the test page.)
Assignee: nobody → ted.mielczarek
Status: NEW → ASSIGNED
Attachment #409346 - Flags: review?(jwalden+bmo)
smaug asked for the stop button.
Summary: mochitest: display "file n of N" at the top when executing tests → mochitest: display "file n of N" at the top when executing tests, add a "stop tests" button
Comment on attachment 409346 [details] [diff] [review]
add progress meter, also make "run tests" link switch to "stop tests" when starting

>diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest

>-    window.scrollTo(0, $('indicator').offsetTop);
>+    window.scrollTo(0, $('runtests').offsetTop);

At this point it seems like you might as well just make this |window.scrollTo(0, 0);|.
Attachment #409346 - Flags: review?(jwalden+bmo) → review+
Comment on attachment 409346 [details] [diff] [review]
add progress meter, also make "run tests" link switch to "stop tests" when starting

>diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest
>@@ -169,6 +171,12 @@ TestRunner.runNextTest = function() {
>         if (TestRunner.onComplete)
>             TestRunner.onComplete();
>     }
>+  var progress = TestRunner._currentTest + " / "
>+  + TestRunner._urls.length
>+  + " (" + Math.floor(100 * (TestRunner._currentTest / TestRunner._urls.length))
>+  + "%)";
>+  document.title = progress + " - " + TestRunner._title;
>+  $("progress").innerHTML = progress;
> };

Er, yikes!  Unusual style alert!  It's extremely rare for + to be at the start of a line like that, and aligned with the statement in question is even weirder.  Better style:

>  var progress =
>    TestRunner._currentTest + " / " + TestRunner._urls.length +
>    " (" +
>    Math.floor(100 * (TestRunner._currentTest / TestRunner._urls.length)) +
>    "%)";
>  document.title = progress + " - " + TestRunner._title;
>  $("progress").innerHTML = progress;

I would approve of temporaries being introduced so the Math.floor() line isn't so absurdly long, but this is at least passable.
I added some temporaries, which does make it a lot cleaner. Not sure what I was thinking there.

Pushed to m-c:
http://hg.mozilla.org/mozilla-central/rev/5ee85f742d82
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
It was backed out by changeset ddd50257e653:
"Vladimir Vukicevic – backing out 5ee85f7 due to test harness failures"
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
FYI, it also seems to have caused unexpected screen coordinates in some tests,
see bug 529660.
Depends on: 529660
Probably due to the scrollTo(0,0:
http://hg.mozilla.org/mozilla-central/rev/5ee85f742d82#l3.16

It saddens me that we have tests that are that fragile, though.

The other failures were because I failed to change the mochitest chrome harness, so this was spewing JS errors in chrome/a11y.
Assignee: ted → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: