Last modified: 2012-10-22 21:15:34 UTC
Qunit test cases like grammar rule tests., plural rule tests etc are written for multiple languages. But it is not possible to run all these tests in a single execution. The reason is when we set a content language, the language javascript alone get loaded(resources/mediawiki.language/languages/xx.js) . But we need more than one js from resources/mediawiki.language/languages/ for executing tests for all languages. See http://www.mediawiki.org/wiki/Special:Code/MediaWiki/111724/31796#c31796
I tried to implement a solution for this locally, but decided to give up because the system simply isn't built for it, and I don't see a way for this to happen anytime soon. The root cause is that the helper data is written in the same property for all languages. I concluded that this seems more a design flaw / feature request for mediawiki.language, not so much a lack in ResourceLoader. The language module should be able to store logic for multiple languages simultaneously, instead of assuming that there is only 1 language at a time. Just like it can load multiple pieces of information in language.data the helper methods convertPlural should be loadable for different languages at the same time as well. Then the unit test can simply load them all on-demand. The language* and skin* properties are nice to conditionally load parts that are relevant for the end user. But in this case it seems more appropriate to have them in separate modules and be able to load them on-demand.
*** Bug 39801 has been marked as a duplicate of this bug. ***
Instead of re-running a whole legion of asynchronous tests unrelated to i18n, any i18n related tests should test in multiple locales by executing their units correctly and passing whatever parameters necessary. There are many context related factors, "just" re-running everything in all sorts of combinations (uselang, skin, page existence, user logged-in state, mediawiki configuration variables, user preferences etc.) - units can do this themselves. We do this on most/all other factors already, and we can for i18n as well. See also bug 39801 comment #2: I243d055d demonstrates a way to run certain assertions in multiple locales by re-loading the mediawiki.language module. This isn't a magic way to re-run anything for a list of languages, but it does show that the mw object is dynamic and can be augmented at any time for any purpose. Other tests should implement their own way of running their logic for other languages. If that means re-loading mw.language, then that is a way. If that means addressing a lower-level method of that library directly, that works too. For example instead of changing wgUserLanguage and re-running $.foo.init() and asserting $.foo.bar(), sometimes it is better to do var myFoo = new $.Foo( { lang: code } ); and assert myFoo.bar(); Marking this bug as invalid as I don't believe re-running everything for an arbitrary of languages is a scalable or useful method. Instead test should be written in a testable way and will therefor be naturally be testable for affecting context factors, including but not limited to the language.