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

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

Issue 10897016: Testrunner for 3rd parties. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « utils/testrunner/options.dart ('k') | utils/testrunner/pipeline_task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 List pipelineTemplate,
31 String test,
32 bool verbose,
33 Function completeHandler) :
34 _verbose = verbose,
35 _completeHandler = completeHandler {
36 _pipelineTemplate = pipelineTemplate;
37 _path = new Path(test);
38 _stdout = new List();
39 _stderr = new List();
40 }
41
42 /** Kick off excution with the first stage. */
43 void execute() {
44 _runStage(_stageNum = 0);
45 }
46
47 /** Execute a stage of the pipeline. */
48 void _runStage(int stageNum) {
49 _pipelineTemplate[stageNum].
50 execute(_path, _stdout, _stderr, _verbose, _handleExit);
51 }
52
53 /**
54 * [_handleExit] is called at the end of each stage. It will execute the
55 * next stage or call the completion handler if all are done.
56 */
57 void _handleExit(int exitCode) {
58 int totalStages = _pipelineTemplate.length;
59 _stageNum++;
60 String suffix = _verbose ? ' (step $_stageNum of $totalStages)' : '';
61
62 if (_verbose && exitCode != 0) {
63 _stderr.add('Test failed$suffix, exit code $exitCode\n');
64 }
65
66 if (_stageNum == totalStages || exitCode != 0) { // Done with pipeline.
67 for (var i = 0; i < _stageNum; i++) {
68 _pipelineTemplate[i].cleanup(_path, _stdout, _stderr, _verbose,
69 config.keepTests);
70 }
71 completeHandler(makePathAbsolute(_path.toString()), exitCode,
72 _stdout, _stderr);
73 } else {
74 if (_verbose) {
75 _stdout.add('Finished $suffix\n');
76 }
77 _runStage(_stageNum);
78 }
79 }
80 }
OLDNEW
« no previous file with comments | « utils/testrunner/options.dart ('k') | utils/testrunner/pipeline_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698