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

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

Issue 297233005: Support --batch for dart2js in testing script. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 'run_executable' : 1948 'run_executable' :
1949 isWindows ? 1949 isWindows ?
1950 'sdk\\bin\\dartanalyzer_developer.bat' 1950 'sdk\\bin\\dartanalyzer_developer.bat'
1951 : 'sdk/bin/dartanalyzer_developer', 1951 : 'sdk/bin/dartanalyzer_developer',
1952 'run_arguments' : ['--batch'], 1952 'run_arguments' : ['--batch'],
1953 }, 1953 },
1954 'dart2analyzer' : { 1954 'dart2analyzer' : {
1955 // This is a unix shell script, no windows equivalent available 1955 // This is a unix shell script, no windows equivalent available
1956 'run_executable' : 'editor/tools/analyzer', 1956 'run_executable' : 'editor/tools/analyzer',
1957 'run_arguments' : ['--batch'], 1957 'run_arguments' : ['--batch'],
1958 }, 1958 },
1959 }; 1959 };
1960 1960
1961 Completer<CommandOutput> _completer; 1961 Completer<CommandOutput> _completer;
1962 Command _command; 1962 Command _command;
1963 List<String> _arguments; 1963 List<String> _arguments;
1964 String _runnerType; 1964 String _runnerType;
1965 1965
1966 io.Process _process; 1966 io.Process _process;
1967 Map _processEnvironmentOverrides; 1967 Map _processEnvironmentOverrides;
1968 Completer _stdoutCompleter; 1968 Completer _stdoutCompleter;
1969 Completer _stderrCompleter; 1969 Completer _stderrCompleter;
1970 StreamSubscription<String> _stdoutSubscription; 1970 StreamSubscription<String> _stdoutSubscription;
1971 StreamSubscription<String> _stderrSubscription; 1971 StreamSubscription<String> _stderrSubscription;
1972 Function _processExitHandler; 1972 Function _processExitHandler;
1973 1973
1974 bool _currentlyRunning = false; 1974 bool _currentlyRunning = false;
1975 OutputLog _testStdout; 1975 OutputLog _testStdout;
1976 OutputLog _testStderr; 1976 OutputLog _testStderr;
1977 String _status; 1977 String _status;
1978 DateTime _startTime; 1978 DateTime _startTime;
1979 Timer _timer; 1979 Timer _timer;
1980 1980
1981 BatchRunnerProcess(); 1981 final String _executable;
1982
1983 BatchRunnerProcess(this._executable);
1982 1984
1983 Future<CommandOutput> runCommand(String runnerType, ProcessCommand command, 1985 Future<CommandOutput> runCommand(String runnerType, ProcessCommand command,
1984 int timeout, List<String> arguments) { 1986 int timeout, List<String> arguments) {
1985 assert(_completer == null); 1987 assert(_completer == null);
1986 assert(!_currentlyRunning); 1988 assert(!_currentlyRunning);
1987 1989
1988 _completer = new Completer<CommandOutput>(); 1990 _completer = new Completer<CommandOutput>();
1989 bool sameRunnerType = _runnerType == runnerType && 1991 bool sameRunnerType = _runnerType == runnerType &&
1990 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides); 1992 _dictEquals(_processEnvironmentOverrides, command.environmentOverrides);
1991 _runnerType = runnerType; 1993 _runnerType = runnerType;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 } 2086 }
2085 return handler; 2087 return handler;
2086 } 2088 }
2087 2089
2088 void _timeoutHandler() { 2090 void _timeoutHandler() {
2089 _processExitHandler = makeExitHandler(">>> TEST TIMEOUT"); 2091 _processExitHandler = makeExitHandler(">>> TEST TIMEOUT");
2090 _process.kill(); 2092 _process.kill();
2091 } 2093 }
2092 2094
2093 _startProcess(callback) { 2095 _startProcess(callback) {
2094 var executable = batchRunnerTypes[_runnerType]['run_executable']; 2096 var executable;
2095 var arguments = batchRunnerTypes[_runnerType]['run_arguments']; 2097 var arguments;
2098 if (_runnerType == 'dart2js') {
2099 executable = _executable;
2100 arguments = ['--batch'];
2101 } else {
2102 executable = batchRunnerTypes[_runnerType]['run_executable'];
2103 arguments = batchRunnerTypes[_runnerType]['run_arguments'];
2104 }
2096 var environment = new Map.from(io.Platform.environment); 2105 var environment = new Map.from(io.Platform.environment);
2097 if (_processEnvironmentOverrides != null) { 2106 if (_processEnvironmentOverrides != null) {
2098 for (var key in _processEnvironmentOverrides.keys) { 2107 for (var key in _processEnvironmentOverrides.keys) {
2099 environment[key] = _processEnvironmentOverrides[key]; 2108 environment[key] = _processEnvironmentOverrides[key];
2100 } 2109 }
2101 } 2110 }
2102 Future processFuture = io.Process.start(executable, 2111 Future processFuture = io.Process.start(executable,
2103 arguments, 2112 arguments,
2104 environment: environment); 2113 environment: environment);
2105 processFuture.then((io.Process p) { 2114 processFuture.then((io.Process p) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 }); 2532 });
2524 } 2533 }
2525 return runCommand(command.maxNumRetries); 2534 return runCommand(command.maxNumRetries);
2526 } 2535 }
2527 2536
2528 Future<CommandOutput> _runCommand(Command command, int timeout) { 2537 Future<CommandOutput> _runCommand(Command command, int timeout) {
2529 var batchMode = !globalConfiguration['noBatch']; 2538 var batchMode = !globalConfiguration['noBatch'];
2530 2539
2531 if (command is BrowserTestCommand) { 2540 if (command is BrowserTestCommand) {
2532 return _startBrowserControllerTest(command, timeout); 2541 return _startBrowserControllerTest(command, timeout);
2542 } else if (command is CompilationCommand && batchMode) {
2543 return _getBatchRunner(command.executable, "dart2js")
2544 .runCommand("dart2js", command, timeout, command.arguments);
2533 } else if (command is AnalysisCommand && batchMode) { 2545 } else if (command is AnalysisCommand && batchMode) {
2534 return _getBatchRunner(command.flavor) 2546 return _getBatchRunner(null, command.flavor)
2535 .runCommand(command.flavor, command, timeout, command.arguments); 2547 .runCommand(command.flavor, command, timeout, command.arguments);
2536 } else if (command is ScriptCommand) { 2548 } else if (command is ScriptCommand) {
2537 return command.run(); 2549 return command.run();
2538 } else { 2550 } else {
2539 return new RunningProcess(command, timeout).run(); 2551 return new RunningProcess(command, timeout).run();
2540 } 2552 }
2541 } 2553 }
2542 2554
2543 BatchRunnerProcess _getBatchRunner(String identifier) { 2555 BatchRunnerProcess _getBatchRunner(String executable, String identifier) {
2544 // Start batch processes if needed 2556 // Start batch processes if needed
2545 var runners = _batchProcesses[identifier]; 2557 var runners = _batchProcesses[identifier];
2546 if (runners == null) { 2558 if (runners == null) {
2547 runners = new List<BatchRunnerProcess>(maxProcesses); 2559 runners = new List<BatchRunnerProcess>(maxProcesses);
2548 for (int i = 0; i < maxProcesses; i++) { 2560 for (int i = 0; i < maxProcesses; i++) {
2549 runners[i] = new BatchRunnerProcess(); 2561 runners[i] = new BatchRunnerProcess(executable);
2550 } 2562 }
2551 _batchProcesses[identifier] = runners; 2563 _batchProcesses[identifier] = runners;
2552 } 2564 }
2553 2565
2554 for (var runner in runners) { 2566 for (var runner in runners) {
2555 if (!runner._currentlyRunning) return runner; 2567 if (!runner._currentlyRunning) return runner;
2556 } 2568 }
2557 throw new Exception('Unable to find inactive batch runner.'); 2569 throw new Exception('Unable to find inactive batch runner.');
2558 } 2570 }
2559 2571
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 } 2982 }
2971 } 2983 }
2972 2984
2973 void eventAllTestsDone() { 2985 void eventAllTestsDone() {
2974 for (var listener in _eventListener) { 2986 for (var listener in _eventListener) {
2975 listener.allDone(); 2987 listener.allDone();
2976 } 2988 }
2977 _allDone(); 2989 _allDone();
2978 } 2990 }
2979 } 2991 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698