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 23 matching lines...) Expand all Loading... | |
| 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> |
| 43 <script type="text/javascript"> | 43 <script type="text/javascript"> |
| 44 window.onerror = function() { window.layoutTestController.notifyDone() }; | |
| 45 | |
| 44 // If 'startedDartTest' is not set, that means that the test did not have | 46 // 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. | 47 // a chance to load. This will happen when a load error occurs in the VM. |
| 46 // Give the machine time to start up. | 48 // Give the machine time to start up. |
| 47 setTimeout(function() { | 49 setTimeout(function() { |
| 48 if (window.layoutTestController | 50 // A window.postMessage might have been enqueued after this timeout. |
| 49 && !window.layoutTestController.startedDartTest) { | 51 // Just sleep another time to give the browser the time to process the |
| 50 window.layoutTestController.notifyDone(); | 52 // posted message. |
| 51 } | 53 setTimeout(function() { |
| 52 }, 3000); | 54 if (window.layoutTestController |
| 55 && !window.layoutTestController.startedDartTest) { | |
| 56 window.layoutTestController.notifyDone(); | |
| 57 } | |
| 58 }, 0); | |
| 59 }, 0); | |
| 53 </script> | 60 </script> |
| 54 </body> | 61 </body> |
| 55 </html> | 62 </html> |
| 56 """ | 63 """ |
| 57 | 64 |
| 58 DART_TEST_AS_LIBRARY = """ | 65 DART_TEST_AS_LIBRARY = """ |
| 59 #library('test'); | 66 #library('test'); |
| 60 #source('%(test)s'); | 67 #source('%(test)s'); |
| 61 """ | 68 """ |
| 62 | 69 |
| 63 DART_CONTENTS = """ | 70 DART_CONTENTS = """ |
| 64 #library('test'); | 71 #library('test'); |
| 65 | 72 |
| 66 #import('%(dom_library)s'); | 73 #import('%(dom_library)s'); |
| 67 #import('%(test_framework)s'); | 74 #import('%(test_framework)s'); |
| 68 | 75 |
| 69 #import('%(library)s', prefix: "Test"); | 76 #import('%(library)s', prefix: "Test"); |
| 70 | 77 |
| 78 wait() { | |
|
ngeoffray
2011/10/31 16:55:54
waitForDone?
floitsch
2011/10/31 16:59:48
Done.
| |
| 79 window.postMessage('unittest-suite-wait-for-done', '*'); | |
| 80 } | |
| 81 | |
| 71 pass() { | 82 pass() { |
| 72 document.body.innerHTML = 'PASS'; | 83 document.body.innerHTML = 'PASS'; |
| 73 window.postMessage('unittest-suite-done', '*'); | 84 window.postMessage('unittest-suite-done', '*'); |
| 74 } | 85 } |
| 75 | 86 |
| 76 fail(e, trace) { | 87 fail(e, trace) { |
| 77 document.body.innerHTML = 'FAIL: $e, $trace'; | 88 document.body.innerHTML = 'FAIL: $e, $trace'; |
| 78 window.postMessage('unittest-suite-done', '*'); | 89 window.postMessage('unittest-suite-done', '*'); |
| 79 } | 90 } |
| 80 | 91 |
| 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() { | 92 main() { |
| 87 bool needsToWait = false; | 93 bool needsToWait = false; |
| 88 bool mainIsFinished = false; | 94 bool mainIsFinished = false; |
| 89 TestRunner.waitForDoneCallback = () { needsToWait = true; }; | 95 TestRunner.waitForDoneCallback = () { needsToWait = true; }; |
| 90 TestRunner.doneCallback = () { | 96 TestRunner.doneCallback = () { |
| 91 if (mainIsFinished) { | 97 if (mainIsFinished) { |
| 92 pass(); | 98 pass(); |
| 93 } else { | 99 } else { |
| 94 needsToWait = false; | 100 needsToWait = false; |
| 95 } | 101 } |
| 96 }; | 102 }; |
| 97 try { | 103 try { |
| 98 Test.main(); | 104 Test.main(); |
| 99 if (!needsToWait) pass(); | 105 if (needsToWait) { |
| 106 wait(); | |
| 107 } else { | |
| 108 pass(); | |
| 109 } | |
| 100 mainIsFinished = true; | 110 mainIsFinished = true; |
| 101 } catch(var e, var trace) { | 111 } catch(var e, var trace) { |
| 102 fail(e, trace); | 112 fail(e, trace); |
| 103 } | 113 } |
| 104 } | 114 } |
| 105 """ | 115 """ |
| 106 | 116 |
| 107 | 117 |
| 108 # Patterns for matching test options in .dart files. | 118 # Patterns for matching test options in .dart files. |
| 109 DART_OPTIONS_PATTERN = re.compile(r'// DartOptions=(.*)') | 119 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) | 506 return ChromiumArchitecture(root_path, arch, mode, test) |
| 497 | 507 |
| 498 elif arch == 'dartium': | 508 elif arch == 'dartium': |
| 499 return DartiumArchitecture(root_path, arch, mode, test) | 509 return DartiumArchitecture(root_path, arch, mode, test) |
| 500 | 510 |
| 501 elif arch in ['ia32', 'x64', 'simarm', 'arm']: | 511 elif arch in ['ia32', 'x64', 'simarm', 'arm']: |
| 502 return RuntimeArchitecture(root_path, arch, mode, test) | 512 return RuntimeArchitecture(root_path, arch, mode, test) |
| 503 | 513 |
| 504 elif arch == 'dartc': | 514 elif arch == 'dartc': |
| 505 return DartcArchitecture(root_path, arch, mode, test) | 515 return DartcArchitecture(root_path, arch, mode, test) |
| OLD | NEW |