mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:48:25 +00:00
Remove unused record and replay functionality.
R=whesse@google.com Review-Url: https://codereview.chromium.org/2920633002 .
This commit is contained in:
parent
6d8b7c8806
commit
8bc4e89219
|
@ -58,8 +58,6 @@ class Configuration {
|
|||
this.dartPath,
|
||||
this.dartPrecompiledPath,
|
||||
this.flutterPath,
|
||||
this.recordingPath,
|
||||
this.replayPath,
|
||||
this.taskCount,
|
||||
int timeout,
|
||||
this.shardCount,
|
||||
|
@ -125,8 +123,6 @@ class Configuration {
|
|||
final String dartPath;
|
||||
final String dartPrecompiledPath;
|
||||
final String flutterPath;
|
||||
final String recordingPath;
|
||||
final String replayPath;
|
||||
|
||||
final int taskCount;
|
||||
final int shardCount;
|
||||
|
|
|
@ -267,10 +267,6 @@ used for browsers to connect to.''',
|
|||
new _Option.int(
|
||||
'test_driver_error_port', 'Port for http test driver server errors.',
|
||||
defaultsTo: 0),
|
||||
new _Option('record_to_file',
|
||||
'Records all commands to be executed and writes to a file.'),
|
||||
new _Option(
|
||||
'replay_from_file', 'Replays a previously recorded list of commands.'),
|
||||
new _Option(
|
||||
'builder_tag',
|
||||
'''Machine specific options that is not captured by the regular test
|
||||
|
@ -619,8 +615,6 @@ compiler.''')
|
|||
dartPath: data["dart"] as String,
|
||||
dartPrecompiledPath: data["dart_precompiled"] as String,
|
||||
flutterPath: data["flutter"] as String,
|
||||
recordingPath: data["record_to_file"] as String,
|
||||
replayPath: data["replay_from_file"] as String,
|
||||
taskCount: data["tasks"] as int,
|
||||
timeout: data["timeout"] as int,
|
||||
shardCount: data["shards"] as int,
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
// 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.
|
||||
|
||||
library record_and_replay;
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'path.dart';
|
||||
import 'test_runner.dart';
|
||||
|
||||
/*
|
||||
* Json files look like this:
|
||||
*
|
||||
* [
|
||||
* {
|
||||
* 'name' : '...',
|
||||
* 'command' : {
|
||||
* 'timeout_limit' : 60,
|
||||
* 'executable' : '...',
|
||||
* 'arguments' : ['arg1, 'arg2', '...'],
|
||||
* },
|
||||
* 'command_output' : {
|
||||
* 'exit_code' : 42,
|
||||
* 'stdout' : '...',
|
||||
* 'stderr' : '...',
|
||||
* 'duration' : 1.5,
|
||||
* 'did_timeout' : false,
|
||||
* },
|
||||
* },
|
||||
* ....
|
||||
* ]
|
||||
*/
|
||||
|
||||
List<String> makePathsRelativeToDart(String cwd, List<String> arguments) {
|
||||
var relativeArguments = <String>[];
|
||||
for (var rawArgument in arguments) {
|
||||
if (rawArgument.startsWith(cwd)) {
|
||||
var relative = new Path(rawArgument).relativeTo(new Path(cwd));
|
||||
relativeArguments.add(relative.toNativePath());
|
||||
} else {
|
||||
relativeArguments.add(rawArgument);
|
||||
}
|
||||
}
|
||||
return relativeArguments;
|
||||
}
|
||||
|
||||
class TestCaseRecorder {
|
||||
Path _outputPath;
|
||||
List<Map> _recordedCommandInvocations = [];
|
||||
String _cwd;
|
||||
|
||||
TestCaseRecorder(this._outputPath) {
|
||||
_cwd = Directory.current.path;
|
||||
}
|
||||
|
||||
void nextCommand(ProcessCommand command, int timeout) {
|
||||
// Convert arguments from absolute to relative paths (relative to the dart
|
||||
// directory) because the absolute path on the machine where we record
|
||||
// may be different from the absolute path on the machine where we execute
|
||||
// the commands.
|
||||
var arguments = makePathsRelativeToDart(_cwd, command.arguments);
|
||||
|
||||
var commandExecution = {
|
||||
'name': command.displayName,
|
||||
'command': {
|
||||
'timeout_limit': timeout,
|
||||
'executable': command.executable,
|
||||
'arguments': arguments,
|
||||
},
|
||||
};
|
||||
_recordedCommandInvocations.add(commandExecution);
|
||||
}
|
||||
|
||||
void finish() {
|
||||
var file = new File(_outputPath.toNativePath());
|
||||
var jsonString = JSON.encode(_recordedCommandInvocations);
|
||||
file.writeAsStringSync(jsonString);
|
||||
print("TestCaseRecorder: written all TestCases to ${_outputPath}");
|
||||
}
|
||||
}
|
||||
|
||||
class TestCaseOutputArchive {
|
||||
Map<String, Map> _commandOutputRecordings;
|
||||
String _cwd;
|
||||
|
||||
TestCaseOutputArchive() {
|
||||
_cwd = Directory.current.path;
|
||||
}
|
||||
|
||||
void loadFromPath(Path recordingPath) {
|
||||
var file = new File(recordingPath.toNativePath());
|
||||
var commandRecordings = JSON.decode(file.readAsStringSync()) as List;
|
||||
_commandOutputRecordings = {};
|
||||
for (var commandRecording in commandRecordings) {
|
||||
var key = _indexKey(commandRecording['command']['executable'] as String,
|
||||
(commandRecording['command']['arguments'] as List).join(' '));
|
||||
_commandOutputRecordings[key] = commandRecording['command_output'] as Map;
|
||||
}
|
||||
}
|
||||
|
||||
CommandOutput outputOf(ProcessCommand command) {
|
||||
// Convert arguments from absolute to relative paths (relative to the dart
|
||||
// directory) because the absolute path on the machine where we record
|
||||
// may be different from the absolute path on the machine where we execute
|
||||
// the commands.
|
||||
var arguments = makePathsRelativeToDart(_cwd, command.arguments);
|
||||
|
||||
var key = _indexKey(command.executable, arguments.join(' '));
|
||||
var command_output = _commandOutputRecordings[key];
|
||||
if (command_output == null) {
|
||||
print("Sorry, but there is no command output for ${command.displayName}"
|
||||
" ($command)");
|
||||
exit(42);
|
||||
}
|
||||
|
||||
double seconds = command_output['duration'] as double;
|
||||
var duration = new Duration(
|
||||
seconds: seconds.round(), milliseconds: (seconds / 1000).round());
|
||||
var commandOutput = createCommandOutput(
|
||||
command,
|
||||
command_output['exit_code'] as int,
|
||||
command_output['did_timeout'] as bool,
|
||||
UTF8.encode(command_output['stdout'] as String),
|
||||
UTF8.encode(command_output['stderr'] as String),
|
||||
duration,
|
||||
false);
|
||||
return commandOutput;
|
||||
}
|
||||
|
||||
String _indexKey(String executable, String arguments) {
|
||||
return "${executable}__$arguments";
|
||||
}
|
||||
}
|
|
@ -68,17 +68,9 @@ Future testConfigurations(List<Configuration> configurations) async {
|
|||
var listTests = firstConf.listTests;
|
||||
|
||||
var reportInJson = firstConf.reportInJson;
|
||||
var recordingPath = firstConf.recordingPath;
|
||||
var replayPath = firstConf.replayPath;
|
||||
|
||||
Browser.resetBrowserConfiguration = firstConf.resetBrowser;
|
||||
|
||||
if (recordingPath != null && replayPath != null) {
|
||||
print("Fatal: Can't have the '--record_to_file' and '--replay_from_file'"
|
||||
"at the same time. Exiting ...");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!firstConf.appendLogs) {
|
||||
var files = [
|
||||
new File(TestUtils.flakyFileName),
|
||||
|
@ -271,16 +263,6 @@ Future testConfigurations(List<Configuration> configurations) async {
|
|||
|
||||
// [firstConf] is needed here, since the ProcessQueue needs to know the
|
||||
// settings of 'noBatch' and 'local_ip'
|
||||
new ProcessQueue(
|
||||
firstConf,
|
||||
maxProcesses,
|
||||
maxBrowserProcesses,
|
||||
startTime,
|
||||
testSuites,
|
||||
eventListener,
|
||||
allTestsFinished,
|
||||
verbose,
|
||||
recordingPath,
|
||||
replayPath,
|
||||
adbDevicePool);
|
||||
new ProcessQueue(firstConf, maxProcesses, maxBrowserProcesses, startTime,
|
||||
testSuites, eventListener, allTestsFinished, verbose, adbDevicePool);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import 'configuration.dart';
|
|||
import 'dependency_graph.dart' as dgraph;
|
||||
import 'expectation.dart';
|
||||
import 'path.dart';
|
||||
import 'record_and_replay.dart';
|
||||
import 'runtime_configuration.dart';
|
||||
import 'test_progress.dart';
|
||||
import 'test_suite.dart';
|
||||
|
@ -2892,50 +2891,6 @@ class CommandExecutorImpl implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
class RecordingCommandExecutor implements CommandExecutor {
|
||||
TestCaseRecorder _recorder;
|
||||
|
||||
RecordingCommandExecutor(Path path) : _recorder = new TestCaseRecorder(path);
|
||||
|
||||
Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) {
|
||||
assert(node.dependencies.length == 0);
|
||||
assert(_cleanEnvironmentOverrides(command.environmentOverrides));
|
||||
_recorder.nextCommand(command, timeout);
|
||||
// Return dummy CommandOutput
|
||||
var output =
|
||||
createCommandOutput(command, 0, false, [], [], const Duration(), false);
|
||||
return new Future.value(output);
|
||||
}
|
||||
|
||||
Future cleanup() {
|
||||
_recorder.finish();
|
||||
return new Future.value();
|
||||
}
|
||||
|
||||
// Returns [:true:] if the environment contains only 'DART_CONFIGURATION'
|
||||
bool _cleanEnvironmentOverrides(Map environment) {
|
||||
if (environment == null) return true;
|
||||
return environment.length == 0 ||
|
||||
(environment.length == 1 &&
|
||||
environment.containsKey("DART_CONFIGURATION"));
|
||||
}
|
||||
}
|
||||
|
||||
class ReplayingCommandExecutor implements CommandExecutor {
|
||||
TestCaseOutputArchive _archive = new TestCaseOutputArchive();
|
||||
|
||||
ReplayingCommandExecutor(Path path) {
|
||||
_archive.loadFromPath(path);
|
||||
}
|
||||
|
||||
Future cleanup() => new Future.value();
|
||||
|
||||
Future<CommandOutput> runCommand(node, ProcessCommand command, int timeout) {
|
||||
assert(node.dependencies.length == 0);
|
||||
return new Future.value(_archive.outputOf(command));
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldRetryCommand(CommandOutput output) {
|
||||
if (!output.successful) {
|
||||
List<String> stdout, stderr;
|
||||
|
@ -3116,8 +3071,6 @@ class ProcessQueue {
|
|||
this._eventListener,
|
||||
this._allDone,
|
||||
[bool verbose = false,
|
||||
String recordingOutputFile,
|
||||
String recordedInputFile,
|
||||
AdbDevicePool adbDevicePool]) {
|
||||
void setupForListing(TestCaseEnqueuer testCaseEnqueuer) {
|
||||
_graph.events
|
||||
|
@ -3198,9 +3151,6 @@ class ProcessQueue {
|
|||
});
|
||||
}
|
||||
|
||||
bool recording = recordingOutputFile != null;
|
||||
bool replaying = recordedInputFile != null;
|
||||
|
||||
// When the graph building is finished, notify event listeners.
|
||||
_graph.events
|
||||
.where((event) => event is dgraph.GraphSealedEvent)
|
||||
|
@ -3212,16 +3162,9 @@ class ProcessQueue {
|
|||
new CommandEnqueuer(_graph);
|
||||
|
||||
// CommandExecutor will execute commands
|
||||
CommandExecutor executor;
|
||||
if (recording) {
|
||||
executor = new RecordingCommandExecutor(new Path(recordingOutputFile));
|
||||
} else if (replaying) {
|
||||
executor = new ReplayingCommandExecutor(new Path(recordedInputFile));
|
||||
} else {
|
||||
executor = new CommandExecutorImpl(
|
||||
_globalConfiguration, maxProcesses, maxBrowserProcesses,
|
||||
adbDevicePool: adbDevicePool);
|
||||
}
|
||||
var executor = new CommandExecutorImpl(
|
||||
_globalConfiguration, maxProcesses, maxBrowserProcesses,
|
||||
adbDevicePool: adbDevicePool);
|
||||
|
||||
// Run "runnable commands" using [executor] subject to
|
||||
// maxProcesses/maxBrowserProcesses constraint
|
||||
|
@ -3234,10 +3177,7 @@ class ProcessQueue {
|
|||
testCaseCompleter.finishedTestCases.listen((TestCase finishedTestCase) {
|
||||
resetDebugTimer();
|
||||
|
||||
// If we're recording, we don't report any TestCases to listeners.
|
||||
if (!recording) {
|
||||
eventFinishedTestCase(finishedTestCase);
|
||||
}
|
||||
eventFinishedTestCase(finishedTestCase);
|
||||
}, onDone: () {
|
||||
// Wait until the commandQueue/exectutor is done (it may need to stop
|
||||
// batch runners, browser controllers, ....)
|
||||
|
|
Loading…
Reference in a new issue