OLD | NEW |
---|---|
(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 // A [PipelineRunner] represents the execution of our pipeline for one test | |
Siggi Cherem (dart-lang)
2012/08/29 01:05:55
see general style comments in testrunner.dart (e.g
gram
2012/08/29 20:12:26
Done.
| |
6 // file. | |
7 class PipelineRunner { | |
8 // The path of the test file. | |
9 Path _path; | |
10 // The pipeline template. | |
11 List _pipelineTemplate; | |
12 // String lists used to capture output. | |
13 List _stdout; | |
14 List _stderr; | |
15 // Whether the output should be verbose. | |
16 bool _verbose; | |
17 // Which stage of the pipeline is being executed. | |
18 int _stageNum; | |
19 // The handler to call when the pipeline is done. | |
20 Function _completeHandler; | |
21 | |
22 PipelineRunner( | |
23 List pipelineTemplate, | |
24 String test, | |
25 bool verbose, | |
26 Function completeHandler) : | |
27 _verbose = verbose, | |
28 _completeHandler = completeHandler { | |
29 _pipelineTemplate = pipelineTemplate; | |
30 _path = new Path(test); | |
31 _stdout = new List(); | |
32 _stderr = new List(); | |
33 } | |
34 | |
35 void execute() { | |
36 runStage(_stageNum = 0); | |
37 } | |
38 | |
39 void runStage(int stageNum) { | |
40 _pipelineTemplate[stageNum]. | |
41 execute(_path, _stdout, _stderr, _verbose, handleExit); | |
42 } | |
43 | |
44 // [handleExit] is called at the end of each stage. It will execute the | |
45 // next stage or call the completion handler if all are done. | |
46 void handleExit(int exitCode) { | |
47 int totalStages = _pipelineTemplate.length; | |
48 ++_stageNum; | |
Siggi Cherem (dart-lang)
2012/08/29 01:05:55
style nit: prefer postfix ++
gram
2012/08/29 20:12:26
Is there a good reason for this? Maybe I'm just sh
| |
49 String suffix = _verbose ? ' (step $_stageNum of $totalStages)' : ''; | |
50 | |
51 if (_verbose && exitCode != 0) { | |
52 _stderr.add('Test failed$suffix, exit code $exitCode\n'); | |
53 } | |
54 | |
55 if (_stageNum == totalStages || exitCode != 0) { // Done with pipeline. | |
56 completeHandler(makePathAbsolute(_path.toString()), exitCode, | |
57 _stdout, _stderr); | |
58 } else { | |
59 if (_verbose) { | |
60 _stdout.add('Finished $suffix\n'); | |
61 } | |
62 runStage(_stageNum); | |
63 } | |
64 } | |
65 } | |
OLD | NEW |