OLD | NEW |
(Empty) | |
| 1 // |
| 2 // Copyright 2014 Google Inc. All rights reserved. |
| 3 // |
| 4 // Use of this source code is governed by a BSD-style |
| 5 // license that can be found in the LICENSE file or at |
| 6 // https://developers.google.com/open-source/licenses/bsd |
| 7 // |
| 8 |
| 9 library charted.tool.hop_runner; |
| 10 |
| 11 import 'package:hop/hop.dart'; |
| 12 import 'dart:io'; |
| 13 |
| 14 main(List<String> args) { |
| 15 addTask('unit-test', createUnitTestsTask()); |
| 16 runHop(args); |
| 17 } |
| 18 |
| 19 Task createUnitTestsTask() => |
| 20 new Task((TaskContext context) { |
| 21 context.info("Running tests..."); |
| 22 return Process.run('./content_shell', |
| 23 ['--dump-render-tree','test/test_in_browser.html']). |
| 24 then((ProcessResult process) => |
| 25 checkTestsOutput(context, process)); |
| 26 }); |
| 27 |
| 28 /// Reads the output from content_shell and checks for number of tests |
| 29 /// passed/failed/erred. This method requires that the tests be done |
| 30 /// in simple html unit test configuration - useHtmlConfiguration(). |
| 31 void checkTestsOutput(TaskContext context, ProcessResult process) { |
| 32 var output = (process.stdout as String), |
| 33 failRegEx = new RegExp(r"^[0-9]+\s+FAIL\s"), |
| 34 errorRegEx = new RegExp(r"^[0-9]+\s+ERROR\s"), |
| 35 failCount = 0, |
| 36 errorCount = 0; |
| 37 |
| 38 context.info(output); |
| 39 |
| 40 for (var line in output.split('\n')) { |
| 41 if (line.contains(failRegEx)) failCount++; |
| 42 if (line.contains(errorRegEx)) errorCount++; |
| 43 } |
| 44 |
| 45 if (failCount + errorCount > 0) { |
| 46 context.fail('FAIL: $failCount\nERROR: $errorCount'); |
| 47 } |
| 48 } |
OLD | NEW |