Skip to content

Commit 5accfd7

Browse files
committed
Bug 1975980 - report pref changes as expected failures, upload a modifiedPrefs.json artifacts with all the pref changes of the job, r=jmaher.
Differential Revision: https://phabricator.services.mozilla.com/D256279
1 parent a44d92c commit 5accfd7

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

testing/mochitest/browser-test.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,6 @@ Tester.prototype = {
725725
},
726726

727727
async checkPreferencesAfterTest() {
728-
// This supports the --compare-preferences flag for browser tests.
729-
// The implementation for plain mochitests is at
730-
// https://searchfox.org/mozilla-central/rev/c25dbe453ff9ca10f2c6bdfb873893c515a29826/testing/mochitest/tests/SimpleTest/TestRunner.js#990-1012
731-
if (!gConfig.comparePrefs) {
732-
// Although the plain mochitest version of this logic resets preferences
733-
// unconditionally, we do not, to minimize impact on the many existing
734-
// tests. We only report failures when --compare-preferences is set.
735-
return;
736-
}
737728
if (!this._ignorePrefs) {
738729
const ignorePrefsFile = `chrome://mochikit/content/${gConfig.ignorePrefsFile}`;
739730
try {
@@ -751,10 +742,38 @@ Tester.prototype = {
751742
const failures = await window.SpecialPowers.comparePrefsToBaseline(
752743
this._ignorePrefs
753744
);
745+
746+
let testPath = this.currentTest.path;
747+
if (testPath.startsWith("chrome://mochitests/content/browser/")) {
748+
testPath = testPath.replace("chrome://mochitests/content/browser/", "");
749+
}
750+
let changedPrefs = [];
754751
for (let p of failures) {
755752
this.structuredLogger.error(
756-
`TEST-UNEXPECTED-FAIL | ${this.currentTest.path} | changed preference: ${p}`
753+
// We only report unexpected failures when --compare-preferences is set.
754+
`TEST-${gConfig.comparePrefs ? "UN" : ""}EXPECTED-FAIL | ${testPath} | changed preference: ${p}`
755+
);
756+
changedPrefs.push(p);
757+
}
758+
759+
if (changedPrefs.length && Services.env.exists("MOZ_UPLOAD_DIR")) {
760+
let modifiedPrefsPath = PathUtils.join(
761+
Services.env.get("MOZ_UPLOAD_DIR"),
762+
"modifiedPrefs.json"
757763
);
764+
765+
if (!this._modifiedPrefs) {
766+
try {
767+
this._modifiedPrefs = JSON.parse(
768+
await IOUtils.readUTF8(modifiedPrefsPath)
769+
);
770+
} catch (e) {
771+
this._modifiedPrefs = {};
772+
}
773+
}
774+
775+
this._modifiedPrefs[testPath] = changedPrefs;
776+
await IOUtils.writeJSON(modifiedPrefsPath, this._modifiedPrefs);
758777
}
759778
},
760779

0 commit comments

Comments
 (0)