Giter VIP home page Giter VIP logo

Comments (1)

j1mr10rd4n avatar j1mr10rd4n commented on August 18, 2024

Hi Martin,

I've created a test-externs branch with an idea for a testing strategy. It uses processing-js as an example because it was requested in #18 and also because processing-js has a comprehensive reference test suite.

This branch's build.boot introduces a test-externs task that processes the reference tests using the Google Closure Compiler with advanced-optimizations before running them against the processing-js library in a PhantomJS instance. There are a couple of extra details due to the way the reference tests are written (see list of steps further down) but this is illustrates the strategy. It could probably be used on other js libraries that have reasonable test suites.

As it stands, only the test code is processed by the google closure compiler. The processing-js library itself is linked as an external library in the test suite. I don't think the processing-js code is compatible with advanced-optimizations and would have to be included as a foreign-lib. The externs ensure that client code is compatible - this testing strategy has already highlighted an error and some omissions in the file pulled from quil/processing-js.

List of Steps

  • Convert reference tests from .pde to .js.
    The reference tests are actually written in the Processing DSL. The test-externs task's first step is to use processing-js in a PhantomJS instance to Processing.compile() the reference tests to javascript. The javascript versions are written to files with proper goog.provide namespaces.
  • Write a doo wrapper that requires the javascript reference test namespaces. The wrapper invokes code that will launch and monitor the test progress in a PhantomJS instance.
  • Process the wrapper and reference tests through the google closure compiler with advanced optimizations and the package's externs file.
  • Munge the test suite so that, for each reference test, the optimized code is injected in place of the standard code. Munge the list of tests to exclude any that we know will fail (see limitations below).
  • Run the test suite and report.

Limitations / Further Work

  • Because it's running in PhantomJS, only the 2D reference tests are exercised - could use a full browser (e.g.Firefox) instead of PhantomJS to include the 3D tests as well.
  • Any code that declares its own classes in the Processing DSL, when compiled to javascript using Processing.compile() is implemented using dynamic class decorators like addMethod(). This means that the new method is declared using a string and the google closure compiler will not touch it. However the actual function call to the method will get munged. To fix this, the function name needs to be exported but this would be the author's responsibility or would require a change in the implementation of Processing.compile().
  • Each javascript library will have its own testing strategy, so any automated externs tests would have to be bespoke.
  • I'm fairly new to clojure so I'm sure my code can be improved!

I'd be very interested in your (and others') thoughts on this as a general approach to testing externs files. If you think this might be a useful package to add to cljsjs, I'd be happy to open a PR.

from packages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.