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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/testrunner/options.dart ('k') | utils/testrunner/pipeline_task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/testrunner/pipeline_runner.dart
===================================================================
--- utils/testrunner/pipeline_runner.dart (revision 0)
+++ utils/testrunner/pipeline_runner.dart (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * A [PipelineRunner] represents the execution of our pipeline for
+ * one test file.
+ */
+class PipelineRunner {
+ /** The path of the test file. */
+ Path _path;
+
+ /** The pipeline template. */
+ List _pipelineTemplate;
+
+ /** String lists used to capture output. */
+ List _stdout;
+ List _stderr;
+
+ /** Whether the output should be verbose. */
+ bool _verbose;
+
+ /** Which stage of the pipeline is being executed. */
+ int _stageNum;
+
+ /** The handler to call when the pipeline is done. */
+ Function _completeHandler;
+
+ PipelineRunner(
+ List pipelineTemplate,
+ String test,
+ bool verbose,
+ Function completeHandler) :
+ _verbose = verbose,
+ _completeHandler = completeHandler {
+ _pipelineTemplate = pipelineTemplate;
+ _path = new Path(test);
+ _stdout = new List();
+ _stderr = new List();
+ }
+
+ /** Kick off excution with the first stage. */
+ void execute() {
+ _runStage(_stageNum = 0);
+ }
+
+ /** Execute a stage of the pipeline. */
+ void _runStage(int stageNum) {
+ _pipelineTemplate[stageNum].
+ execute(_path, _stdout, _stderr, _verbose, _handleExit);
+ }
+
+ /**
+ * [_handleExit] is called at the end of each stage. It will execute the
+ * next stage or call the completion handler if all are done.
+ */
+ void _handleExit(int exitCode) {
+ int totalStages = _pipelineTemplate.length;
+ _stageNum++;
+ String suffix = _verbose ? ' (step $_stageNum of $totalStages)' : '';
+
+ if (_verbose && exitCode != 0) {
+ _stderr.add('Test failed$suffix, exit code $exitCode\n');
+ }
+
+ if (_stageNum == totalStages || exitCode != 0) { // Done with pipeline.
+ for (var i = 0; i < _stageNum; i++) {
+ _pipelineTemplate[i].cleanup(_path, _stdout, _stderr, _verbose,
+ config.keepTests);
+ }
+ completeHandler(makePathAbsolute(_path.toString()), exitCode,
+ _stdout, _stderr);
+ } else {
+ if (_verbose) {
+ _stdout.add('Finished $suffix\n');
+ }
+ _runStage(_stageNum);
+ }
+ }
+}
« 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