Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: utils/testrunner/pipeline_runner.dart

Issue 10977069: New testrunner that runs the test pipleine in an isolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 /**
6 * A [PipelineRunner] represents the execution of our pipeline for
7 * one test file.
8 */
9 class PipelineRunner {
10 /** The path of the test file. */
11 Path _path;
12
13 /** The pipeline template. */
14 List _pipelineTemplate;
15
16 /** String lists used to capture output. */
17 List _stdout;
18 List _stderr;
19
20 /** Whether the output should be verbose. */
21 bool _verbose;
22
23 /** Which stage of the pipeline is being executed. */
24 int _stageNum;
25
26 /** The handler to call when the pipeline is done. */
27 Function _completeHandler;
28
29 PipelineRunner(
30 this._pipelineTemplate,
31 String test,
32 this._verbose,
33 this._completeHandler) {
34 _path = new Path(test);
35 _stdout = new List();
36 _stderr = new List();
37 }
38
39 /** Kick off excution with the first stage. */
40 void execute() {
41 _runStage(_stageNum = 0);
42 }
43
44 /** Execute a stage of the pipeline. */
45 void _runStage(int stageNum) {
46 _pipelineTemplate[stageNum].
47 execute(_path, _stdout, _stderr, _verbose, _handleExit);
48 }
49
50 /**
51 * [_handleExit] is called at the end of each stage. It will execute the
52 * next stage or call the completion handler if all are done.
53 */
54 void _handleExit(int exitCode) {
55 int totalStages = _pipelineTemplate.length;
56 _stageNum++;
57 String suffix = _verbose ? ' (step $_stageNum of $totalStages)' : '';
58
59 if (_verbose && exitCode != 0) {
60 _stderr.add('Test failed$suffix, exit code $exitCode\n');
61 }
62
63 if (_stageNum == totalStages || exitCode != 0) { // Done with pipeline.
64 for (var i = 0; i < _stageNum; i++) {
65 _pipelineTemplate[i].cleanup(_path, _stdout, _stderr, _verbose,
66 config.keepTests);
67 }
68 completeHandler(makePathAbsolute(_path.toString()), exitCode,
69 _stdout, _stderr);
70 } else {
71 if (_verbose) {
72 _stdout.add('Finished $suffix\n');
73 }
74 _runStage(_stageNum);
75 }
76 }
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698