This is an archive of the discontinued LLVM Phabricator instance.

[LNT] Adding initial support for javascript unit testing
AcceptedPublic

Authored by kristof.beyls on May 11 2016, 6:01 AM.

Details

Reviewers
jmolloy
cmatthews
Summary

This adds initial support for unit testing the javascript
functionality, by using the Jasmine javascript testing framework
(http://jasmine.github.io/) and the Jasmine-py
(https://github.com/jasmine/jasmine-py/) package to drive the
regression tests from python.

In this change:

  • I added 2 simple javascript tests, see tests/spec/javascripts/profile_lnt_spec.js.
  • Added integration for running these tests with lit, see tests/javascript_tests.py and tests/lit.cfg.
  • Adapted an interface in lnt_profile.js, to make it easier to unit test (It also makes the interface cleaner, independent of unit testing needs).
  • Unfortunately, there seems to be a problem with the jasmine pypi package: it installs fine with "pip install jasmine", but I get an error when trying to install it automatically when running "python ../lnt/setup.py develop": ValueError: bad marshal data (unknown type code)

The main reasons for picking Jasmine, out of quite a few different alternatives for javascript testing frameworks are:

  • It seems to be one of the more popular and well-supported frameworks.
  • It can easily be installed using "pip install".
  • The jasmine-py package makes running the tests from python (e.g. lit) easy.

The tests are being run in a browser. When no browser is specified, a default one is used.
Probably, the most comfortable way to run these tests is to use the phantomjs head-less browser (http://phantomjs.org/).
The lit command line to run all tests (python + javascript ones) then looks like:

llvm-lit -sv -Dbrowser=phantomjs lnt/tests

As is, this isn't ready to be committed. First, the problem with installing the jasmine pypi
package as part of 'python ../lnt/setup.py develop' needs to be solved. I'm hoping to get
some review feedback on whether this looks like the right/a good direction for integrating
javascript testing into LNT's regression tests.

Diff Detail

Event Timeline

kristof.beyls retitled this revision from to [LNT] Adding initial support for javascript unit testing.
kristof.beyls updated this object.
kristof.beyls added a subscriber: llvm-commits.
cmatthews accepted this revision.May 25 2016, 3:44 PM
cmatthews edited edge metadata.

I think this is a good approach.

I do get the ValueError: bad marshal data (unknown type code) on install as well.

I also note I don't get the error when using ipython as the interpreter. ipython is python 2.7.10 vs the 2.7.6 that is on my system.

This revision is now accepted and ready to land.May 25 2016, 3:44 PM
silvas resigned from this revision.Jul 8 2016, 11:49 PM
silvas removed a reviewer: silvas.

The issue with jasmine-py (bad marshall data) has been fixed in the latest 2.5.0 release, after having raised a bug for it: https://github.com/jasmine/jasmine-py/issues/30.

Unfortunately, I'm encountering the following 2 defects in Selenium and phantomjs as installed on Ubuntu 16.04:

I'll need time to investigate these further to come to a conclusion on whether using jasmine-py, and it's dependencies like Selenium is a good route, or whether an approach where we rely on fewer third part libraries would be better.

Andi added a subscriber: Andi.Feb 2 2020, 10:09 AM