Last modified: 2012-10-22 21:15:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T39321, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37321 - Qunit tests cannot be executed for multiple context languages
Qunit tests cannot be executed for multiple context languages
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
Unit tests (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 39801 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-04 04:50 UTC by Santhosh Thottingal
Modified: 2012-10-22 21:15 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Santhosh Thottingal 2012-06-04 04:50:25 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
Comment 1 Krinkle 2012-06-09 15:34:31 UTC
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.
Comment 2 Krinkle 2012-10-22 21:08:33 UTC
*** Bug 39801 has been marked as a duplicate of this bug. ***
Comment 3 Krinkle 2012-10-22 21:15:34 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links