Permalink
Browse files

Testing Framework Upgrade Part I

This first part of the testing framework upgrade:

- enhances the jsdoc script to allow switching to debug mode from the command line
- uses Jasmine to run tests
- adds flexibility to run tests from multiple root directories
- does automatic test discovery, so test files can just be created, dropped in an appropriate folder, and run without having to explicity add it to the test runner
- cleans up the test directory layout
- incorporates env.rhino.js which should make it easier to test templates
- is incomplete: this is just a savepoint.  About 1/3 of the tests have been converted.  The rest are still run through the old testrunner
  • Loading branch information...
1 parent e35ddfa commit 2d73440b3d42b0e4bbab7418fb11e187a07b25bd @jannon jannon committed May 1, 2012
Showing with 18,495 additions and 829 deletions.
  1. +19 −2 jsdoc
  2. +2 −3 lib/rhino-shim.js
  3. +64 −43 node_modules/common/args.js
  4. +27 −22 rhino_modules/fs.js
  5. +9 −5 rhino_modules/jsdoc/opts/parser.js
  6. +1 −1 rhino_modules/jsdoc/src/handlers.js
  7. +2 −2 rhino_modules/jsdoc/src/parser.js
  8. +134 −5 rhino_modules/path.js
  9. +42 −2 test/README.md
  10. +56 −0 test/async-callback.js
  11. 0 test/{cases → fixtures}/src/_dir2/four.js
  12. 0 test/{cases → fixtures}/src/_ignored.js
  13. 0 test/{cases → fixtures}/src/dir1/three.js
  14. 0 test/{cases → fixtures}/src/ignored.txt
  15. 0 test/{cases → fixtures}/src/one.js
  16. 0 test/{cases → fixtures}/src/two.js
  17. +128 −0 test/jasmine-jsdoc.js
  18. +14,006 −0 test/lib/env.rhino.js
  19. +2,547 −0 test/lib/jasmine.js
  20. +299 −0 test/reporter.js
  21. +171 −126 test/runner.js
  22. +51 −0 test/spec-collection.js
  23. +36 −0 test/specs/common/events.js
  24. +18 −0 test/specs/common/query.js
  25. +77 −0 test/specs/common/util.js
  26. +2 −2 test/{t/cases → specs/documentation}/also.js
  27. 0 test/{t/cases → specs/documentation}/constructorproperty.js
  28. 0 test/{t/cases → specs/documentation}/exports.js
  29. 0 test/{t/cases → specs/documentation}/inlinecomment.js
  30. 0 test/{t/cases → specs/documentation}/inner.js
  31. 0 test/{t/cases → specs/documentation}/innerscope.js
  32. 0 test/{t/cases → specs/documentation}/innerscope2.js
  33. 0 test/{t/cases → specs/documentation}/moduleinner.js
  34. +22 −0 test/specs/documentation/modules.js
  35. 0 test/{t/cases → specs/documentation}/namedFuncStatement.js
  36. 0 test/{t/cases → specs/documentation}/objectlit.js
  37. 0 test/{t/cases → specs/documentation}/objectlit2.js
  38. 0 test/{t/cases → specs/documentation}/quotename.js
  39. 0 test/{t/cases → specs/documentation}/quotename2.js
  40. 0 test/{t/cases → specs/documentation}/starbangstar.js
  41. 0 test/{t/cases → specs/documentation}/this-and-objectlit.js
  42. 0 test/{t/cases → specs/documentation}/this.js
  43. 0 test/{t/cases → specs/documentation}/this2.js
  44. 0 test/{t/cases → specs/documentation}/this3.js
  45. 0 test/{t/cases → specs/documentation}/var.js
  46. 0 test/{t/cases → specs/documentation}/variations.js
  47. 0 test/{t/cases → specs/documentation}/virtual.js
  48. +34 −0 test/specs/helpers.js
  49. +3 −0 test/specs/jsdoc/augment.js
  50. +3 −0 test/specs/jsdoc/borrow.js
  51. +3 −0 test/specs/jsdoc/doclet.js
  52. +157 −0 test/specs/jsdoc/name.js
  53. +216 −0 test/specs/jsdoc/opts/parser.js
  54. +54 −0 test/specs/jsdoc/src/handlers.js
  55. +44 −0 test/specs/jsdoc/src/parser.js
  56. +17 −0 test/specs/jsdoc/src/scanner.js
  57. +3 −0 test/specs/jsdoc/tag/dictionary.js
  58. +3 −0 test/specs/jsdoc/tag/type.js
  59. +3 −0 test/specs/jsdoc/tag/validator.js
  60. +101 −0 test/specs/jsdoc/util/dumper.js
  61. +141 −0 test/specs/jsdoc/util/templateHelper.js
  62. 0 test/{t/cases → specs/tags}/abstracttag.js
  63. 0 test/{t/cases → specs/tags}/accesstag.js
  64. 0 test/{t/cases → specs/tags}/alias.js
  65. 0 test/{t/cases → specs/tags}/alias2.js
  66. 0 test/{t/cases → specs/tags}/alias3.js
  67. 0 test/{t/cases → specs/tags}/aliasglobal.js
  68. 0 test/{t/cases → specs/tags}/aliasresolve.js
  69. 0 test/{t/cases → specs/tags}/aliasresolve2.js
  70. 0 test/{t/cases → specs/tags}/augmentstag.js
  71. 0 test/{t/cases → specs/tags}/authortag.js
  72. 0 test/{t/cases → specs/tags}/borrowstag.js
  73. 0 test/{t/cases → specs/tags}/borrowstag2.js
  74. 0 test/{t/cases → specs/tags}/classtag.js
  75. 0 test/{t/cases → specs/tags}/constructortag.js
  76. 0 test/{t/cases → specs/tags}/constructstag.js
  77. 0 test/{t/cases → specs/tags}/constructstag2.js
  78. 0 test/{t/cases → specs/tags}/constructstag3.js
  79. 0 test/{t/cases → specs/tags}/constructstag4.js
  80. 0 test/{t/cases → specs/tags}/constructstag5.js
  81. 0 test/{t/cases → specs/tags}/copyrighttag.js
  82. 0 test/{t/cases → specs/tags}/defaulttag.js
  83. 0 test/{t/cases → specs/tags}/deprecatedtag.js
  84. 0 test/{t/cases → specs/tags}/enumtag.js
  85. 0 test/{t/cases → specs/tags}/eventfirestag.js
  86. 0 test/{t/cases → specs/tags}/exceptiontag.js
  87. 0 test/{t/cases → specs/tags}/exportstag.js
  88. 0 test/{t/cases → specs/tags}/exportstag2.js
  89. 0 test/{t/cases → specs/tags}/exportstag3.js
  90. 0 test/{t/cases → specs/tags}/exportstag4.js
  91. 0 test/{t/cases → specs/tags}/file.js
  92. 0 test/{t/cases → specs/tags}/globaltag.js
  93. 0 test/{t/cases → specs/tags}/ignoretag.js
  94. 0 test/{t/cases → specs/tags}/lends.js
  95. 0 test/{t/cases → specs/tags}/lends2.js
  96. 0 test/{t/cases → specs/tags}/lendsglobal.js
  97. 0 test/{t/cases → specs/tags}/memberoftag.js
  98. 0 test/{t/cases → specs/tags}/memberoftag2.js
  99. 0 test/{t/cases → specs/tags}/memberoftag3.js
  100. 0 test/{t/cases → specs/tags}/memberoftag4.js
  101. 0 test/{t/cases → specs/tags}/memberoftagforced.js
  102. 0 test/{t/cases → specs/tags}/moduletag.js
  103. 0 test/{t/cases → specs/tags}/moduletag2.js
  104. 0 test/{t/cases → specs/tags}/paramtag.js
  105. 0 test/{t/cases → specs/tags}/privatetag.js
  106. 0 test/{t/cases → specs/tags}/projecttag.js
  107. 0 test/{t/cases → specs/tags}/readonlytag.js
  108. 0 test/{t/cases → specs/tags}/requirestag.js
  109. 0 test/{t/cases → specs/tags}/returnstag.js
  110. 0 test/{t/cases → specs/tags}/seetag.js
  111. 0 test/{t/cases → specs/tags}/sincetag.js
  112. 0 test/{t/cases → specs/tags}/thistag.js
  113. 0 test/{t/cases → specs/tags}/typedeftag.js
  114. 0 test/{t/cases → specs/tags}/typekind.js
  115. 0 test/{t/cases → specs/tags}/typetag.js
  116. 0 test/{t/cases → specs/tags}/variations3.js
  117. 0 test/{t/cases → specs/tags}/versiontag.js
  118. +0 −18 test/t/cases/modules/data/mod-1.js
  119. +0 −18 test/t/cases/modules/data/mod-2.js
  120. +0 −18 test/t/cases/modules/data/mod-3.js
  121. +0 −91 test/t/common/dumper.js
  122. +0 −34 test/t/common/events.js
  123. +0 −16 test/t/common/query.js
  124. +0 −19 test/t/common/scanner.js
  125. +0 −51 test/t/common/util.js
  126. +0 −127 test/t/jsdoc/name.js
  127. +0 −37 test/t/jsdoc/opts/parser.js
  128. +0 −16 test/t/jsdoc/src/handlers.js
  129. +0 −52 test/t/jsdoc/src/parser.js
  130. +0 −119 test/t/jsdoc/util/templateHelper.js
