index.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!doctype html>
  2. <meta charset="utf-8"/>
  3. <title>CodeMirror: Test Suite</title>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <link rel="stylesheet" href="mode_test.css">
  7. <script src="../doc/activebookmark.js"></script>
  8. <script src="../lib/codemirror.js"></script>
  9. <script src="../mode/meta.js"></script>
  10. <script src="../addon/mode/overlay.js"></script>
  11. <script src="../addon/mode/multiplex.js"></script>
  12. <script src="../addon/search/searchcursor.js"></script>
  13. <script src="../addon/dialog/dialog.js"></script>
  14. <script src="../addon/edit/matchbrackets.js"></script>
  15. <script src="../addon/hint/sql-hint.js"></script>
  16. <script src="../addon/hint/xml-hint.js"></script>
  17. <script src="../addon/hint/html-hint.js"></script>
  18. <script src="../addon/comment/comment.js"></script>
  19. <script src="../addon/mode/simple.js"></script>
  20. <script src="../mode/css/css.js"></script>
  21. <script src="../mode/clike/clike.js"></script>
  22. <!-- clike must be after css or vim and sublime tests will fail -->
  23. <script src="../mode/clojure/clojure.js"></script>
  24. <script src="../mode/cypher/cypher.js"></script>
  25. <script src="../mode/d/d.js"></script>
  26. <script src="../mode/dockerfile/dockerfile.js"></script>
  27. <script src="../mode/gfm/gfm.js"></script>
  28. <script src="../mode/haml/haml.js"></script>
  29. <script src="../mode/htmlmixed/htmlmixed.js"></script>
  30. <script src="../mode/javascript/javascript.js"></script>
  31. <script src="../mode/jsx/jsx.js"></script>
  32. <script src="../mode/markdown/markdown.js"></script>
  33. <script src="../mode/php/php.js"></script>
  34. <script src="../mode/python/python.js"></script>
  35. <script src="../mode/powershell/powershell.js"></script>
  36. <script src="../mode/ruby/ruby.js"></script>
  37. <script src="../mode/sass/sass.js"></script>
  38. <script src="../mode/shell/shell.js"></script>
  39. <script src="../mode/slim/slim.js"></script>
  40. <script src="../mode/soy/soy.js"></script>
  41. <script src="../mode/sql/sql.js"></script>
  42. <script src="../mode/stex/stex.js"></script>
  43. <script src="../mode/swift/swift.js"></script>
  44. <script src="../mode/textile/textile.js"></script>
  45. <script src="../mode/verilog/verilog.js"></script>
  46. <script src="../mode/xml/xml.js"></script>
  47. <script src="../mode/xquery/xquery.js"></script>
  48. <script src="../keymap/emacs.js"></script>
  49. <script src="../keymap/sublime.js"></script>
  50. <script src="../keymap/vim.js"></script>
  51. <script src="../mode/rust/rust.js"></script>
  52. <script src="../mode/mscgen/mscgen.js"></script>
  53. <script src="../mode/dylan/dylan.js"></script>
  54. <style type="text/css">
  55. .ok {color: #090;}
  56. .fail {color: #e00;}
  57. .error {color: #c90;}
  58. .done {font-weight: bold;}
  59. #progress {
  60. background: #45d;
  61. color: white;
  62. text-shadow: 0 0 1px #45d, 0 0 2px #45d, 0 0 3px #45d;
  63. font-weight: bold;
  64. white-space: pre;
  65. }
  66. #testground {
  67. visibility: hidden;
  68. }
  69. #testground.offscreen {
  70. visibility: visible;
  71. position: absolute;
  72. left: -10000px;
  73. top: -10000px;
  74. }
  75. .CodeMirror { border: 1px solid black; }
  76. </style>
  77. <div id=nav>
  78. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  79. <ul>
  80. <li><a href="../index.html">Home</a>
  81. <li><a href="../doc/manual.html">Manual</a>
  82. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  83. </ul>
  84. <ul>
  85. <li><a class=active href="#">Test suite</a>
  86. </ul>
  87. </div>
  88. <article>
  89. <h2>Test Suite</h2>
  90. <p>A limited set of programmatic sanity tests for CodeMirror.</p>
  91. <div style="border: 1px solid black; padding: 1px; max-width: 700px;">
  92. <div style="width: 0px;" id=progress><div style="padding: 3px;">Ran <span id="progress_ran">0</span><span id="progress_total"> of 0</span> tests</div></div>
  93. </div>
  94. <p id=status>Please enable JavaScript...</p>
  95. <div id=output></div>
  96. <div id=testground></div>
  97. <script src="driver.js"></script>
  98. <script src="test.js"></script>
  99. <script src="doc_test.js"></script>
  100. <script src="multi_test.js"></script>
  101. <script src="contenteditable_test.js"></script>
  102. <script src="scroll_test.js"></script>
  103. <script src="comment_test.js"></script>
  104. <script src="search_test.js"></script>
  105. <script src="mode_test.js"></script>
  106. <script src="../mode/clike/test.js"></script>
  107. <script src="../mode/clojure/test.js"></script>
  108. <script src="../mode/css/test.js"></script>
  109. <script src="../mode/css/gss_test.js"></script>
  110. <script src="../mode/css/scss_test.js"></script>
  111. <script src="../mode/css/less_test.js"></script>
  112. <script src="../mode/cypher/test.js"></script>
  113. <script src="../mode/d/test.js"></script>
  114. <script src="../mode/dockerfile/test.js"></script>
  115. <script src="../mode/gfm/test.js"></script>
  116. <script src="../mode/haml/test.js"></script>
  117. <script src="../mode/javascript/test.js"></script>
  118. <script src="../mode/jsx/test.js"></script>
  119. <script src="../mode/markdown/test.js"></script>
  120. <script src="../mode/php/test.js"></script>
  121. <script src="../mode/powershell/test.js"></script>
  122. <script src="../mode/ruby/test.js"></script>
  123. <script src="../mode/sass/test.js"></script>
  124. <script src="../mode/shell/test.js"></script>
  125. <script src="../mode/slim/test.js"></script>
  126. <script src="../mode/soy/test.js"></script>
  127. <script src="../mode/stex/test.js"></script>
  128. <script src="../mode/swift/test.js"></script>
  129. <script src="../mode/textile/test.js"></script>
  130. <script src="../mode/verilog/test.js"></script>
  131. <script src="../mode/xml/test.js"></script>
  132. <script src="../mode/xquery/test.js"></script>
  133. <script src="../mode/python/test.js"></script>
  134. <script src="../mode/rust/test.js"></script>
  135. <script src="../mode/mscgen/mscgen_test.js"></script>
  136. <script src="../mode/mscgen/xu_test.js"></script>
  137. <script src="../mode/mscgen/msgenny_test.js"></script>
  138. <script src="../mode/dylan/test.js"></script>
  139. <script src="../addon/mode/multiplex_test.js"></script>
  140. <script src="emacs_test.js"></script>
  141. <script src="sql-hint-test.js"></script>
  142. <script src="sublime_test.js"></script>
  143. <script src="vim_test.js"></script>
  144. <script src="html-hint-test.js"></script>
  145. <script>
  146. window.onload = runHarness;
  147. CodeMirror.on(window, 'hashchange', runHarness);
  148. function esc(str) {
  149. return str.replace(/[<&]/, function(ch) { return ch == "<" ? "&lt;" : "&amp;"; });
  150. }
  151. var output = document.getElementById("output"),
  152. progress = document.getElementById("progress"),
  153. progressRan = document.getElementById("progress_ran").childNodes[0],
  154. progressTotal = document.getElementById("progress_total").childNodes[0];
  155. var count = 0,
  156. failed = 0,
  157. skipped = 0,
  158. bad = "",
  159. running = false, // Flag that states tests are running
  160. quit = false, // Flag to quit tests ASAP
  161. verbose = false; // Adds message for *every* test to output
  162. function runHarness(){
  163. if (running) {
  164. quit = true;
  165. setStatus("Restarting tests...", '', true);
  166. setTimeout(function(){runHarness();}, 500);
  167. return;
  168. }
  169. filters = [];
  170. verbose = false;
  171. if (window.location.hash.substr(1)){
  172. var strings = window.location.hash.substr(1).split(",");
  173. while (strings.length) {
  174. var s = strings.shift();
  175. if (s === "verbose")
  176. verbose = true;
  177. else
  178. filters.push(parseTestFilter(decodeURIComponent(s)));
  179. }
  180. }
  181. quit = false;
  182. running = true;
  183. setStatus("Loading tests...");
  184. count = 0;
  185. failed = 0;
  186. skipped = 0;
  187. bad = "";
  188. totalTests = countTests();
  189. progressTotal.nodeValue = " of " + totalTests;
  190. progressRan.nodeValue = count;
  191. output.innerHTML = '';
  192. document.getElementById("testground").innerHTML = "<form>" +
  193. "<textarea id=\"code\" name=\"code\"></textarea>" +
  194. "<input type=submit value=ok name=submit>" +
  195. "</form>";
  196. runTests(displayTest);
  197. }
  198. function setStatus(message, className, force){
  199. if (quit && !force) return;
  200. if (!message) throw("must provide message");
  201. var status = document.getElementById("status").childNodes[0];
  202. status.nodeValue = message;
  203. status.parentNode.className = className;
  204. }
  205. function addOutput(name, className, code){
  206. var newOutput = document.createElement("dl");
  207. var newTitle = document.createElement("dt");
  208. newTitle.className = className;
  209. newTitle.appendChild(document.createTextNode(name));
  210. newOutput.appendChild(newTitle);
  211. var newMessage = document.createElement("dd");
  212. newMessage.innerHTML = code;
  213. newOutput.appendChild(newTitle);
  214. newOutput.appendChild(newMessage);
  215. output.appendChild(newOutput);
  216. }
  217. function displayTest(type, name, customMessage) {
  218. var message = "???";
  219. if (type != "done" && type != "skipped") ++count;
  220. progress.style.width = (count * (progress.parentNode.clientWidth - 2) / (totalTests || 1)) + "px";
  221. progressRan.nodeValue = count;
  222. if (type == "ok") {
  223. message = "Test '" + name + "' passed";
  224. if (!verbose) customMessage = false;
  225. } else if (type == "skipped") {
  226. message = "Test '" + name + "' skipped";
  227. ++skipped;
  228. if (!verbose) customMessage = false;
  229. } else if (type == "expected") {
  230. message = "Test '" + name + "' failed as expected";
  231. if (!verbose) customMessage = false;
  232. } else if (type == "error" || type == "fail") {
  233. ++failed;
  234. message = "Test '" + name + "' failed";
  235. } else if (type == "done") {
  236. if (failed) {
  237. type += " fail";
  238. message = failed + " failure" + (failed > 1 ? "s" : "");
  239. } else if (count < totalTests) {
  240. failed = totalTests - count;
  241. type += " fail";
  242. message = failed + " failure" + (failed > 1 ? "s" : "");
  243. } else {
  244. type += " ok";
  245. message = "All passed";
  246. if (skipped) {
  247. message += " (" + skipped + " skipped)";
  248. }
  249. }
  250. progressTotal.nodeValue = '';
  251. customMessage = true; // Hack to avoid adding to output
  252. }
  253. if (verbose && !customMessage) customMessage = message;
  254. setStatus(message, type);
  255. if (customMessage && customMessage.length > 0) {
  256. addOutput(name, type, customMessage);
  257. }
  258. }
  259. </script>
  260. </article>