← Back to team overview

launchpad-dev team mailing list archive

Re: YUI test and Javascript changes - what you need to know

 


On 07/11/2011 01:09 PM, Ian Booth wrote:
> Hi
>
> You may have noticed a large number of changes to the Javascript and YUI
> tests in recent updates to your devel branch. Here's a quick heads up on
> what's been going on and what you should know moving forward.
>
> At the recent Epic, we started a project to pull the lazr-js source code
> into the Launchpad source tree. As part of the effort, it was of course
> necessary to ensure that the existing lazr-js unit tests were run as
> part of Launchpad's YUI test layer. In doing this, a number of areas for
> improvement for Launchpad's YUI test framework became apparent. The
> changes have all been done and landed. What you need to know to continue
> writing YUI tests will be summarised below. The dev wiki has also been
> updated:
> https://dev.launchpad.net/JavascriptUnitTesting
>
> == Source Code ==
>
> The lazr-js source code have been brought into the Launchpad source tree
> under lib/lp/app/javascript. So we have:
>
> lib/lp/app/javascript/anim/...
> lib/lp/app/javascript/anim/tests/...
> lib/lp/app/javascript/overlay/...
> lib/lp/app/javascript/overlay/tests/...
> lib/lp/app/javascript/picker/...
> lib/lp/app/javascript/picker/tests/...
> etc
>
> The previously separate Launchpad and lazr-js picker implementations
> have been merged. lazr-js code which we were not using in Launchpad has
> been deleted. Since we have test coverage and now full control over the
> source code, feel free to make changes/improvemets/bug fixes etc just as
> for other Launchpad source code.
>
> The Javascript build process has had some radical surgery to simplify
> the directory structure and Javascript packaging. The changes are
> transparent to developers. Unless you want to know the gory detail, all
> you need to know is that a make (clean) jsbuild will produce a
> launchpad.js which Just Works.
>
> == YUI Library ==
>
> Previously, the YUI library was packaged as part of lazr-js. Now it's a
> separate dependency, packaged as a tarball in download-cache. As with
> other tarballs in the cache, we use versions.cfg to nominate what
> version we want to build with. Currently it's 3.3, so that tarball
> yui-3.3.tar.gz will be unpacked and used as part of the make process.
>
> The outcome is that we can very easily now test new versions if YUI by
> simply downloading the pre-packaged tarball off github and updating
> versions.cfg.
>
> == YUI Tests ==
>
> Our YUI tests had a number of areas for improvement. The main issue is
> that there was way too much cut'n'paste boiler plate.
> 1. Each html test harness had to define a <div id='log></div> to capture
> the output.
>
> 2. Logged output was very hard to read inside the small log console
> embedded in the page.
>
> 3. Lots of areas were there was cut'n'paste in the test files:
> a. the html test harness (import of all the css styles)
>
> b. the YUI object construction at the top of each test file
> YUI({
> ... cut'n'paste configs ...
> }).use(...)
>
> c. the test run and logging code (the 15 lines of "Lock, stock and two
> smoking barrels" javascript)
>
>
> The refactoring that was done eliminates the above problems:
> i. There's a new lib/lp/app/javascript/testing directory which contains
> the common code and css for all tests.
> --> yui config, css, common test code changed in one place
>
> ii. the log div is constructed on the fly in the test setup code
> --> no more <div id='log></div> required in html test harnesses
>
> iii the test output is logged to both the browser console and the YUI
> test console
> --> logged output readable
>
> iv. tests are run using a single line of Javascript:
> Y.lp.testing.Runner.run(suite);
> --> enough said
>
> The wiki has the new harness and runner example code:
> https://dev.launchpad.net/JavascriptUnitTesting
>
> As before, the YUI tests are run using:
> bin/test --layer=YUI
>
> or can be run one suite at a time in the browser by loading the relevant
> html test harness.
>
> NB I have found that FF5 fails when running some of the tests. They work
> fine in Chromium and python-htmlbrowser used by the test runner. I have
> not yet tracked down the cause. The failing tests are from the (former)
> lazr-js suite.
>
> If there are any questions, please let me know.
>
>
Fantastic work guys, this is really great to see! Is there anything left
to do to consider this work complete?
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~launchpad-dev
> Post to     : launchpad-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~launchpad-dev
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References