Bug 1527673 - Output histogram name in asserts r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Thu, 28 Feb 2019 18:44:45 +0000
changeset 519690 f89aa19d37be3281be2ac835f1704746dfa68b2e
parent 519689 26e37344a1d9fb6f579c38e82e04341577ead9ad
child 519691 512b63ef9f71910c7d49cd5d5bc332efae84bdf9
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1527673
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527673 - Output histogram name in asserts r=chutten Depends on D21531 Differential Revision: https://phabricator.services.mozilla.com/D21532
toolkit/components/telemetry/tests/utils/TelemetryTestUtils.jsm
--- a/toolkit/components/telemetry/tests/utils/TelemetryTestUtils.jsm
+++ b/toolkit/components/telemetry/tests/utils/TelemetryTestUtils.jsm
@@ -228,61 +228,61 @@ var TelemetryTestUtils = {
    */
   assertHistogram(histogram, index, expected) {
     const snapshot = histogram.snapshot();
     let found = false;
     for (let [i, val] of Object.entries(snapshot.values)) {
       if (i == index) {
         found = true;
         Assert.equal(val, expected,
-          `expected counts should match for the histogram index ${i}`);
+          `expected counts should match for ${histogram.name()} at index ${i}`);
       } else {
         Assert.equal(val, 0,
-          `unexpected counts should be zero for the histogram index ${i}`);
+          `unexpected counts should be zero for ${histogram.name()} at index ${i}`);
       }
     }
-    Assert.ok(found, `Should have found an entry for histogram index ${index}`);
+    Assert.ok(found, `Should have found an entry for ${histogram.name()} at index ${index}`);
   },
 
   /**
    * Assert that a key within a keyed histogram contains the required sum.
    *
    * @param {Object} histogram The keyed histogram to check.
    * @param {String} key The key to check.
    * @param {Number} [expected] The expected sum for the key.
    */
   assertKeyedHistogramSum(histogram, key, expected) {
     const snapshot = histogram.snapshot();
     if (expected === undefined) {
-      Assert.ok(!(key in snapshot), `The histogram must not contain ${key}.`);
+      Assert.ok(!(key in snapshot), `The histogram ${histogram.name()} must not contain ${key}.`);
       return;
     }
-    Assert.ok(key in snapshot, `The histogram must contain ${key}.`);
+    Assert.ok(key in snapshot, `The histogram ${histogram.name()} must contain ${key}.`);
     Assert.equal(snapshot[key].sum, expected,
-      `The key ${key} must contain the expected sum.`);
+      `The key ${key} must contain the expected sum in ${histogram.name()}.`);
   },
 
   /**
    * Assert that the value of a key within a keyed histogram is the right value.
    * It expects that other values are all zero.
    *
    * @param {Object} histogram The keyed histogram to check.
    * @param {String} key The key to check.
    * @param {Number} index The index to check against the expected value.
    * @param {Number} [expected] The expected values for the key.
    */
   assertKeyedHistogramValue(histogram, key, index, expected) {
     const snapshot = histogram.snapshot();
     if (!(key in snapshot)) {
-      Assert.ok(false, `The histogram must contain ${key}`);
+      Assert.ok(false, `The histogram ${histogram.name()} must contain ${key}`);
       return;
     }
     for (let [i, val] of Object.entries(snapshot[key].values)) {
       if (i == index) {
         Assert.equal(val, expected,
-          `expected counts should match for the histogram index ${i}`);
+          `expected counts should match for ${histogram.name()} at index ${i}`);
       } else {
         Assert.equal(val, 0,
-          `unexpected counts should be zero for the histogram index ${i}`);
+          `unexpected counts should be zero for ${histogram.name() } at index ${i}`);
       }
     }
   },
 };