Difference between revisions of "JavascriptCompressionTesting"
Umar Sheikh (talk | contribs) m (u) |
|||
| Line 19: | Line 19: | ||
* Even if this doesn't prove useful I'm curious to know how it worked. -[[User:Stephen Judkins|Stephen Judkins]] 23:51, 30 January 2008 (PST) | * Even if this doesn't prove useful I'm curious to know how it worked. -[[User:Stephen Judkins|Stephen Judkins]] 23:51, 30 January 2008 (PST) | ||
* useful link: [http://www.mikechambers.com/blog/2003/12/06/shell-scripting-on-os-x-with-ecma-javascript] | * useful link: [http://www.mikechambers.com/blog/2003/12/06/shell-scripting-on-os-x-with-ecma-javascript] | ||
| − | * how to include files, for example, in ruby console, we can say: require 'irb/completion'. how to do sth like : inlcude 'jquery.js' using this shell? | + | * how to include files, for example, in ruby console, we can say: require 'irb/completion'. how to do sth like : inlcude 'jquery.js' using this shell? Without this power, it doesn't look of much use??? |
[[Category:DevelopmentTeam]] | [[Category:DevelopmentTeam]] | ||
Revision as of 12:36, 31 January 2008
What (summary)
We want an automated test to make sure our javascript doesn't have invalid syntax that emerges when packed.
Why this is important
It is annoying to have to set $auPackJavascript = true; every time one wants to deploy new code. Setting javascript packing to false is useful to keep on during development.
DoneDone
If the javascript files contain a syntax error that causes decompression to fail, running "rake test integration" both show an error.
Steps to get to DoneDone
- Check to see how easy it is to get [Rhino|http://developer.mozilla.org/en/docs/Rhino_Shell] running on everyone's computer.
- Is it easy to install Java? If it seems like a too difficult process then forget about this entire task.
- On the other hand, there are many useful Java tools we may want to be able to use...and Mac OS already has it installed
- You'd probably want to distribute the Rhino [jar|http://www.mozilla.org/rhino/download.html] with the repo.
- Shelling out to the command line is probably how to go.
- Even if this doesn't prove useful I'm curious to know how it worked. -Stephen Judkins 23:51, 30 January 2008 (PST)
- useful link: [1]
- how to include files, for example, in ruby console, we can say: require 'irb/completion'. how to do sth like : inlcude 'jquery.js' using this shell? Without this power, it doesn't look of much use???
Install instructions
- Instructions taken from here
- make sure you have java installed. You can check this by typing "java" at your command prompt and reading the output
- download Rhino from [2], (click on the "Rhino---.zip" file, the '---' representing version)
- unzip it, and copy the "js.jar" file to "/www/sites/branches/classpath/js.jar"
- open up your .bashrc file to export path to the jar file. Your paths shoudl look like this:
- CLASSPATH="/www/sites/classpath:/www/sites/classpath/js.jar"
- PATH="/www/bin:/www/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/s bin:/bin:/usr/games"
- export PATH CLASSPATH
- alias js='java org.mozilla.javascript.tools.shell.Main'|}
- close your shell prompt and reopen it to make the changes take effect
- Test your installations:
- create a js file, example helloworld.js, and write
- print("Hello world");
- save and close it
- run it by typing :
- java org.mozilla.javascript.tools.shell.Main helloworld.js
- your shell output should read:
- Hello world
- Your are done!
- note: the line: "alias js='java org.mozilla.javascript.tools.shell.Main'" in the bashrc file enables you to write "js helloworld.js" instead of the lengthy "java org.mozilla.javascript.tools.shell.Main helloworld.js".
- if in following these instructions, you come across an error/omission/ambiguity etc, do not hesitate to make constructive edits to rectify it, or at least report a problem. Thanks!

