index.html 11 KB

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