Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 # | 4 # |
| 5 | 5 |
| 6 """Runs a Dart unit test in different configurations. | 6 """Runs a Dart unit test in different configurations. |
| 7 | 7 |
| 8 Currently supported architectures include dartium, chromium, ia32, x64, | 8 Currently supported architectures include dartium, chromium, ia32, x64, |
| 9 arm, simarm, and dartc. | 9 arm, simarm, and dartc. |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 <style> | 32 <style> |
| 33 .unittest-table { font-family:monospace; border:1px; } | 33 .unittest-table { font-family:monospace; border:1px; } |
| 34 .unittest-pass { background: #6b3;} | 34 .unittest-pass { background: #6b3;} |
| 35 .unittest-fail { background: #d55;} | 35 .unittest-fail { background: #d55;} |
| 36 .unittest-error { background: #a11;} | 36 .unittest-error { background: #a11;} |
| 37 </style> | 37 </style> |
| 38 </head> | 38 </head> |
| 39 <body> | 39 <body> |
| 40 <h1> Running %(title)s </h1> | 40 <h1> Running %(title)s </h1> |
| 41 <script type="text/javascript" src="%(controller_script)s"></script> | 41 <script type="text/javascript" src="%(controller_script)s"></script> |
| 42 <script type="%(script_type)s" src="%(source_script)s"></script> | 42 <script type="%(script_type)s" src="%(source_script)s"></script> |
|
vsm
2011/10/31 17:48:21
Note, we're changing Dart scripts to execute on DO
floitsch
2011/10/31 18:00:37
But that would mean that the JS script is executed
| |
| 43 <script type="text/javascript"> | 43 <script type="text/javascript"> |
| 44 // If nobody intercepts the error, finish the test. | |
| 45 window.onerror = function() { window.layoutTestController.notifyDone() }; | |
| 46 | |
| 44 // If 'startedDartTest' is not set, that means that the test did not have | 47 // If 'startedDartTest' is not set, that means that the test did not have |
| 45 // a chance to load. This will happen when a load error occurs in the VM. | 48 // a chance to load. This will happen when a load error occurs in the VM. |
| 46 // Give the machine time to start up. | 49 // Give the machine time to start up. |
| 47 setTimeout(function() { | 50 setTimeout(function() { |
| 48 if (window.layoutTestController | 51 // A window.postMessage might have been enqueued after this timeout. |
|
Anton Muhin
2011/10/31 18:19:24
I don't know all the details, but maybe trigger fi
| |
| 49 && !window.layoutTestController.startedDartTest) { | 52 // Just sleep another time to give the browser the time to process the |
| 50 window.layoutTestController.notifyDone(); | 53 // posted message. |
| 51 } | 54 setTimeout(function() { |
| 52 }, 3000); | 55 if (window.layoutTestController |
| 56 && !window.layoutTestController.startedDartTest) { | |
| 57 window.layoutTestController.notifyDone(); | |
| 58 } | |
| 59 }, 0); | |
| 60 }, 0); | |
| 53 </script> | 61 </script> |
| 54 </body> | 62 </body> |
| 55 </html> | 63 </html> |
| 56 """ | 64 """ |
| 57 | 65 |
| 58 DART_TEST_AS_LIBRARY = """ | 66 DART_TEST_AS_LIBRARY = """ |
| 59 #library('test'); | 67 #library('test'); |
| 60 #source('%(test)s'); | 68 #source('%(test)s'); |
| 61 """ | 69 """ |
| 62 | 70 |
| 63 DART_CONTENTS = """ | 71 DART_CONTENTS = """ |
| 64 #library('test'); | 72 #library('test'); |
| 65 | 73 |
| 66 #import('%(dom_library)s'); | 74 #import('%(dom_library)s'); |
| 67 #import('%(test_framework)s'); | 75 #import('%(test_framework)s'); |
| 68 | 76 |
| 69 #import('%(library)s', prefix: "Test"); | 77 #import('%(library)s', prefix: "Test"); |
| 70 | 78 |
| 79 waitForDone() { | |
| 80 window.postMessage('unittest-suite-wait-for-done', '*'); | |
| 81 } | |
| 82 | |
| 71 pass() { | 83 pass() { |
| 72 document.body.innerHTML = 'PASS'; | 84 document.body.innerHTML = 'PASS'; |
| 73 window.postMessage('unittest-suite-done', '*'); | 85 window.postMessage('unittest-suite-done', '*'); |
| 74 } | 86 } |
| 75 | 87 |
| 76 fail(e, trace) { | 88 fail(e, trace) { |
| 77 document.body.innerHTML = 'FAIL: $e, $trace'; | 89 document.body.innerHTML = 'FAIL: $e, $trace'; |
| 78 window.postMessage('unittest-suite-done', '*'); | 90 window.postMessage('unittest-suite-done', '*'); |
| 79 } | 91 } |
| 80 | 92 |
| 81 // All tests are registered as async tests on the UnitTestSuite. | |
| 82 // If the test uses the [:TestRunner:] we will a callback to wait for the | |
| 83 // done callback. | |
| 84 // Otherwise we will call [:testSuite.done():] immediately after the test | |
| 85 // finished. | |
| 86 main() { | 93 main() { |
| 87 bool needsToWait = false; | 94 bool needsToWait = false; |
| 88 bool mainIsFinished = false; | 95 bool mainIsFinished = false; |
| 89 TestRunner.waitForDoneCallback = () { needsToWait = true; }; | 96 TestRunner.waitForDoneCallback = () { needsToWait = true; }; |
| 90 TestRunner.doneCallback = () { | 97 TestRunner.doneCallback = () { |
| 91 if (mainIsFinished) { | 98 if (mainIsFinished) { |
| 92 pass(); | 99 pass(); |
| 93 } else { | 100 } else { |
| 94 needsToWait = false; | 101 needsToWait = false; |
| 95 } | 102 } |
| 96 }; | 103 }; |
| 97 try { | 104 try { |
| 98 Test.main(); | 105 Test.main(); |
| 99 if (!needsToWait) pass(); | 106 if (needsToWait) { |
| 107 waitForDone(); | |
| 108 } else { | |
| 109 pass(); | |
| 110 } | |
| 100 mainIsFinished = true; | 111 mainIsFinished = true; |
| 101 } catch(var e, var trace) { | 112 } catch(var e, var trace) { |
| 102 fail(e, trace); | 113 fail(e, trace); |
| 103 } | 114 } |
| 104 } | 115 } |
| 105 """ | 116 """ |
| 106 | 117 |
| 107 | 118 |
| 108 # Patterns for matching test options in .dart files. | 119 # Patterns for matching test options in .dart files. |
| 109 DART_OPTIONS_PATTERN = re.compile(r'// DartOptions=(.*)') | 120 DART_OPTIONS_PATTERN = re.compile(r'// DartOptions=(.*)') |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 return ChromiumArchitecture(root_path, arch, mode, test) | 507 return ChromiumArchitecture(root_path, arch, mode, test) |
| 497 | 508 |
| 498 elif arch == 'dartium': | 509 elif arch == 'dartium': |
| 499 return DartiumArchitecture(root_path, arch, mode, test) | 510 return DartiumArchitecture(root_path, arch, mode, test) |
| 500 | 511 |
| 501 elif arch in ['ia32', 'x64', 'simarm', 'arm']: | 512 elif arch in ['ia32', 'x64', 'simarm', 'arm']: |
| 502 return RuntimeArchitecture(root_path, arch, mode, test) | 513 return RuntimeArchitecture(root_path, arch, mode, test) |
| 503 | 514 |
| 504 elif arch == 'dartc': | 515 elif arch == 'dartc': |
| 505 return DartcArchitecture(root_path, arch, mode, test) | 516 return DartcArchitecture(root_path, arch, mode, test) |
| OLD | NEW |