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

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
Index: utils/testrunner/pipeline_runner.dart
===================================================================
--- utils/testrunner/pipeline_runner.dart (revision 0)
+++ utils/testrunner/pipeline_runner.dart (revision 0)
@@ -0,0 +1,65 @@
+// 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();
+ }
+
+ void execute() {
+ runStage(_stageNum = 0);
+ }
+
+ 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.
+ completeHandler(makePathAbsolute(_path.toString()), exitCode,
+ _stdout, _stderr);
+ } else {
+ if (_verbose) {
+ _stdout.add('Finished $suffix\n');
+ }
+ runStage(_stageNum);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698