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

Side by Side Diff: tools/testing/dart/test_runner.dart

Issue 11035027: Add in-process http server to the dart test scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address more comments. 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Classes and methods for executing tests. 6 * Classes and methods for executing tests.
7 * 7 *
8 * This module includes: 8 * This module includes:
9 * - Managing parallel execution of tests, including timeout checks. 9 * - Managing parallel execution of tests, including timeout checks.
10 * - Evaluating the output of each test as pass/fail/crash/timeout. 10 * - Evaluating the output of each test as pass/fail/crash/timeout.
11 */ 11 */
12 #library("test_runner"); 12 #library("test_runner");
13 13
14 #import("dart:io"); 14 #import("dart:io");
15 #import("dart:isolate"); 15 #import("dart:isolate");
16 #import("status_file_parser.dart"); 16 #import("status_file_parser.dart");
17 #import("test_progress.dart"); 17 #import("test_progress.dart");
18 #import("test_suite.dart"); 18 #import("test_suite.dart");
19 19
20 const int NO_TIMEOUT = 0; 20 const int NO_TIMEOUT = 0;
21 const int SLOW_TIMEOUT_MULTIPLIER = 4; 21 const int SLOW_TIMEOUT_MULTIPLIER = 4;
22 22
23 typedef void TestCaseEvent(TestCase testCase); 23 typedef void TestCaseEvent(TestCase testCase);
24 typedef void ExitCodeEvent(int exitCode); 24 typedef void ExitCodeEvent(int exitCode);
25 typedef bool EnqueMoreWork(ProcessQueue queue); 25 typedef bool EnqueueMoreWork(ProcessQueue queue);
26 26
27 /** A command executed as a step in a test case. */ 27 /** A command executed as a step in a test case. */
28 class Command { 28 class Command {
29 /** Path to the executable of this command. */ 29 /** Path to the executable of this command. */
30 String executable; 30 String executable;
31 31
32 /** Command line arguments to the executable. */ 32 /** Command line arguments to the executable. */
33 List<String> arguments; 33 List<String> arguments;
34 34
35 /** The actual command line that will be executed. */ 35 /** The actual command line that will be executed. */
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 */ 946 */
947 class ProcessQueue { 947 class ProcessQueue {
948 int _numProcesses = 0; 948 int _numProcesses = 0;
949 int _activeTestListers = 0; 949 int _activeTestListers = 0;
950 int _maxProcesses; 950 int _maxProcesses;
951 951
952 /** The number of tests we allow to actually fail before we stop retrying. */ 952 /** The number of tests we allow to actually fail before we stop retrying. */
953 int _MAX_FAILED_NO_RETRY = 4; 953 int _MAX_FAILED_NO_RETRY = 4;
954 bool _verbose; 954 bool _verbose;
955 bool _listTests; 955 bool _listTests;
956 EnqueMoreWork _enqueueMoreWork; 956 Function _allDone;
957 EnqueueMoreWork _enqueueMoreWork;
957 Queue<TestCase> _tests; 958 Queue<TestCase> _tests;
958 ProgressIndicator _progress; 959 ProgressIndicator _progress;
959 960
960 // For dartc/selenium batch processing we keep a list of batch processes. 961 // For dartc/selenium batch processing we keep a list of batch processes.
961 Map<String, List<BatchRunnerProcess>> _batchProcesses; 962 Map<String, List<BatchRunnerProcess>> _batchProcesses;
962 963
963 // Cache information about test cases per test suite. For multiple 964 // Cache information about test cases per test suite. For multiple
964 // configurations there is no need to repeatedly search the file 965 // configurations there is no need to repeatedly search the file
965 // system, generate tests, and search test files for options. 966 // system, generate tests, and search test files for options.
966 Map<String, List<TestInformation>> _testCache; 967 Map<String, List<TestInformation>> _testCache;
(...skipping 14 matching lines...) Expand all
981 bool _startingServer = false; 982 bool _startingServer = false;
982 983
983 /** True if we find that there is already a selenium jar running. */ 984 /** True if we find that there is already a selenium jar running. */
984 bool _seleniumAlreadyRunning = false; 985 bool _seleniumAlreadyRunning = false;
985 986
986 ProcessQueue(int this._maxProcesses, 987 ProcessQueue(int this._maxProcesses,
987 String progress, 988 String progress,
988 Date startTime, 989 Date startTime,
989 bool printTiming, 990 bool printTiming,
990 this._enqueueMoreWork, 991 this._enqueueMoreWork,
992 this._allDone,
991 [bool verbose = false, 993 [bool verbose = false,
992 bool listTests = false]) 994 bool listTests = false])
993 : _verbose = verbose, 995 : _verbose = verbose,
994 _listTests = listTests, 996 _listTests = listTests,
995 _tests = new Queue<TestCase>(), 997 _tests = new Queue<TestCase>(),
996 _progress = new ProgressIndicator.fromName(progress, 998 _progress = new ProgressIndicator.fromName(progress,
997 startTime, 999 startTime,
998 printTiming), 1000 printTiming),
999 _batchProcesses = new Map<String, List<BatchRunnerProcess>>(), 1001 _batchProcesses = new Map<String, List<BatchRunnerProcess>>(),
1000 _testCache = new Map<String, List<TestInformation>>() { 1002 _testCache = new Map<String, List<TestInformation>>() {
1001 if (!_enqueueMoreWork(this)) _progress.allDone(); 1003 _checkDone();
1002 } 1004 }
1003 1005
1004 /** 1006 /**
1005 * Registers a TestSuite so that all of its tests will be run. 1007 * Registers a TestSuite so that all of its tests will be run.
1006 */ 1008 */
1007 void addTestSuite(TestSuite testSuite) { 1009 void addTestSuite(TestSuite testSuite) {
1008 _activeTestListers++; 1010 _activeTestListers++;
1009 testSuite.forEachTest(_runTest, _testCache, _testListerDone); 1011 testSuite.forEachTest(_runTest, _testCache, _testListerDone);
1010 } 1012 }
1011 1013
1012 void _testListerDone() { 1014 void _testListerDone() {
1013 _activeTestListers--; 1015 _activeTestListers--;
1014 _checkDone(); 1016 _checkDone();
1015 } 1017 }
1016 1018
1017 /** 1019 /**
1018 * Perform any cleanup needed once all tests in a TestSuite have completed 1020 * Perform any cleanup needed once all tests in a TestSuite have completed
1019 * and notify our progress indicator that we are done. 1021 * and notify our progress indicator that we are done.
1020 */ 1022 */
1021 void _cleanupAndMarkDone() { 1023 void _cleanupAndMarkDone() {
1024 // _progress.allDone() exits the process, so we have to call the
1025 // _allDone callback before.
1026 _allDone();
1022 if (browserUsed != '' && _seleniumServer != null) { 1027 if (browserUsed != '' && _seleniumServer != null) {
1023 _seleniumServer.kill(); 1028 _seleniumServer.kill();
1024 } else { 1029 } else {
1025 _progress.allDone(); 1030 _progress.allDone();
1026 } 1031 }
1027 } 1032 }
1028 1033
1029 void _checkDone() { 1034 void _checkDone() {
1030 // When there are no more active test listers ask for more work 1035 // When there are no more active test listers ask for more work
1031 // from process queue users. 1036 // from process queue users.
1032 if (_activeTestListers == 0 && !_enqueueMoreWork(this)) { 1037 if (_activeTestListers == 0) {
1038 _enqueueMoreWork(this);
1039 }
1040 // If there is still no work, we are done.
1041 if (_activeTestListers == 0) {
1033 _progress.allTestsKnown(); 1042 _progress.allTestsKnown();
1034 if (_tests.isEmpty() && _numProcesses == 0) { 1043 if (_tests.isEmpty() && _numProcesses == 0) {
1035 _terminateBatchRunners(); 1044 _terminateBatchRunners();
1036 _cleanupAndMarkDone(); 1045 _cleanupAndMarkDone();
1037 } 1046 }
1038 } 1047 }
1039 } 1048 }
1040 1049
1041 /** 1050 /**
1042 * True if we are using a browser + platform combination that needs the 1051 * True if we are using a browser + platform combination that needs the
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 // the developer doesn't waste his or her time trying to fix a bunch of 1245 // the developer doesn't waste his or her time trying to fix a bunch of
1237 // tests that appear to be broken but were actually just flakes that 1246 // tests that appear to be broken but were actually just flakes that
1238 // didn't get retried because there had already been one failure. 1247 // didn't get retried because there had already been one failure.
1239 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; 1248 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests;
1240 new RunningProcess(test, allowRetry, this).start(); 1249 new RunningProcess(test, allowRetry, this).start();
1241 } 1250 }
1242 _numProcesses++; 1251 _numProcesses++;
1243 } 1252 }
1244 } 1253 }
1245 } 1254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698