flakiness_dashboard_unittests.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. // Copyright (C) 2011 Google Inc. All rights reserved.
  2. //
  3. // Redistribution and use in source and binary forms, with or without
  4. // modification, are permitted provided that the following conditions are
  5. // met:
  6. //
  7. // * Redistributions of source code must retain the above copyright
  8. // notice, this list of conditions and the following disclaimer.
  9. // * Redistributions in binary form must reproduce the above
  10. // copyright notice, this list of conditions and the following disclaimer
  11. // in the documentation and/or other materials provided with the
  12. // distribution.
  13. // * Neither the name of Google Inc. nor the names of its
  14. // contributors may be used to endorse or promote products derived from
  15. // this software without specific prior written permission.
  16. //
  17. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. // FIXME(jparent): Rename this once it isn't globals.
  29. function resetGlobals()
  30. {
  31. allExpectations = null;
  32. allTests = null;
  33. g_expectationsByPlatform = {};
  34. g_resultsByBuilder = {};
  35. g_allExpectations = null;
  36. g_allTestsTrie = null;
  37. var historyInstance = new history.History(flakinessConfig);
  38. // FIXME(jparent): Remove this once global isn't used.
  39. g_history = historyInstance;
  40. g_testToResultsMap = {};
  41. for (var key in history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES)
  42. historyInstance.crossDashboardState[key] = history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES[key];
  43. LOAD_BUILDBOT_DATA([{
  44. name: 'webkit.org',
  45. url: 'dummyurl',
  46. tests: {'layout-tests': {'builders': ['Apple Lion Release WK2 (Tests)', 'Apple Lion Debug WK2 (Tests)', 'GTK Linux 64-bit Release', 'Qt Linux Tests']}}
  47. }]);
  48. for (var group in LAYOUT_TESTS_BUILDER_GROUPS)
  49. LAYOUT_TESTS_BUILDER_GROUPS[group] = null;
  50. return historyInstance;
  51. }
  52. function stubResultsByBuilder(data)
  53. {
  54. for (var builder in currentBuilders())
  55. {
  56. g_resultsByBuilder[builder] = data[builder] || {'tests': []};
  57. };
  58. }
  59. function runExpectationsTest(builder, test, expectations, modifiers)
  60. {
  61. // Put in some dummy results. processExpectations expects the test to be
  62. // there.
  63. var tests = {};
  64. tests[test] = {'results': [[100, 'F']], 'times': [[100, 0]]};
  65. var results = {};
  66. results[builder] = {'tests': tests};
  67. stubResultsByBuilder(results);
  68. processExpectations();
  69. var resultsForTest = createResultsObjectForTest(test, builder);
  70. populateExpectationsData(resultsForTest);
  71. var message = 'Builder: ' + resultsForTest.builder + ' test: ' + resultsForTest.test;
  72. equal(resultsForTest.expectations, expectations, message);
  73. equal(resultsForTest.modifiers, modifiers, message);
  74. }
  75. test('releaseFail', 2, function() {
  76. resetGlobals();
  77. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  78. var builder = 'Apple Lion Release WK2 (Tests)';
  79. var test = 'foo/1.html';
  80. var expectationsArray = [
  81. {'modifiers': 'RELEASE', 'expectations': 'FAIL'}
  82. ];
  83. g_expectationsByPlatform['APPLE_MAC_LION_WK2'] = getParsedExpectations('[ Release ] ' + test + ' [ Failure ]');
  84. runExpectationsTest(builder, test, 'FAIL', 'RELEASE');
  85. });
  86. test('releaseFailDebugCrashReleaseBuilder', 2, function() {
  87. resetGlobals();
  88. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  89. var builder = 'Apple Lion Release WK2 (Tests)';
  90. var test = 'foo/1.html';
  91. var expectationsArray = [
  92. {'modifiers': 'RELEASE', 'expectations': 'FAIL'},
  93. {'modifiers': 'DEBUG', 'expectations': 'CRASH'}
  94. ];
  95. g_expectationsByPlatform['APPLE_MAC_LION_WK2'] = getParsedExpectations('[ Release ] ' + test + ' [ Failure ]\n' +
  96. '[ Debug ] ' + test + ' [ Crash ]');
  97. runExpectationsTest(builder, test, 'FAIL', 'RELEASE');
  98. });
  99. test('releaseFailDebugCrashDebugBuilder', 2, function() {
  100. resetGlobals();
  101. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  102. var builder = 'Apple Lion Debug WK2 (Tests)';
  103. var test = 'foo/1.html';
  104. var expectationsArray = [
  105. {'modifiers': 'RELEASE', 'expectations': 'FAIL'},
  106. {'modifiers': 'DEBUG', 'expectations': 'CRASH'}
  107. ];
  108. g_expectationsByPlatform['APPLE_MAC_LION_WK2'] = getParsedExpectations('[ Release ] ' + test + ' [ Failure ]\n' +
  109. '[ Debug ] ' + test + ' [ Crash ]');
  110. runExpectationsTest(builder, test, 'CRASH', 'DEBUG');
  111. });
  112. test('overrideJustBuildType', 4, function() {
  113. resetGlobals();
  114. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  115. var test = 'bar/1.html';
  116. g_expectationsByPlatform['APPLE_MAC_LION_WK2'] = getParsedExpectations('bar [ WontFix Failure Pass Timeout ]\n' +
  117. '[ Release ] ' + test + ' [ WontFix Failure ]\n' +
  118. '[ Debug ] ' + test + ' [ Crash ]');
  119. runExpectationsTest('Apple Lion Release WK2 (Tests)', test, 'FAIL', 'RELEASE WONTFIX');
  120. runExpectationsTest('Apple Lion Debug WK2 (Tests)', test, 'CRASH', 'DEBUG');
  121. });
  122. test('platformAndBuildType', 30, function() {
  123. var historyInstance = new history.History(flakinessConfig);
  124. // FIXME(jparent): Change to use the flakiness_db's history object
  125. // once it exists, rather than tracking global.
  126. g_history = historyInstance;
  127. var runPlatformAndBuildTypeTest = function(builder, expectedPlatform, expectedBuildType) {
  128. g_perBuilderPlatformAndBuildType = {};
  129. buildInfo = platformAndBuildType(builder);
  130. var message = 'Builder: ' + builder;
  131. equal(buildInfo.platform, expectedPlatform, message);
  132. equal(buildInfo.buildType, expectedBuildType, message);
  133. }
  134. // FIXME: These platforms should match whatever we use in the TestExpectations format.
  135. runPlatformAndBuildTypeTest('Lion Release (Tests)', 'APPLE_MAC_LION_WK1', 'RELEASE');
  136. runPlatformAndBuildTypeTest('Lion Debug (Tests)', 'APPLE_MAC_LION_WK1', 'DEBUG');
  137. runPlatformAndBuildTypeTest('MountainLion Release (Tests)', 'APPLE_MAC_MOUNTAINLION_WK1', 'RELEASE');
  138. runPlatformAndBuildTypeTest('MountainLion Leaks', 'APPLE_MAC_MOUNTAINLION_WK1', 'RELEASE');
  139. runPlatformAndBuildTypeTest('MountainLion Debug (Tests)', 'APPLE_MAC_MOUNTAINLION_WK1', 'DEBUG');
  140. runPlatformAndBuildTypeTest('GTK Linux 32-bit Release', 'GTK_LINUX_WK1', 'RELEASE');
  141. runPlatformAndBuildTypeTest('GTK Linux 32-bit Debug', 'GTK_LINUX_WK1', 'DEBUG');
  142. runPlatformAndBuildTypeTest('GTK Linux 64-bit Debug', 'GTK_LINUX_WK1', 'DEBUG');
  143. runPlatformAndBuildTypeTest('GTK Linux 64-bit Debug WK2', 'GTK_LINUX_WK2', 'DEBUG');
  144. runPlatformAndBuildTypeTest('Qt Linux Release', 'QT_LINUX', 'RELEASE');
  145. runPlatformAndBuildTypeTest('Windows 7 Release (Tests)', 'APPLE_WIN_WIN7', 'RELEASE');
  146. runPlatformAndBuildTypeTest('Windows XP Debug (Tests)', 'APPLE_WIN_XP', 'DEBUG');
  147. // FIXME: Should WebKit2 be it's own platform?
  148. runPlatformAndBuildTypeTest('MountainLion Release (WebKit2 Tests)', 'APPLE_MAC_MOUNTAINLION_WK2', 'RELEASE');
  149. runPlatformAndBuildTypeTest('MountainLion Debug (WebKit2 Tests)', 'APPLE_MAC_MOUNTAINLION_WK2', 'DEBUG');
  150. runPlatformAndBuildTypeTest('Windows 7 Release (WebKit2 Tests)', 'APPLE_WIN_WIN7', 'RELEASE');
  151. });
  152. test('realModifiers', 3, function() {
  153. equal(realModifiers('BUG(Foo) DEBUG SLOW'), 'SLOW');
  154. equal(realModifiers('BUG(Foo) RELEASE'), '');
  155. equal(realModifiers('BUG(Foo)'), '');
  156. });
  157. test('allTestsWithSamePlatformAndBuildType', 1, function() {
  158. // FIXME: test that allTestsWithSamePlatformAndBuildType actually returns the right set of tests.
  159. var expectedPlatformsList = ['APPLE_MAC_LION_WK1', 'APPLE_MAC_LION_WK2', 'APPLE_MAC_MOUNTAINLION_WK1', 'APPLE_MAC_MOUNTAINLION_WK2',
  160. 'APPLE_WIN_XP', 'APPLE_WIN_WIN7', 'GTK_LINUX_WK1', 'GTK_LINUX_WK2', 'QT_LINUX', 'EFL_LINUX_WK1', 'EFL_LINUX_WK2'];
  161. var actualPlatformsList = Object.keys(g_allTestsByPlatformAndBuildType);
  162. deepEqual(expectedPlatformsList, actualPlatformsList);
  163. });
  164. test('filterBugs',4, function() {
  165. var filtered = filterBugs('Skip crbug.com/123 webkit.org/b/123 Slow Bug(Tony) Debug')
  166. equal(filtered.modifiers, 'Skip Slow Debug');
  167. equal(filtered.bugs, 'crbug.com/123 webkit.org/b/123 Bug(Tony)');
  168. filtered = filterBugs('Skip Slow Debug')
  169. equal(filtered.modifiers, 'Skip Slow Debug');
  170. equal(filtered.bugs, '');
  171. });
  172. test('getExpectations', 14, function() {
  173. resetGlobals();
  174. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  175. stubResultsByBuilder({
  176. 'Apple Lion Release WK2 (Tests)' : {
  177. 'tests': {
  178. 'foo/test1.html': {'results': [[100, 'F']], 'times': [[100, 0]]},
  179. 'foo/test2.html': {'results': [[100, 'F']], 'times': [[100, 0]]},
  180. 'foo/test3.html': {'results': [[100, 'F']], 'times': [[100, 0]]},
  181. 'test1.html': {'results': [[100, 'F']], 'times': [[100, 0]]}
  182. }
  183. }
  184. });
  185. g_expectationsByPlatform['APPLE_MAC_LION_WK2'] = getParsedExpectations('Bug(123) foo [ Failure Pass Crash ]\n' +
  186. 'Bug(Foo) [ Release ] foo/test1.html [ Failure ]\n' +
  187. '[ Debug ] foo/test1.html [ Crash ]\n' +
  188. 'Bug(456) foo/test2.html [ Failure ]\n' +
  189. '[ Debug ] foo/test2.html [ Crash ]\n' +
  190. '[ Release ] test1.html [ Failure ]\n' +
  191. '[ Debug ] test1.html [ Crash ]\n');
  192. g_expectationsByPlatform['GTK'] = getParsedExpectations('Bug(42) foo/test2.html [ ImageOnlyFailure ]\n' +
  193. '[ Debug ] test1.html [ Crash ]\n');
  194. g_expectationsByPlatform['GTK_LINUX_WK1'] = getParsedExpectations('[ Release ] foo/test1.html [ ImageOnlyFailure ]\n' +
  195. 'Bug(789) foo/test2.html [ Crash ]\n');
  196. g_expectationsByPlatform['GTK_LINUX_WK2'] = getParsedExpectations('Bug(987) foo/test2.html [ Failure ]\n');
  197. processExpectations();
  198. var expectations = getExpectations('foo/test1.html', 'APPLE_MAC_LION_WK2', 'DEBUG');
  199. equal(JSON.stringify(expectations), '{"modifiers":"DEBUG","expectations":"CRASH"}');
  200. var expectations = getExpectations('foo/test1.html', 'APPLE_MAC_LION_WK2', 'RELEASE');
  201. equal(JSON.stringify(expectations), '{"modifiers":"Bug(Foo) RELEASE","expectations":"FAIL"}');
  202. var expectations = getExpectations('foo/test2.html', 'APPLE_MAC_LION_WK2', 'RELEASE');
  203. equal(JSON.stringify(expectations), '{"modifiers":"Bug(456)","expectations":"FAIL"}');
  204. var expectations = getExpectations('foo/test2.html', 'APPLE_MAC_LION_WK2', 'DEBUG');
  205. equal(JSON.stringify(expectations), '{"modifiers":"DEBUG","expectations":"CRASH"}');
  206. var expectations = getExpectations('test1.html', 'APPLE_MAC_LION_WK2', 'RELEASE');
  207. equal(JSON.stringify(expectations), '{"modifiers":"RELEASE","expectations":"FAIL"}');
  208. var expectations = getExpectations('foo/test3.html', 'APPLE_MAC_LION_WK2', 'DEBUG');
  209. equal(JSON.stringify(expectations), '{"modifiers":"Bug(123)","expectations":"FAIL PASS CRASH"}');
  210. var expectations = getExpectations('test1.html', 'APPLE_MAC_LION_WK2', 'DEBUG');
  211. equal(JSON.stringify(expectations), '{"modifiers":"DEBUG","expectations":"CRASH"}');
  212. var expectations = getExpectations('test1.html', 'APPLE_MAC_LION_WK2', 'RELEASE');
  213. equal(JSON.stringify(expectations), '{"modifiers":"RELEASE","expectations":"FAIL"}');
  214. var expectations = getExpectations('foo/test1.html', 'GTK_LINUX_WK1', 'RELEASE');
  215. equal(JSON.stringify(expectations), '{"modifiers":"RELEASE","expectations":"IMAGE"}');
  216. var expectations = getExpectations('foo/test2.html', 'GTK_LINUX_WK1', 'DEBUG');
  217. equal(JSON.stringify(expectations), '{"modifiers":"Bug(789)","expectations":"CRASH"}');
  218. var expectations = getExpectations('test1.html', 'GTK_LINUX_WK1', 'DEBUG');
  219. equal(JSON.stringify(expectations), '{"modifiers":"DEBUG","expectations":"CRASH"}');
  220. var expectations = getExpectations('foo/test2.html', 'GTK_LINUX_WK2', 'DEBUG');
  221. equal(JSON.stringify(expectations), '{"modifiers":"Bug(987)","expectations":"FAIL"}');
  222. var expectations = getExpectations('foo/test2.html', 'GTK_LINUX_WK2', 'RELEASE');
  223. equal(JSON.stringify(expectations), '{"modifiers":"Bug(987)","expectations":"FAIL"}');
  224. var expectations = getExpectations('test1.html', 'GTK_LINUX_WK2', 'DEBUG');
  225. equal(JSON.stringify(expectations), '{"modifiers":"DEBUG","expectations":"CRASH"}');
  226. });
  227. test('substringList', 2, function() {
  228. var historyInstance = new history.History(flakinessConfig);
  229. // FIXME(jparent): Remove this once global isn't used.
  230. g_history = historyInstance;
  231. historyInstance.crossDashboardState.testType = 'gtest';
  232. historyInstance.dashboardSpecificState.tests = 'test.FLAKY_foo test.FAILS_foo1 test.DISABLED_foo2 test.MAYBE_foo3 test.foo4';
  233. equal(substringList().toString(), 'test.foo,test.foo1,test.foo2,test.foo3,test.foo4');
  234. historyInstance.crossDashboardState.testType = 'layout-tests';
  235. historyInstance.dashboardSpecificState.tests = 'foo/bar.FLAKY_foo.html';
  236. equal(substringList().toString(), 'foo/bar.FLAKY_foo.html');
  237. });
  238. test('htmlForTestsWithExpectationsButNoFailures', 4, function() {
  239. var historyInstance = new history.History(defaultDashboardSpecificStateValues, generatePage, handleValidHashParameter);
  240. // FIXME(jparent): Remove this once global isn't used.
  241. g_history = historyInstance;
  242. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  243. var builder = 'Apple Lion Release WK2 (Tests)';
  244. g_perBuilderWithExpectationsButNoFailures[builder] = ['passing-test1.html', 'passing-test2.html'];
  245. g_perBuilderSkippedPaths[builder] = ['skipped-test1.html'];
  246. g_resultsByBuilder[builder] = { buildNumbers: [5, 4, 3, 1] };
  247. historyInstance.dashboardSpecificState.showUnexpectedPasses = true;
  248. historyInstance.dashboardSpecificState.showSkipped = true;
  249. historyInstance.crossDashboardState.group = '@ToT - webkit.org';
  250. historyInstance.crossDashboardState.testType = 'layout-tests';
  251. var container = document.createElement('div');
  252. container.innerHTML = htmlForTestsWithExpectationsButNoFailures(builder);
  253. equal(container.querySelectorAll('#passing-tests > div').length, 2);
  254. equal(container.querySelectorAll('#skipped-tests > div').length, 1);
  255. historyInstance.dashboardSpecificState.showUnexpectedPasses = false;
  256. historyInstance.dashboardSpecificState.showSkipped = false;
  257. var container = document.createElement('div');
  258. container.innerHTML = htmlForTestsWithExpectationsButNoFailures(builder);
  259. equal(container.querySelectorAll('#passing-tests > div').length, 0);
  260. equal(container.querySelectorAll('#skipped-tests > div').length, 0);
  261. });
  262. test('headerForTestTableHtml', 1, function() {
  263. var container = document.createElement('div');
  264. container.innerHTML = headerForTestTableHtml();
  265. equal(container.querySelectorAll('input').length, 5);
  266. });
  267. test('htmlForTestTypeSwitcherGroup', 6, function() {
  268. var historyInstance = new history.History(flakinessConfig);
  269. // FIXME(jparent): Remove this once global isn't used.
  270. g_history = historyInstance;
  271. var container = document.createElement('div');
  272. historyInstance.crossDashboardState.testType = 'ui_tests';
  273. container.innerHTML = ui.html.testTypeSwitcher(true);
  274. var selects = container.querySelectorAll('select');
  275. equal(selects.length, 2);
  276. var group = selects[1];
  277. equal(group.parentNode.textContent.indexOf('Group:'), 0);
  278. equal(group.children.length, 1);
  279. historyInstance.crossDashboardState.testType = 'layout-tests';
  280. container.innerHTML = ui.html.testTypeSwitcher(true);
  281. var selects = container.querySelectorAll('select');
  282. equal(selects.length, 2);
  283. var group = selects[1];
  284. equal(group.parentNode.textContent.indexOf('Group:'), 0);
  285. equal(group.children.length, 1);
  286. });
  287. test('htmlForIndividualTestOnAllBuilders', 1, function() {
  288. resetGlobals();
  289. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  290. equal(htmlForIndividualTestOnAllBuilders('foo/nonexistant.html'), '<div class="not-found">Test not found. Either it does not exist, is skipped or passes on all platforms.</div>');
  291. });
  292. test('htmlForIndividualTestOnAllBuildersWithResultsLinksNonexistant', 1, function() {
  293. resetGlobals();
  294. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  295. equal(htmlForIndividualTestOnAllBuildersWithResultsLinks('foo/nonexistant.html'),
  296. '<div class="not-found">Test not found. Either it does not exist, is skipped or passes on all platforms.</div>' +
  297. '<div class=expectations test=foo/nonexistant.html>' +
  298. '<div>' +
  299. '<span class=link onclick="g_history.setQueryParameter(\'showExpectations\', true)">Show results</span> | ' +
  300. '<span class=link onclick="g_history.setQueryParameter(\'showLargeExpectations\', true)">Show large thumbnails</span> | ' +
  301. '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b>' +
  302. '</div>' +
  303. '</div>');
  304. });
  305. test('htmlForIndividualTestOnAllBuildersWithResultsLinks', 1, function() {
  306. var historyInstance = resetGlobals();
  307. historyInstance.crossDashboardState.group = '@ToT - webkit.org';
  308. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  309. var builderName = 'Apple Lion Release WK2 (Tests)';
  310. var test = 'dummytest.html';
  311. g_testToResultsMap[test] = [createResultsObjectForTest(test, builderName)];
  312. equal(htmlForIndividualTestOnAllBuildersWithResultsLinks(test),
  313. '<table class=test-table><thead><tr>' +
  314. '<th sortValue=test><div class=table-header-content><span></span><span class=header-text>test</span></div></th>' +
  315. '<th sortValue=bugs><div class=table-header-content><span></span><span class=header-text>bugs</span></div></th>' +
  316. '<th sortValue=modifiers><div class=table-header-content><span></span><span class=header-text>modifiers</span></div></th>' +
  317. '<th sortValue=expectations><div class=table-header-content><span></span><span class=header-text>expectations</span></div></th>' +
  318. '<th sortValue=slowest><div class=table-header-content><span></span><span class=header-text>slowest run</span></div></th>' +
  319. '<th sortValue=flakiness colspan=10000><div class=table-header-content><span></span><span class=header-text>flakiness (numbers are runtimes in seconds)</span></div></th>' +
  320. '</tr></thead>' +
  321. '<tbody></tbody>' +
  322. '</table>' +
  323. '<div>The following builders either don\'t run this test (e.g. it\'s skipped) or all runs passed:</div>' +
  324. '<div class=skipped-builder-list>' +
  325. '<div class=skipped-builder>Apple Lion Debug WK2 (Tests)</div><div class=skipped-builder>GTK Linux 64-bit Release</div><div class=skipped-builder>Qt Linux Tests</div>' +
  326. '</div>' +
  327. '<div class=expectations test=dummytest.html>' +
  328. '<div><span class=link onclick="g_history.setQueryParameter(\'showExpectations\', true)">Show results</span> | ' +
  329. '<span class=link onclick="g_history.setQueryParameter(\'showLargeExpectations\', true)">Show large thumbnails</span>' +
  330. '<form onsubmit="g_history.setQueryParameter(\'revision\', revision.value);return false;">' +
  331. 'Show results for WebKit revision: <input name=revision placeholder="e.g. 65540" value="" id=revision-input>' +
  332. '</form></div>' +
  333. '</div>');
  334. });
  335. test('htmlForIndividualTests', 4, function() {
  336. var historyInstance = resetGlobals();
  337. loadBuildersList('@ToT - webkit.org', 'layout-tests');
  338. var test1 = 'foo/nonexistant.html';
  339. var test2 = 'bar/nonexistant.html';
  340. historyInstance.dashboardSpecificState.showChrome = false;
  341. var tests = [test1, test2];
  342. equal(htmlForIndividualTests(tests),
  343. '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/foo/nonexistant.html" target="_blank">foo/nonexistant.html</a></h2>' +
  344. htmlForIndividualTestOnAllBuilders(test1) +
  345. '<div class=expectations test=foo/nonexistant.html>' +
  346. '<div><span class=link onclick=\"g_history.setQueryParameter(\'showExpectations\', true)\">Show results</span> | ' +
  347. '<span class=link onclick=\"g_history.setQueryParameter(\'showLargeExpectations\', true)\">Show large thumbnails</span> | ' +
  348. '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b></div>' +
  349. '</div>' +
  350. '<hr>' +
  351. '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/bar/nonexistant.html" target="_blank">bar/nonexistant.html</a></h2>' +
  352. htmlForIndividualTestOnAllBuilders(test2) +
  353. '<div class=expectations test=bar/nonexistant.html>' +
  354. '<div><span class=link onclick=\"g_history.setQueryParameter(\'showExpectations\', true)\">Show results</span> | ' +
  355. '<span class=link onclick=\"g_history.setQueryParameter(\'showLargeExpectations\', true)\">Show large thumbnails</span> | ' +
  356. '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b></div>' +
  357. '</div>');
  358. tests = [test1];
  359. equal(htmlForIndividualTests(tests), htmlForIndividualTestOnAllBuilders(test1) +
  360. '<div class=expectations test=foo/nonexistant.html>' +
  361. '<div><span class=link onclick=\"g_history.setQueryParameter(\'showExpectations\', true)\">Show results</span> | ' +
  362. '<span class=link onclick=\"g_history.setQueryParameter(\'showLargeExpectations\', true)\">Show large thumbnails</span> | ' +
  363. '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b></div>' +
  364. '</div>');
  365. historyInstance.dashboardSpecificState.showChrome = true;
  366. equal(htmlForIndividualTests(tests),
  367. '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/foo/nonexistant.html" target="_blank">foo/nonexistant.html</a></h2>' +
  368. htmlForIndividualTestOnAllBuildersWithResultsLinks(test1));
  369. tests = [test1, test2];
  370. equal(htmlForIndividualTests(tests),
  371. '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/foo/nonexistant.html" target="_blank">foo/nonexistant.html</a></h2>' +
  372. htmlForIndividualTestOnAllBuildersWithResultsLinks(test1) + '<hr>' +
  373. '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/bar/nonexistant.html" target="_blank">bar/nonexistant.html</a></h2>' +
  374. htmlForIndividualTestOnAllBuildersWithResultsLinks(test2));
  375. });
  376. test('htmlForSingleTestRow', 1, function() {
  377. var historyInstance = resetGlobals();
  378. var builder = 'dummyBuilder';
  379. BUILDER_TO_MASTER[builder] = WEBKIT_BUILDER_MASTER;
  380. var test = createResultsObjectForTest('foo/exists.html', builder);
  381. historyInstance.dashboardSpecificState.showCorrectExpectations = true;
  382. g_resultsByBuilder[builder] = {buildNumbers: [2, 1], webkitRevision: [1234, 1233]};
  383. test.rawResults = [[1, 'F'], [2, 'I']];
  384. test.rawTimes = [[1, 0], [2, 5]];
  385. var expected = '<tr>' +
  386. '<td class="test-link"><span class="link" onclick="g_history.setQueryParameter(\'tests\',\'foo/exists.html\');">foo/exists.html</span>' +
  387. '<td class=options-container><a href="https://bugs.webkit.org/enter_bug.cgi?assigned_to=webkit-unassigned%40lists.webkit.org&product=WebKit&form_name=enter_bug&component=Tools%20%2F%20Tests&short_desc=Layout%20Test%20foo%2Fexists.html%20is%20failing&comment=The%20following%20layout%20test%20is%20failing%20on%20%5Binsert%20platform%5D%0A%0Afoo%2Fexists.html%0A%0AProbable%20cause%3A%0A%0A%5Binsert%20probable%20cause%5D" class="file-bug">FILE BUG</a>' +
  388. '<td class=options-container>' +
  389. '<td class=options-container>' +
  390. '<td><td title="TEXT. Click for more info." class="results F merge" onclick=\'showPopupForBuild(event, "dummyBuilder",0,"foo/exists.html")\'>&nbsp;' +
  391. '<td title="IMAGE. Click for more info." class="results I" onclick=\'showPopupForBuild(event, "dummyBuilder",1,"foo/exists.html")\'>5';
  392. equal(htmlForSingleTestRow(test), expected);
  393. });
  394. test('lookupVirtualTestSuite', 2, function() {
  395. equal(lookupVirtualTestSuite('fast/canvas/foo.html'), '');
  396. equal(lookupVirtualTestSuite('platform/chromium/virtual/gpu/fast/canvas/foo.html'), 'platform/chromium/virtual/gpu/fast/canvas');
  397. });
  398. test('baseTest', 2, function() {
  399. equal(baseTest('fast/canvas/foo.html', ''), 'fast/canvas/foo.html');
  400. equal(baseTest('platform/chromium/virtual/gpu/fast/canvas/foo.html', 'platform/chromium/virtual/gpu/fast/canvas'), 'fast/canvas/foo.html');
  401. });
  402. // FIXME: Create builders_tests.js and move this there.
  403. test('requestBuilderListAddsBuilderGroupEntry', 1, function() {
  404. var testBuilderGroups = { '@ToT - dummy.org': null };
  405. var builderGroup = new BuilderGroup();
  406. var groupName = '@ToT - dummy.org';
  407. requestBuilderList(testBuilderGroups, 'webkit.org', groupName, builderGroup, 'layout-tests');
  408. equal(testBuilderGroups['@ToT - dummy.org'], builderGroup);
  409. })
  410. test('sortTests', 4, function() {
  411. var test1 = createResultsObjectForTest('foo/test1.html', 'dummyBuilder');
  412. var test2 = createResultsObjectForTest('foo/test2.html', 'dummyBuilder');
  413. var test3 = createResultsObjectForTest('foo/test3.html', 'dummyBuilder');
  414. test1.modifiers = 'b';
  415. test2.modifiers = 'a';
  416. test3.modifiers = '';
  417. var tests = [test1, test2, test3];
  418. sortTests(tests, 'modifiers', FORWARD);
  419. deepEqual(tests, [test2, test1, test3]);
  420. sortTests(tests, 'modifiers', BACKWARD);
  421. deepEqual(tests, [test3, test1, test2]);
  422. test1.bugs = 'b';
  423. test2.bugs = 'a';
  424. test3.bugs = '';
  425. var tests = [test1, test2, test3];
  426. sortTests(tests, 'bugs', FORWARD);
  427. deepEqual(tests, [test2, test1, test3]);
  428. sortTests(tests, 'bugs', BACKWARD);
  429. deepEqual(tests, [test3, test1, test2]);
  430. });
  431. test('popup', 2, function() {
  432. ui.popup.show(document.body, 'dummy content');
  433. ok(document.querySelector('#popup'));
  434. ui.popup.hide();
  435. ok(!document.querySelector('#popup'));
  436. });
  437. test('gpuResultsPath', 3, function() {
  438. equal(gpuResultsPath('777777', 'Win7 Release (ATI)'), '777777_Win7_Release_ATI_');
  439. equal(gpuResultsPath('123', 'GPU Linux (dbg)(NVIDIA)'), '123_GPU_Linux_dbg_NVIDIA_');
  440. equal(gpuResultsPath('12345', 'GPU Mac'), '12345_GPU_Mac');
  441. });
  442. test('TestTrie', 3, function() {
  443. var builders = {
  444. "Dummy Chromium Windows Builder": true,
  445. "Dummy GTK Linux Builder": true,
  446. "Dummy Apple Mac Lion Builder": true
  447. };
  448. var resultsByBuilder = {
  449. "Dummy Chromium Windows Builder": {
  450. tests: {
  451. "foo": true,
  452. "foo/bar/1.html": true,
  453. "foo/bar/baz": true
  454. }
  455. },
  456. "Dummy GTK Linux Builder": {
  457. tests: {
  458. "bar": true,
  459. "foo/1.html": true,
  460. "foo/bar/2.html": true,
  461. "foo/bar/baz/1.html": true,
  462. }
  463. },
  464. "Dummy Apple Mac Lion Builder": {
  465. tests: {
  466. "foo/bar/3.html": true,
  467. "foo/bar/baz/foo": true,
  468. }
  469. }
  470. };
  471. var expectedTrie = {
  472. "foo": {
  473. "bar": {
  474. "1.html": true,
  475. "2.html": true,
  476. "3.html": true,
  477. "baz": {
  478. "1.html": true,
  479. "foo": true
  480. }
  481. },
  482. "1.html": true
  483. },
  484. "bar": true
  485. }
  486. var trie = new TestTrie(builders, resultsByBuilder);
  487. deepEqual(trie._trie, expectedTrie);
  488. var leafsOfCompleteTrieTraversal = [];
  489. var expectedLeafs = ["foo/bar/1.html", "foo/bar/baz/1.html", "foo/bar/baz/foo", "foo/bar/2.html", "foo/bar/3.html", "foo/1.html", "bar"];
  490. trie.forEach(function(triePath) {
  491. leafsOfCompleteTrieTraversal.push(triePath);
  492. });
  493. deepEqual(leafsOfCompleteTrieTraversal, expectedLeafs);
  494. var leafsOfPartialTrieTraversal = [];
  495. expectedLeafs = ["foo/bar/1.html", "foo/bar/baz/1.html", "foo/bar/baz/foo", "foo/bar/2.html", "foo/bar/3.html"];
  496. trie.forEach(function(triePath) {
  497. leafsOfPartialTrieTraversal.push(triePath);
  498. }, "foo/bar");
  499. deepEqual(leafsOfPartialTrieTraversal, expectedLeafs);
  500. });
  501. test('changeTestTypeInvalidatesGroup', 1, function() {
  502. var historyInstance = resetGlobals();
  503. var originalGroup = '@ToT - webkit.org';
  504. var originalTestType = 'layout-tests';
  505. loadBuildersList(originalGroup, originalTestType);
  506. historyInstance.crossDashboardState.group = originalGroup;
  507. historyInstance.crossDashboardState.testType = originalTestType;
  508. historyInstance.invalidateQueryParameters({'testType': 'ui_tests'});
  509. notEqual(historyInstance.crossDashboardState.group, originalGroup, "group should have been invalidated");
  510. });
  511. test('shouldHideTest', 10, function() {
  512. var historyInstance = new history.History(flakinessConfig);
  513. historyInstance.parseParameters();
  514. // FIXME(jparent): Change to use the flakiness_dashboard's history object
  515. // once it exists, rather than tracking global.
  516. g_history = historyInstance;
  517. var test = createResultsObjectForTest('foo/test.html', 'dummyBuilder');
  518. equal(shouldHideTest(test), true, 'default layout test, hide it.');
  519. historyInstance.dashboardSpecificState.showCorrectExpectations = true;
  520. equal(shouldHideTest(test), false, 'show correct expectations.');
  521. historyInstance.dashboardSpecificState.showCorrectExpectations = false;
  522. test = createResultsObjectForTest('foo/test.html', 'dummyBuilder');
  523. test.isWontFixSkip = true;
  524. equal(shouldHideTest(test), true, 'by default hide these too');
  525. historyInstance.dashboardSpecificState.showWontFixSkip = true;
  526. equal(shouldHideTest(test), false, 'now we should show it');
  527. historyInstance.dashboardSpecificState.showWontFixSkip = false;
  528. test = createResultsObjectForTest('foo/test.html', 'dummyBuilder');
  529. test.isFlaky = true;
  530. equal(shouldHideTest(test), false, 'we show flaky tests by default');
  531. historyInstance.dashboardSpecificState.showFlaky = false;
  532. equal(shouldHideTest(test), true, 'do not show flaky test');
  533. historyInstance.dashboardSpecificState.showFlaky = true;
  534. test = createResultsObjectForTest('foo/test.html', 'dummyBuilder');
  535. test.slowestNonTimeoutCrashTime = MIN_SECONDS_FOR_SLOW_TEST + 1;
  536. equal(shouldHideTest(test), true, 'we hide slow tests by default');
  537. historyInstance.dashboardSpecificState.showSlow = true;
  538. equal(shouldHideTest(test), false, 'now show slow test');
  539. historyInstance.dashboardSpecificState.showSlow = false;
  540. test = createResultsObjectForTest('foo/test.html', 'dummyBuilder');
  541. historyInstance.crossDashboardState.testType = 'not layout tests';
  542. equal(shouldHideTest(test), false, 'show all non layout tests');
  543. test.isWontFixSkip = true;
  544. equal(shouldHideTest(test), false, 'show all non layout tests, even if wont fix');
  545. });