View
21 jsdoc
@@ -4,6 +4,23 @@
SOURCE="$0"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.shell.Main -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@
-#java -classpath ${BASEDIR}/lib/js.jar org.mozilla.javascript.tools.debugger.Main -debug -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@
+if test $1 = "--debug"
+then
+ CMD="org.mozilla.javascript.tools.debugger.Main -debug"
+ shift
+else
+ CMD="org.mozilla.javascript.tools.shell.Main"
+fi
+
+#Conditionally execute different command lines depending on whether we're running tests or not
+if test $1 = "-T"
+then
+ echo "Running Tests"
+ java -classpath ${BASEDIR}/lib/js.jar ${CMD} -opt -1 -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@
+else
+ echo "Running Normal"
+ java -classpath ${BASEDIR}/lib/js.jar ${CMD} -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@
+fi
+
+#java -classpath ${BASEDIR}/lib/js.jar ${CMD} -modules ${BASEDIR}/node_modules -modules ${BASEDIR}/rhino_modules -modules ${BASEDIR} ${BASEDIR}/jsdoc.js --dirname=${BASEDIR} $@
View
@@ -11,13 +11,13 @@ console = {
log: function(/*...*/) {
var args = Array.prototype.slice.call(arguments, 0),
dumper = dumper || require('jsdoc/util/dumper');
-
+
for (var i = 0, len = args.length; i < len; i++) {
if (typeof args[i] !== 'string') {
args[i] = dumper.dump(args[i]);
}
}
-
+
print( args.join(' ') );
}
};
@@ -33,4 +33,3 @@ process = {
},
argv: [__dirname + '/jsdoc.js'].concat(Array.prototype.slice.call(arguments, 0))
};
-
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -7,12 +7,17 @@ exports.readFileSync = function(filename, encoding) {
var readdirSync = exports.readdirSync = function(path) {
var dir,
files;
-
+
dir = new java.io.File(path);
if (!dir.directory) { return [String(dir)]; }
-
+
files = dir.list();
-
+
+ //Convert files to Javascript strings so they play nice with node modules
+ files = files.map(function(fileName) {
+ return String(fileName);
+ });
+
return files;
};
@@ -24,20 +29,20 @@ var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
_allFiles = [];
_path = [dir];
}
-
+
if (_path.length === 0) { return _allFiles; }
if (typeof recurse === 'undefined') { recurse = 1; }
-
+
if ( stat(dir).isFile(dir) ) {
files = [dir];
}
else {
files = readdirSync(dir);
}
-
+
for (var f = 0, lenf = files.length; f < lenf; f++) {
file = String(files[f]);
-
+
if (file.match(/^\.[^\.\/\\]/)) { continue; } // skip dot files
if ((new java.io.File(_path.join('/') + '/' + file)).list()) { // it's a directory
@@ -48,7 +53,7 @@ var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
}
_path.pop();
}
- else { // it's a file
+ else { // it's a file
_allFiles.push(
(_path.join('/') + '/' + file).replace(/[\/\\]+/g, '/')
);
@@ -58,21 +63,21 @@ var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
return _allFiles;
};
-var stat = exports.stat = function(path, encoding) {
- var f = new java.io.File(path)
+var stat = exports.stat = exports.statSync = function(path, encoding) {
+ var f = new java.io.File(path);
return {
isFile: function() {
return f.isFile();
},
- isDir: function() {
+ isDirectory: function() {
return f.isDirectory();
}
- }
+ };
};
exports.mkPath = function(/**Array*/ path) {
- if (path.constructor != Array) path = path.split(/[\\\/]/);
+ if (path.constructor != Array){path = path.split(/[\\\/]/);}
var make = "";
for (var i = 0, l = path.length; i < l; i++) {
make += path[i] + '/';
@@ -104,25 +109,25 @@ function exists(path) {
var toDir = exports.toDir = function(path) {
var f = new java.io.File(path);
-
+
if (f.isDirectory()){
return path;
}
-
+
var parts = path.split(/[\\\/]/);
parts.pop();
-
+
return parts.join('/');
};
exports.copyFile = function(inFile, outDir, fileName) {
- if (fileName == null) fileName = toFile(inFile);
-
+ if (fileName == null){fileName = toFile(inFile);}
+
outDir = toDir(outDir);
-
+
var inFile = new java.io.File(inFile);
var outFile = new java.io.File(outDir+'/'+fileName);
-
+
var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096);
var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096);
var theChar;
@@ -136,7 +141,7 @@ exports.copyFile = function(inFile, outDir, fileName) {
var toFile = exports.toFile = function(path) {
var parts = path.split(/[\\\/]/);
return parts.pop();
-}
+};
exports.writeFileSync = function(filename, data, encoding) {
encoding = encoding || 'utf-8';
@@ -147,7 +152,7 @@ exports.writeFileSync = function(filename, data, encoding) {
encoding
)
);
-
+
try {
out.write(data);
}
Oops, something went wrong.

0 comments on commit 2d73440

Please sign in to comment.