Chromium Code Reviews| Index: tools/testing/dart/record_and_replay.dart |
| diff --git a/tools/testing/dart/record_and_replay.dart b/tools/testing/dart/record_and_replay.dart |
| index c2ba7c979a16ebcb0b3f7b050cfd48e6136e59d4..63d8b12fab608ff7a4c05cc7c78a88c25d91e772 100644 |
| --- a/tools/testing/dart/record_and_replay.dart |
| +++ b/tools/testing/dart/record_and_replay.dart |
| @@ -16,7 +16,6 @@ import 'test_runner.dart'; |
| * [ |
| * { |
| * 'name' : '...', |
| - * 'configuration' : '...', |
| * 'command' : { |
| * 'timeout_limit' : 60, |
| * 'executable' : '...', |
| @@ -44,10 +43,7 @@ class TestCaseRecorder { |
| _cwd = Directory.current.path; |
| } |
| - void nextTestCase(TestCase testCase) { |
| - assert(testCase.commands.length == 1); |
| - |
| - var command = testCase.commands[0]; |
| + void nextCommand(Command command, int timeout) { |
| assert(command.environment == null); |
| var arguments = []; |
| @@ -61,10 +57,9 @@ class TestCaseRecorder { |
| } |
| var commandExecution = { |
| - 'name' : testCase.displayName, |
| - 'configuration' : testCase.configurationString, |
| + 'name' : command.displayName, |
| 'command' : { |
| - 'timeout_limit' : testCase.timeout, |
| + 'timeout_limit' : timeout, |
| 'executable' : command.executable, |
| 'arguments' : arguments, |
| }, |
| @@ -81,36 +76,49 @@ class TestCaseRecorder { |
| } |
| class TestCaseOutputArchive { |
| - Map<String, Map> _testCaseOutputRecords; |
| + Map<String, Map> _commandOutputRecordings; |
| + var _cwd; |
| + |
| + TestCaseOutputArchive() { |
| + _cwd = Directory.current.path; |
| + } |
| void loadFromPath(Path recordingPath) { |
| var file = new File.fromPath(recordingPath); |
| - var testCases = json.parse(file.readAsStringSync()); |
| - _testCaseOutputRecords = {}; |
| - for (var testCase in testCases) { |
| - var key = _indexKey(testCase['configuration'], testCase['name']); |
| - _testCaseOutputRecords[key] = testCase['command_output']; |
| + var commandRecordings = json.parse(file.readAsStringSync()); |
| + _commandOutputRecordings = {}; |
| + for (var commandRecording in commandRecordings) { |
| + var key = _indexKey(commandRecording['command']['executable'], |
| + commandRecording['command']['arguments'].join(' ')); |
| + _commandOutputRecordings[key] = commandRecording['command_output']; |
| } |
| } |
| - CommandOutput outputOf(TestCase testCase) { |
| - var key = _indexKey(testCase.configurationString, testCase.displayName); |
| - var command_output = _testCaseOutputRecords[key]; |
| - if (command_output == null) { |
| - print("Sorry, but there is no command output for " |
| - "${testCase.displayName}"); |
| + CommandOutput outputOf(Command command) { |
| + var arguments = []; |
| + for (var rawArgument in command.arguments) { |
| + if (rawArgument.startsWith(_cwd)) { |
| + var relative = new Path(rawArgument).relativeTo(new Path(_cwd)); |
|
ricow1
2013/07/30 09:30:11
I like it :-), but please add a comment stating wh
kustermann
2013/07/31 15:53:54
Done.
|
| + arguments.add(relative.toNativePath()); |
| + } else { |
| + arguments.add(rawArgument); |
| + } |
| + } |
| + 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']; |
| var duration = new Duration(seconds: seconds.round(), |
| milliseconds: (seconds/1000).round()); |
| - var commandOutput = new CommandOutput.fromCase( |
| - testCase, |
| - testCase.commands.first, |
| + var commandOutput = createCommandOutput( |
| + command, |
| command_output['exit_code'], |
| - false, |
| command_output['did_timeout'], |
| encodeUtf8(command_output['stdout']), |
| encodeUtf8(command_output['stderr']), |
| @@ -119,8 +127,8 @@ class TestCaseOutputArchive { |
| return commandOutput; |
| } |
| - String _indexKey(String configuration, String name) { |
| - return "${configuration}__$name"; |
| + String _indexKey(String executable, String arguments) { |
| + return "${executable}__$arguments"; |
| } |
| } |