Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: Tools/GardeningServer/ui/ct-failure-analyzer-tests.html

Issue 462453002: Sheriff-O-Matic: Transition more unit tests to mocha. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase and fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6
7 <link rel="import" href="ct-failure-analyzer.html">
8
9 <script>
10 (function() {
11
12 module("ct-failure-analyzer");
13
14 test("_failureComparator", 1, function() {
15 var analyzer = document.createElement('ct-failure-analyzer');
16
17 var resultsByBuilder = {};
18 var failure1 = new CTFailure("step1", "reason1", resultsByBuilder, 123, 123);
19 var failure2 = new CTFailure("step1", "reason2", resultsByBuilder, 123, 123);
20 var failure3 = new CTFailure("step1", "reason3", resultsByBuilder, 123, 123);
21 var failure4 = new CTFailure("step2", "reason1", resultsByBuilder, 123, 123);
22
23 var failures = [failure4, failure3, failure2, failure1];
24 var expectedFailures = [failure1, failure2, failure3, failure4];
25 deepEqual(failures.sort(analyzer._failureComparator), expectedFailures);
26 });
27
28 test("_failureListComparator", 8, function() {
29 var analyzer = document.createElement('ct-failure-analyzer');
30
31 var revision1 = {
32 'chromium': 1,
33 'blink': 2
34 };
35 var revision2 = {
36 'chromium': 2,
37 'blink': 1
38 };
39 var revision3 = {
40 'chromium': 2,
41 'blink': 2
42 };
43 var resultsByBuilder = {};
44 var failure1 = new CTFailure("step", "reason", resultsByBuilder, revision1, re vision1);
45 var failure2 = new CTFailure("step", "reason", resultsByBuilder, revision2, re vision2);
46 var failure3 = new CTFailure("step", "reason", resultsByBuilder, revision3, re vision3);
47 var failure4 = new CTFailure("step", "reason", resultsByBuilder, null, null);
48
49 // Sort by last revision first.
50 ok(analyzer._failureListComparator('chromium', [failure1], [failure2]) > 0);
51 ok(analyzer._failureListComparator('chromium', [failure2], [failure1]) < 0);
52 ok(analyzer._failureListComparator('chromium', [failure1], [failure1]) == 0);
53
54 // If the tree revisions are equal, take others.
55 ok(analyzer._failureListComparator('chromium', [failure2], [failure3]) > 0);
56
57 // Prioritize the given tree.
58 ok(analyzer._failureListComparator('chromium', [failure1], [failure2]) > 0);
59 ok(analyzer._failureListComparator('blink', [failure1], [failure2]) < 0);
60
61 // Default to 'chromium'.
62 ok(analyzer._failureListComparator(undefined, [failure1], [failure2]) > 0);
63
64 // Failures without a revision go to the end.
65 ok(analyzer._failureListComparator('chromium', [failure4], [failure1]) < 0);
66 });
67
68 })()
69 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698