Extend test group rule to support 'userInitiated' field.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2018 03:27:45 +0000 (03:27 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2018 03:27:45 +0000 (03:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186544

Reviewed by Ryosuke Niwa.

Added support for rule specifying whether or not test group is user initiated.

* tools/js/analysis-results-notifier.js: Rule now support 'userInitiated' field.
(AnalysisResultsNotifier.prototype.async.sendNotificationsForTestGroups):
(AnalysisResultsNotifier.prototype._applyRules):
(AnalysisResultsNotifier._matchesRule):
* unit-tests/analysis-results-notifier-tests.js: Added unit tests for this change.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232740 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/tools/js/analysis-results-notifier.js
Websites/perf.webkit.org/unit-tests/analysis-results-notifier-tests.js

index d533507..097aa3a 100644 (file)
@@ -1,3 +1,18 @@
+2018-06-11  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Extend test group rule to support 'userInitiated' field.
+        https://bugs.webkit.org/show_bug.cgi?id=186544
+
+        Reviewed by Ryosuke Niwa.
+
+        Added support for rule specifying whether or not test group is user initiated.
+
+        * tools/js/analysis-results-notifier.js: Rule now support 'userInitiated' field.
+        (AnalysisResultsNotifier.prototype.async.sendNotificationsForTestGroups):
+        (AnalysisResultsNotifier.prototype._applyRules):
+        (AnalysisResultsNotifier._matchesRule):
+        * unit-tests/analysis-results-notifier-tests.js: Added unit tests for this change.
+
 2018-05-29  Dewei Zhu  <dewei_zhu@apple.com>
 
         CommitSet range bisector should use commits occur in commit sets which specify the range as valid commits for commits without ordering.
index 759dc26..48e2129 100644 (file)
@@ -39,7 +39,7 @@ class AnalysisResultsNotifier {
             const title = `"${testGroup.task().name()}" - "${testGroup.name()}" has finished`;
             const message = await AnalysisResultsNotifier._messageForTestGroup(testGroup, title);
             let content = AnalysisResultsNotifier._instantiateNotificationTemplate(this._messageTemplate, title, message);
-            content = this._applyRules(testGroup.platform().name(), testGroup.test().path()[0].name(), content);
+            content = this._applyRules(testGroup.platform().name(), testGroup.test().path()[0].name(), !!testGroup.author(), content);
             const testGroupInfo = {author: testGroup.author()};
 
             const tempDir = fs.mkdtempSync(os.tmpdir());
@@ -77,16 +77,16 @@ class AnalysisResultsNotifier {
         return instance;
     }
 
-    _applyRules(platformName, testName, message)
+    _applyRules(platformName, testName, userInitiated, message)
     {
         for (const rule of this._messageConstructionRules) {
-            if (AnalysisResultsNotifier._matchesRule(platformName, testName, rule))
+            if (AnalysisResultsNotifier._matchesRule(platformName, testName, userInitiated, rule))
                 message = AnalysisResultsNotifier._applyUpdate(message, rule.parameters);
         }
         return message;
     }
 
-    static _matchesRule(platform, test, rule)
+    static _matchesRule(platform, test, userInitiated, rule)
     {
         if (rule.tests && !rule.tests.includes(test))
             return false;
@@ -94,6 +94,9 @@ class AnalysisResultsNotifier {
         if (rule.platforms && !rule.platforms.includes(platform))
             return false;
 
+        if ('userInitiated' in rule && userInitiated !== rule.userInitiated)
+            return false;
+
         return true;
     }
 
index 104b571..ded9fd9 100644 (file)
@@ -21,37 +21,67 @@ describe('AnalysisResultsNotifier', () => {
 
         it('should return a group of matching function based on configuration', () => {
             const rule = {platforms: [trunkMacBook, trunkMacBookPro], tests: [speedometer, speedometer2]};
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, speedometer, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, speedometer, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, true, rule));
 
         });
 
         it('should match rule only contains tests correctly', () => {
             const rule = {tests: [jetStream]};
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, jetStream, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, jetStream, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, true, rule));
         });
 
         it('should match rule only contains platforms correctly', () => {
             const rule = {platforms: [trunkMacBook]};
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, rule));
-            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, jetStream, rule));
-            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, jetStream, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, jetStream, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookAir, jetStream, true, rule));
+        });
+
+        it('should match rule with "userInitiated" set to true', () => {
+            const rule = {platforms: [trunkMacBook, trunkMacBookPro], tests: [speedometer, speedometer2], userInitiated: true};
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, false, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, false, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, false, rule));
+        });
+
+        it('should match rule with "userInitiated" set to false', () => {
+            const rule = {platforms: [trunkMacBook, trunkMacBookPro], tests: [speedometer, speedometer2], userInitiated: false};
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, false, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, false, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, false, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(!AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
 
         });
+
+        it('should match the rule regardless whether or not "userInitiated" is set if rule does not specify', () => {
+            const rule = {platforms: [trunkMacBook, trunkMacBookPro], tests: [speedometer, speedometer2]};
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, true, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBook, speedometer2, false, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer, false, rule));
+            assert.ok(AnalysisResultsNotifier._matchesRule(trunkMacBookPro, speedometer2, false, rule));
+        });
     });
 
     describe('_validateRules', () => {