Chromium Code Reviews| Index: tools/testing/dart/test_runner.dart |
| diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart |
| index b5eb6f8ea9f686e9c8320580b7fb5372374d2e7a..4010f7b2f8975e977817483a7121a16f5d908346 100644 |
| --- a/tools/testing/dart/test_runner.dart |
| +++ b/tools/testing/dart/test_runner.dart |
| @@ -670,8 +670,9 @@ class CommandBuilder { |
| } |
| Command _getUniqueCommand(Command command) { |
| - // All Command classes have hashCode/operator==, so we check if this command |
| - // has already been build, if so we return the cached one, otherwise we |
| + // All Command classes implement hashCode and operator==. |
| + // We check if this command has already been built. |
| + // If so, we return the cached one. Otherwise we |
| // store the one given as [command] argument. |
| var cachedCommand = _cachedCommands[command]; |
| if (cachedCommand != null) { |
| @@ -1664,6 +1665,60 @@ CommandOutput createCommandOutput(Command command, |
| /** |
| + * An OutputLog records the output from a test, but truncates it if |
| + * it is longer than MAX_HEAD characters, and just keeps the head and |
| + * the last TAIL_LENGTH characters of the output. |
| + */ |
| +class OutputLog { |
| + static const int MAX_HEAD = 100000; |
| + static const int TAIL_LENGTH = 20000; |
|
kustermann
2014/04/08 15:23:47
I would make the limit lower and use 20 * 1024, so
Bill Hesse
2014/04/09 10:40:27
Done.
|
| + List<int> head = <int>[]; |
| + List<int> tail; |
| + bool dataDropped = false; |
| + |
| + OutputLog(); |
| + |
| + void add(List<int> data) { |
| + if (tail == null) { |
| + head.addAll(data); |
| + if (head.length > MAX_HEAD) { |
| + tail = head.sublist(MAX_HEAD); |
| + head.length = MAX_HEAD; |
| + } |
| + } else { |
| + tail.addAll(data); |
| + } |
| + if (tail != null && tail.length > 2 * TAIL_LENGTH) { |
| + tail = _truncatedTail(); |
| + dataDropped = true; |
| + } |
| + } |
| + |
| + List<int> _truncatedTail() => |
| + tail.length > TAIL_LENGTH ? |
| + tail.sublist(tail.length - TAIL_LENGTH) : |
| + tail; |
| + |
| + List<int> toList() { |
| + if (dataDropped) { |
| + head.addAll(""" |
| + |
| +***************************************************************************** |
| + |
| +Data removed due to excessive length |
| + |
| +***************************************************************************** |
| + |
| +""".codeUnits); |
| + head.addAll(_truncatedTail()); |
| + } else if (tail != null) { |
| + head.addAll(tail); |
| + } |
| + return head; |
|
kustermann
2014/04/08 15:23:47
This will get confusing if you call toList() sever
Bill Hesse
2014/04/09 10:40:27
Done.
|
| + } |
| +} |
| + |
| +/** |
| * A RunningProcess actually runs a test, getting the command lines from |
| * its [TestCase], starting the test process (and first, a compilation |
| * process if the TestCase is a [BrowserTestCase]), creating a timeout |
| @@ -1680,8 +1735,8 @@ class RunningProcess { |
| DateTime startTime; |
| Timer timeoutTimer; |
| int pid; |
| - List<int> stdout = <int>[]; |
| - List<int> stderr = <int>[]; |
| + OutputLog stdout = new OutputLog(); |
| + OutputLog stderr = new OutputLog(); |
| bool compilationSkipped = false; |
| Completer<CommandOutput> completer; |
| @@ -1804,8 +1859,8 @@ class RunningProcess { |
| command, |
| exitCode, |
| timedOut, |
| - stdout, |
| - stderr, |
| + stdout.toList(), |
| + stderr.toList(), |
| new DateTime.now().difference(startTime), |
| compilationSkipped, |
| pid); |
| @@ -1813,8 +1868,8 @@ class RunningProcess { |
| } |
| StreamSubscription _drainStream(Stream<List<int>> source, |
| - List<int> destination) { |
| - return source.listen(destination.addAll); |
| + OutputLog destination) { |
| + return source.listen(destination.add); |
| } |
| Map<String, String> _createProcessEnvironment() { |
| @@ -1865,8 +1920,8 @@ class BatchRunnerProcess { |
| Function _processExitHandler; |
| bool _currentlyRunning = false; |
| - List<int> _testStdout; |
| - List<int> _testStderr; |
| + OutputLog _testStdout; |
| + OutputLog _testStderr; |
| String _status; |
| DateTime _startTime; |
| Timer _timer; |
| @@ -1922,8 +1977,8 @@ class BatchRunnerProcess { |
| void doStartTest(Command command, int timeout) { |
| _startTime = new DateTime.now(); |
| - _testStdout = []; |
| - _testStderr = []; |
| + _testStdout = new OutputLog(); |
| + _testStderr = new OutputLog(); |
| _status = null; |
| _stdoutCompleter = new Completer(); |
| _stderrCompleter = new Completer(); |
| @@ -1953,8 +2008,8 @@ class BatchRunnerProcess { |
| var output = createCommandOutput(_command, |
| exitCode, |
| (outcome == "TIMEOUT"), |
| - _testStdout, |
| - _testStderr, |
| + _testStdout.toList(), |
| + _testStderr.toList(), |
| new DateTime.now().difference(_startTime), |
| false); |
| assert(_completer != null); |
| @@ -2010,8 +2065,8 @@ class BatchRunnerProcess { |
| } else if (line.startsWith('>>> ')) { |
| throw new Exception("Unexpected command from batch runner: '$line'."); |
| } else { |
| - _testStdout.addAll(encodeUtf8(line)); |
| - _testStdout.addAll("\n".codeUnits); |
| + _testStdout.add(encodeUtf8(line)); |
| + _testStdout.add("\n".codeUnits); |
| } |
| if (_status != null) { |
| _stdoutSubscription.pause(); |
| @@ -2030,8 +2085,8 @@ class BatchRunnerProcess { |
| _stderrSubscription.pause(); |
| _stderrCompleter.complete(null); |
| } else { |
| - _testStderr.addAll(encodeUtf8(line)); |
| - _testStderr.addAll("\n".codeUnits); |
| + _testStderr.add(encodeUtf8(line)); |
| + _testStderr.add("\n".codeUnits); |
| } |
| }); |
| _stderrSubscription.pause(); |