Skip to content

Commit

Permalink
New unit testing scripts and much more from Larry Lawjoskar http://gi…
Browse files Browse the repository at this point in the history
…thub.com/Lawjoskar.  Thanks Larry
  • Loading branch information
thatcher committed Feb 17, 2009
1 parent be17195 commit a8c5a3a
Show file tree
Hide file tree
Showing 24 changed files with 4,468 additions and 8,013 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@

ENV = dist/env.rhino.js
TEST = test/test.js

JAR = java -jar rhino/js.jar

test-rhino:
@@${JAR} ${TEST}
ant -emacs test

run-rhino:
echo "load('dist/env.rhino.js');window.location='test/index.html';" | ${JAR}
9 changes: 7 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Building:
* Creates a platform-agnostic "dist/env.js" file and a Rhino-specific "dist/env.rhino.js" file.

Testing:
* run "make rhino-test"
* run "ant test"

Installing:
1) Include the proper env.js file for your platform.
Expand Down Expand Up @@ -55,4 +55,9 @@ Installing:
// tell env.js the base DOM to model
// run any setup code for your framework
// tell the framework that the document is loaded


Testing jQuery Compatibility:
* run ./bin/test-jquery.sh 1.2.6
* run ./bin/test-jquery.sh 1.3.1
* Checks out the given jQuery tag from Subversion into test/vendor/jQuery/[version], moves dist/env.rhino.js into
the correct location in their tree, and runs the test suites.
28 changes: 28 additions & 0 deletions bin/jquery-1.2.6-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Init
load("build/runtest/env.js");

window.onload = function(){
// Load the test runner
load("dist/jquery.js","build/runtest/testrunner.js");

// Load the tests
load(
"test/unit/core.js",
"test/unit/selector.js",
"test/unit/event.js",
"test/unit/fx.js",
"test/unit/dimensions.js"

// offset relies on window.open, which is currently unimplemented in env.js
//"test/unit/offset.js",

// these tests require hitting a server, so we will need some clever env.js
// way of testing them
//"test/unit/ajax.js"
);

// Display the results
results();
};

window.location = "test/index.html";
29 changes: 29 additions & 0 deletions bin/jquery-1.3.1-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Init
load("build/runtest/env.js");

window.onload = function(){
// Load the test runner
load("dist/jquery.js","build/runtest/testrunner.js");

// Load the tests
load(
"test/unit/core.js",
"test/unit/selector.js",
"test/unit/event.js",
"test/unit/fx.js",
"test/unit/dimensions.js",
"test/unit/data.js"

// offset relies on window.open, which is currently unimplemented in env.js
//"test/unit/offset.js",

// these tests require hitting a server, so we will need some clever env.js
// way of testing them
//"test/unit/ajax.js"
);

// Display the results
results();
};

window.location = "test/index.html";
22 changes: 22 additions & 0 deletions bin/test-jquery.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# Usage: test-jquery.sh [version]
# Currently supported versions: 1.2.6 & 1.3.1
#
# This script will check out the jQuery development tree from Subversion if necessary,
# massage the testing scripts as necessary, copy our latest version of env.js into place,
# and then run the test scripts.

if [ -n "$1" ]; then VERSION="$1"; else VERSION="1.2.6"; fi
JQUERY_DIR="test/vendor/jQuery/$VERSION"

if [ ! -d "$JQUERY_DIR" ]; then
svn export http://jqueryjs.googlecode.com/svn/tags/$VERSION/ $JQUERY_DIR
fi

cp dist/env.rhino.js $JQUERY_DIR/build/runtest/env.js
cp rhino/js.jar $JQUERY_DIR/build/js.jar
cp bin/jquery-$VERSION-test.js $JQUERY_DIR/build/runtest/test.js

cd $JQUERY_DIR
make runtest
28 changes: 4 additions & 24 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,30 +125,10 @@
<echo message="${ENV_RHINO} built." />
</target>

<target name="test-jquery-1.2.6">
<echo message="Running jQuery-1.2.6 Tests"/>
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true">
<!--arg line='-e load("/dist/env.rhino.js"); window.location="test/jquery/1.2.6/index.html";' /-->
<arg value='-e'/>
<arg value='load(\"dist\/env.rhino.js\"); window.location=\"test\/jquery\/1.2.6\/index.html\";' />
<classpath>
<pathelement location="${RHINO_JAR}"/>
</classpath>
</java>
<echo message="Finished jQuery-1.2.6 Tests" />
</target>

<target name="test-prototype">
<echo message="Running Prototype-1.6.0.3 Tests"/>
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true">
<!--arg line='-e load("/dist/env.rhino.js"); window.location="test/jquery/1.2.6/index.html";' /-->
<arg value='-e'/>
<arg value='load(\"dist\/env.rhino.js\"); window.location=\"test\/prototype\/1.6.0.3\/index.html\"; load(\"test\/prototype\/1.6.0.3\/unit\/dom_test.js\"); __env__.writeToFile(document.documentElement.xml, __env__.location(\"test\/prototype\/1.6.0.3\/results\/dom.html\"));' />
<classpath>
<pathelement location="${RHINO_JAR}"/>
</classpath>
</java>
<echo message="Finished Prototype-1.6.0.3 Tests" />
<target name="test" description="Run the tests">
<java fork="true" jar="rhino/js.jar">
<arg value="test/test.js"/>
</java>
</target>

</project>
197 changes: 0 additions & 197 deletions test/index - Copy.html

This file was deleted.

27 changes: 14 additions & 13 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "../DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Test Suite</title>
<link rel="Stylesheet" media="screen" href="data/testsuite.css" />
<!-- Includes -->
<!--script type="text/javascript">
<script type="text/javascript">
var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$",
originaljQuery = jQuery,
original$ = $;
</script-->
<script type="text/javascript;text/envjs" src="jquery.js"></script>
<script type="text/javascript;text/envjs" src="testrunner.js"></script>
<script type="text/javascript;text/envjs" src="unit/core.js"></script>
<!--script type="text/javascript;text/envjs" src="unit/dimensions.js"></script>
<script type="text/javascript;text/envjs" src="unit/selector.js"></script>
<script type="text/javascript;text/envjs" src="unit/event.js"></script>
<script type="text/javascript;text/envjs" src="unit/ajax.js"></script>
<script type="text/javascript;text/envjs" src="unit/fx.js"></script-->
<script type="text/javascript;text/envjs" src="unit/prototypecompat.js"></script>
</script>
<script type="text/javascript" src="../dist/jquery.js"></script>
<script type="text/javascript" src="data/testrunner.js"></script>
<script type="text/javascript" src="unit/core.js"></script>
<script type="text/javascript" src="unit/dimensions.js"></script>
<script type="text/javascript" src="unit/selector.js"></script>
<script type="text/javascript" src="unit/event.js"></script>
<script type="text/javascript" src="unit/ajax.js"></script>
<script type="text/javascript" src="unit/fx.js"></script>
</head>
<body id="body">
<h1 id="header">jQuery Test Suite</h1>
Expand Down Expand Up @@ -175,4 +176,4 @@ <h2 id="userAgent"></h2>
</dl>
<ol id="tests"></ol>
</body>
</html>
</html>
Loading

0 comments on commit a8c5a3a

Please sign in to comment.