OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library testing.log; | 5 library testing.log; |
6 | 6 |
7 import 'chain.dart' show | 7 import 'chain.dart' show |
8 Result, | 8 Result, |
9 Step; | 9 Step; |
10 | 10 |
11 import 'suite.dart' show | 11 import 'suite.dart' show |
12 Suite; | 12 Suite; |
13 | 13 |
14 import 'test_description.dart' show | 14 import 'test_description.dart' show |
15 TestDescription; | 15 TestDescription; |
16 | 16 |
17 import 'test_dart/status_file_parser.dart' show | 17 import 'expectation.dart' show |
18 Expectation; | 18 Expectation; |
19 | 19 |
20 /// ANSI escape code for moving cursor one line up. | 20 /// ANSI escape code for moving cursor one line up. |
21 /// See [CSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes). | 21 /// See [CSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes). |
22 const String cursorUp = "\u001b[1A"; | 22 const String cursorUp = "\u001b[1A"; |
23 | 23 |
24 /// ANSI escape code for erasing the entire line. | 24 /// ANSI escape code for erasing the entire line. |
25 /// See [CSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes). | 25 /// See [CSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes). |
26 const String eraseLine = "\u001b[2K"; | 26 const String eraseLine = "\u001b[2K"; |
27 | 27 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 print(numberedLines(text)); | 99 print(numberedLines(text)); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 void logUnexpectedResult(Suite suite, TestDescription description, | 103 void logUnexpectedResult(Suite suite, TestDescription description, |
104 Result result, Set<Expectation> expectedOutcomes) { | 104 Result result, Set<Expectation> expectedOutcomes) { |
105 print("${eraseLine}UNEXPECTED: ${suite.name}/${description.shortName}"); | 105 print("${eraseLine}UNEXPECTED: ${suite.name}/${description.shortName}"); |
106 Uri statusFile = suite.statusFile; | 106 Uri statusFile = suite.statusFile; |
107 if (statusFile != null) { | 107 if (statusFile != null) { |
108 String path = statusFile.toFilePath(); | 108 String path = statusFile.toFilePath(); |
109 if (result.outcome == Expectation.PASS) { | 109 if (result.outcome == Expectation.Pass) { |
110 print("The test unexpectedly passed, please update $path."); | 110 print("The test unexpectedly passed, please update $path."); |
111 } else { | 111 } else { |
112 print("The test had the outcome ${result.outcome}, but the status file " | 112 print("The test had the outcome ${result.outcome}, but the status file " |
113 "($path) allows these outcomes: ${expectedOutcomes.join(' ')}"); | 113 "($path) allows these outcomes: ${expectedOutcomes.join(' ')}"); |
114 } | 114 } |
115 } | 115 } |
116 String log = result.log; | 116 String log = result.log; |
117 if (log.isNotEmpty) { | 117 if (log.isNotEmpty) { |
118 print(log); | 118 print(log); |
119 } | 119 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 paddedLineNumber.substring(paddedLineNumber.length - pad); | 155 paddedLineNumber.substring(paddedLineNumber.length - pad); |
156 result.write("$paddedLineNumber: $line"); | 156 result.write("$paddedLineNumber: $line"); |
157 lineNumber++; | 157 lineNumber++; |
158 } | 158 } |
159 return '$result'; | 159 return '$result'; |
160 } | 160 } |
161 | 161 |
162 List<String> splitLines(String text) { | 162 List<String> splitLines(String text) { |
163 return text.split(new RegExp('^', multiLine: true)); | 163 return text.split(new RegExp('^', multiLine: true)); |
164 } | 164 } |
OLD | NEW |