You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
11 KiB

5 months ago
  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/5"><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/codemirror5">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="html-hint-test.js"></script>
  154. <script src="annotatescrollbar.js"></script>
  155. <script>
  156. window.onload = runHarness;
  157. CodeMirror.on(window, 'hashchange', runHarness);
  158. function esc(str) {
  159. return str.replace(/[<&]/, function(ch) { return ch == "<" ? "&lt;" : "&amp;"; });
  160. }
  161. var output = document.getElementById("output"),
  162. progress = document.getElementById("progress"),
  163. progressRan = document.getElementById("progress_ran").childNodes[0],
  164. progressTotal = document.getElementById("progress_total").childNodes[0];
  165. var count = 0,
  166. failed = 0,
  167. skipped = 0,
  168. bad = "",
  169. running = false, // Flag that states tests are running
  170. quit = false, // Flag to quit tests ASAP
  171. verbose = false, // Adds message for *every* test to output
  172. done = false
  173. function runHarness(){
  174. if (running) {
  175. quit = true;
  176. setStatus("Restarting tests...", '', true);
  177. setTimeout(function(){ runHarness(); }, 500);
  178. return;
  179. }
  180. filters = [];
  181. verbose = false;
  182. if (window.location.hash.substr(1)){
  183. var strings = window.location.hash.substr(1).split(",");
  184. while (strings.length) {
  185. var s = strings.shift();
  186. if (s === "verbose")
  187. verbose = true;
  188. else
  189. filters.push(parseTestFilter(decodeURIComponent(s)));
  190. }
  191. }
  192. quit = false;
  193. running = true;
  194. setStatus("Loading tests...");
  195. count = 0;
  196. failed = 0;
  197. done = false;
  198. skipped = 0;
  199. bad = "";
  200. totalTests = countTests();
  201. progressTotal.nodeValue = " of " + totalTests;
  202. progressRan.nodeValue = count;
  203. output.innerHTML = '';
  204. document.getElementById("testground").innerHTML = "<form>" +
  205. "<textarea id=\"code\" name=\"code\"></textarea>" +
  206. "<input type=submit value=ok name=submit>" +
  207. "</form>";
  208. runTests(displayTest);
  209. }
  210. function setStatus(message, className, force){
  211. if (quit && !force) return;
  212. if (!message) throw("must provide message");
  213. var status = document.getElementById("status").childNodes[0];
  214. status.nodeValue = message;
  215. status.parentNode.className = className;
  216. }
  217. function addOutput(name, className, code){
  218. var newOutput = document.createElement("dl");
  219. var newTitle = document.createElement("dt");
  220. newTitle.className = className;
  221. newTitle.appendChild(document.createTextNode(name));
  222. newOutput.appendChild(newTitle);
  223. var newMessage = document.createElement("dd");
  224. newMessage.innerHTML = code;
  225. newOutput.appendChild(newTitle);
  226. newOutput.appendChild(newMessage);
  227. output.appendChild(newOutput);
  228. }
  229. function displayTest(type, name, customMessage) {
  230. var message = "???";
  231. if (type != "done" && type != "skipped") ++count;
  232. progress.style.width = (count * (progress.parentNode.clientWidth - 2) / (totalTests || 1)) + "px";
  233. progressRan.nodeValue = count;
  234. if (type == "ok") {
  235. message = "Test '" + name + "' passed";
  236. if (!verbose) customMessage = false;
  237. } else if (type == "skipped") {
  238. message = "Test '" + name + "' skipped";
  239. ++skipped;
  240. if (!verbose) customMessage = false;
  241. } else if (type == "expected") {
  242. message = "Test '" + name + "' failed as expected";
  243. if (!verbose) customMessage = false;
  244. } else if (type == "error" || type == "fail") {
  245. ++failed;
  246. message = "Test '" + name + "' failed";
  247. } else if (type == "done") {
  248. if (failed) {
  249. type += " fail";
  250. message = failed + " failure" + (failed > 1 ? "s" : "");
  251. } else if (count < totalTests) {
  252. failed = totalTests - count;
  253. type += " fail";
  254. message = failed + " failure" + (failed > 1 ? "s" : "");
  255. } else {
  256. type += " ok";
  257. message = "All passed"
  258. if (skipped) {
  259. message += " (" + skipped + " skipped)";
  260. }
  261. }
  262. done = true
  263. progressTotal.nodeValue = '';
  264. customMessage = true; // Hack to avoid adding to output
  265. }
  266. if (verbose && !customMessage) customMessage = message;
  267. setStatus(message, type);
  268. if (customMessage && customMessage.length > 0) {
  269. addOutput(name, type, customMessage);
  270. }
  271. }
  272. </script>
  273. </article>