jenkins-bot has submitted this change and it was merged.

Change subject: Fix how QUnit.newMwEnvironment merges live and custom settings
......................................................................


Fix how QUnit.newMwEnvironment merges live and custom settings

We shouldn't merge a live state's setting value with a custom
value anymore as it has been done since I7d20f0b2f4. Doing this
can produce very unpredictable outcome of tests depending on the
server's state and will prevent from being able to properly
define a test's conditions.

Change-Id: I7ad058a45708244918211658b5d4e07f69abba31
---
M tests/qunit/data/testrunner.js
1 file changed, 8 insertions(+), 6 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js
index c89656d..77db213 100644
--- a/tests/qunit/data/testrunner.js
+++ b/tests/qunit/data/testrunner.js
@@ -109,12 +109,14 @@
                liveMessages = mw.messages.values;
 
                function freshConfigCopy( custom ) {
-                       // "deep=true" is important here.
-                       // Otherwise we just create a new object with values 
referring to live config.
-                       // e.g. mw.config.set( 'wgFileExtensions', [] ) would 
not effect liveConfig,
-                       // but mw.config.get( 'wgFileExtensions' ).push( 'png' 
) would as the array
-                       // was passed by reference in $.extend's loop.
-                       return $.extend( /*deep=*/true, {}, liveConfig, custom 
);
+                       // Tests should mock all factors that directly 
influence the tested code.
+                       // For backwards compatibility though we set mw.config 
to a copy of the live config
+                       // and extend it with the (optionally) given custom 
settings for this test
+                       // (instead of starting blank with only the given 
custmo settings).
+                       // This is a shallow copy, so we don't end up with 
settings taking an array value
+                       // extended with the custom settings - setting a config 
property means you override it,
+                       // not extend it.
+                       return $.extend( {}, liveConfig, custom );
                }
 
                function freshMessagesCopy( custom ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/49693
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7ad058a45708244918211658b5d4e07f69abba31
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to