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

Unified Diff: tests/compiler/dart2js/cps_ir/runner.dart

Issue 1709203002: Improve how we report unittest failures by stripping out the commented input code (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/cps_ir/runner.dart
diff --git a/tests/compiler/dart2js/cps_ir/runner.dart b/tests/compiler/dart2js/cps_ir/runner.dart
index af77384d79236b8d192db76ec492ad419a9f0098..9f764825ddcd3fa14685b3d384614216c307e7b6 100644
--- a/tests/compiler/dart2js/cps_ir/runner.dart
+++ b/tests/compiler/dart2js/cps_ir/runner.dart
@@ -28,8 +28,13 @@ runTest(String filename, {bool update: false}) {
.readAsStringSync();
var expectedFile =
new File.fromUri(Platform.script.resolve('expected/$outputname'));
- String expected = expectedFile.existsSync()
- ? expectedFile.readAsStringSync() : '';
+ String expected = '';
+ if (expectedFile.existsSync()) {
+ expected = expectedFile.readAsStringSync()
+ .replaceAll(new RegExp('^//.*\n', multiLine: true), '')
+ .trim();
+ }
+
var match = elementNameRegExp.firstMatch(source);
var elementName = match?.group(1);
@@ -58,14 +63,9 @@ runTest(String filename, {bool update: false}) {
Expect.isTrue(result.isSuccess);
CompilerImpl compiler = result.compiler;
if (expected != null) {
- String output = elementName == null
+ found = elementName == null
? _getCodeForMain(compiler)
: _getCodeForMethod(compiler, elementName);
- // Include the input in a comment of the expected file to make it easier
- // to see the relation between input and output in code reviews.
- found = '// Expectation for test: \n'
- '// ${source.trim().replaceAll('\n', '\n// ')}\n\n'
- '$output\n';
}
} catch (e, st) {
print(e);
@@ -81,12 +81,16 @@ runTest(String filename, {bool update: false}) {
}
if (expected != found) {
if (update) {
- expectedFile.writeAsStringSync(found);
+ // Include the input in a comment of the expected file to make it easier
+ // to see the relation between input and output in code reviews.
+ String comment = source.trim().replaceAll('\n', '\n// ');
+ expectedFile.writeAsStringSync('// Expectation for test: \n'
+ '// ${comment}\n\n${found}\n');
print('INFO: $expectedFile was updated');
} else {
Expect.fail('Unexpected output for test:\n '
'${_formatTest(files).replaceAll('\n', '\n ')}\n'
- 'Expected:\n ${expected.replaceAll('\n', '\n ')}\n'
+ 'Expected:\n ${expected.replaceAll('\n', '\n ')}\n\n'
'but found:\n ${found?.replaceAll('\n', '\n ')}\n'
'$regenerateCommand');
}
« 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