| OLD | NEW |
| 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. |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 } | 1934 } |
| 1935 for (var excludedEnvironmentVariable in EXCLUDED_ENVIRONMENT_VARIABLES) { | 1935 for (var excludedEnvironmentVariable in EXCLUDED_ENVIRONMENT_VARIABLES) { |
| 1936 environment.remove(excludedEnvironmentVariable); | 1936 environment.remove(excludedEnvironmentVariable); |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 return environment; | 1939 return environment; |
| 1940 } | 1940 } |
| 1941 } | 1941 } |
| 1942 | 1942 |
| 1943 class BatchRunnerProcess { | 1943 class BatchRunnerProcess { |
| 1944 static bool isWindows = io.Platform.operatingSystem == 'windows'; | |
| 1945 | |
| 1946 final batchRunnerTypes = { | |
| 1947 'dartanalyzer' : { | |
| 1948 'run_executable' : | |
| 1949 isWindows ? | |
| 1950 'sdk\\bin\\dartanalyzer_developer.bat' | |
| 1951 : 'sdk/bin/dartanalyzer_developer', | |
| 1952 'run_arguments' : ['--batch'], | |
| 1953 }, | |
| 1954 'dart2analyzer' : { | |
| 1955 // This is a unix shell script, no windows equivalent available | |
| 1956 'run_executable' : 'editor/tools/analyzer', | |
| 1957 'run_arguments' : ['--batch'], | |
| 1958 }, | |
| 1959 }; | |
| 1960 | |
| 1961 Completer<CommandOutput> _completer; | 1944 Completer<CommandOutput> _completer; |
| 1962 Command _command; | 1945 ProcessCommand _command; |
| 1963 List<String> _arguments; | 1946 List<String> _arguments; |
| 1964 String _runnerType; | 1947 String _runnerType; |
| 1965 | 1948 |
| 1966 io.Process _process; | 1949 io.Process _process; |
| 1967 Map _processEnvironmentOverrides; | 1950 Map _processEnvironmentOverrides; |
| 1968 Completer _stdoutCompleter; | 1951 Completer _stdoutCompleter; |
| 1969 Completer _stderrCompleter; | 1952 Completer _stderrCompleter; |
| 1970 StreamSubscription<String> _stdoutSubscription; | 1953 StreamSubscription<String> _stdoutSubscription; |
| 1971 StreamSubscription<String> _stderrSubscription; | 1954 StreamSubscription<String> _stderrSubscription; |
| 1972 Function _processExitHandler; | 1955 Function _processExitHandler; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1985 assert(_completer == null); | 1968 assert(_completer == null); |
| 1986 assert(!_currentlyRunning); | 1969 assert(!_currentlyRunning); |
| 1987 | 1970 |
| 1988 _completer = new Completer<CommandOutput>(); | 1971 _completer = new Completer<CommandOutput>(); |
| 1989 bool sameRunnerType = _runnerType == runnerType && | 1972 bool sameRunnerType = _runnerType == runnerType && |
| 1990 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides); | 1973 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides); |
| 1991 _runnerType = runnerType; | 1974 _runnerType = runnerType; |
| 1992 _currentlyRunning = true; | 1975 _currentlyRunning = true; |
| 1993 _command = command; | 1976 _command = command; |
| 1994 _arguments = arguments; | 1977 _arguments = arguments; |
| 1995 | |
| 1996 _processEnvironmentOverrides = command.environmentOverrides; | 1978 _processEnvironmentOverrides = command.environmentOverrides; |
| 1997 | 1979 |
| 1998 if (_process == null) { | 1980 if (_process == null) { |
| 1999 // Start process if not yet started. | 1981 // Start process if not yet started. |
| 2000 _startProcess(() { | 1982 _startProcess(() { |
| 2001 doStartTest(command, timeout); | 1983 doStartTest(command, timeout); |
| 2002 }); | 1984 }); |
| 2003 } else if (!sameRunnerType) { | 1985 } else if (!sameRunnerType) { |
| 2004 // Restart this runner with the right executable for this test if needed. | 1986 // Restart this runner with the right executable for this test if needed. |
| 2005 _processExitHandler = (_) { | 1987 _processExitHandler = (_) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 } | 2066 } |
| 2085 return handler; | 2067 return handler; |
| 2086 } | 2068 } |
| 2087 | 2069 |
| 2088 void _timeoutHandler() { | 2070 void _timeoutHandler() { |
| 2089 _processExitHandler = makeExitHandler(">>> TEST TIMEOUT"); | 2071 _processExitHandler = makeExitHandler(">>> TEST TIMEOUT"); |
| 2090 _process.kill(); | 2072 _process.kill(); |
| 2091 } | 2073 } |
| 2092 | 2074 |
| 2093 _startProcess(callback) { | 2075 _startProcess(callback) { |
| 2094 var executable = batchRunnerTypes[_runnerType]['run_executable']; | 2076 assert(_command is ProcessCommand); |
| 2095 var arguments = batchRunnerTypes[_runnerType]['run_arguments']; | 2077 var executable = _command.executable; |
| 2078 var arguments = ['--batch']; |
| 2096 var environment = new Map.from(io.Platform.environment); | 2079 var environment = new Map.from(io.Platform.environment); |
| 2097 if (_processEnvironmentOverrides != null) { | 2080 if (_processEnvironmentOverrides != null) { |
| 2098 for (var key in _processEnvironmentOverrides.keys) { | 2081 for (var key in _processEnvironmentOverrides.keys) { |
| 2099 environment[key] = _processEnvironmentOverrides[key]; | 2082 environment[key] = _processEnvironmentOverrides[key]; |
| 2100 } | 2083 } |
| 2101 } | 2084 } |
| 2102 Future processFuture = io.Process.start(executable, | 2085 Future processFuture = io.Process.start(executable, |
| 2103 arguments, | 2086 arguments, |
| 2104 environment: environment); | 2087 environment: environment); |
| 2105 processFuture.then((io.Process p) { | 2088 processFuture.then((io.Process p) { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 } else { | 2503 } else { |
| 2521 return new Future.value(output); | 2504 return new Future.value(output); |
| 2522 } | 2505 } |
| 2523 }); | 2506 }); |
| 2524 } | 2507 } |
| 2525 return runCommand(command.maxNumRetries); | 2508 return runCommand(command.maxNumRetries); |
| 2526 } | 2509 } |
| 2527 | 2510 |
| 2528 Future<CommandOutput> _runCommand(Command command, int timeout) { | 2511 Future<CommandOutput> _runCommand(Command command, int timeout) { |
| 2529 var batchMode = !globalConfiguration['noBatch']; | 2512 var batchMode = !globalConfiguration['noBatch']; |
| 2513 var dart2jsBatchMode = globalConfiguration['dart2js_batch']; |
| 2530 | 2514 |
| 2531 if (command is BrowserTestCommand) { | 2515 if (command is BrowserTestCommand) { |
| 2532 return _startBrowserControllerTest(command, timeout); | 2516 return _startBrowserControllerTest(command, timeout); |
| 2517 } else if (command is CompilationCommand && dart2jsBatchMode) { |
| 2518 return _getBatchRunner("dart2js") |
| 2519 .runCommand("dart2js", command, timeout, command.arguments); |
| 2533 } else if (command is AnalysisCommand && batchMode) { | 2520 } else if (command is AnalysisCommand && batchMode) { |
| 2534 return _getBatchRunner(command.flavor) | 2521 return _getBatchRunner(command.flavor) |
| 2535 .runCommand(command.flavor, command, timeout, command.arguments); | 2522 .runCommand(command.flavor, command, timeout, command.arguments); |
| 2536 } else if (command is ScriptCommand) { | 2523 } else if (command is ScriptCommand) { |
| 2537 return command.run(); | 2524 return command.run(); |
| 2538 } else { | 2525 } else { |
| 2539 return new RunningProcess(command, timeout).run(); | 2526 return new RunningProcess(command, timeout).run(); |
| 2540 } | 2527 } |
| 2541 } | 2528 } |
| 2542 | 2529 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 } | 2957 } |
| 2971 } | 2958 } |
| 2972 | 2959 |
| 2973 void eventAllTestsDone() { | 2960 void eventAllTestsDone() { |
| 2974 for (var listener in _eventListener) { | 2961 for (var listener in _eventListener) { |
| 2975 listener.allDone(); | 2962 listener.allDone(); |
| 2976 } | 2963 } |
| 2977 _allDone(); | 2964 _allDone(); |
| 2978 } | 2965 } |
| 2979 } | 2966 } |
| OLD | NEW |