diff --git a/pkg/analyzer/test/util/id_testing_helper.dart b/pkg/analyzer/test/util/id_testing_helper.dart index 460d1813651f..4c9190a2ace2 100644 --- a/pkg/analyzer/test/util/id_testing_helper.dart +++ b/pkg/analyzer/test/util/id_testing_helper.dart @@ -52,7 +52,8 @@ Future checkTests( Map> expectedMaps = { marker: new MemberAnnotations(), }; - computeExpectedMap(testFileUri, code, expectedMaps, onFailure: onFailure); + computeExpectedMap(testFileUri, testFileName, code, expectedMaps, + onFailure: onFailure); Map codeMap = {testFileUri: code}; var libFileNames = []; var testData = TestData(testFileUri, testFileUri, memorySourceFiles, codeMap, @@ -92,7 +93,7 @@ Future runTest(TestData testData, DataComputer dataComputer, RunTestFunction runTestFor( DataComputer dataComputer, List testedConfigs) { return (TestData testData, - {bool testAfterFailures, bool verbose, bool printCode}) { + {bool testAfterFailures, bool verbose, bool succinct, bool printCode}) { return runTest(testData, dataComputer, testedConfigs, testAfterFailures: testAfterFailures, onFailure: onFailure); }; @@ -199,7 +200,8 @@ class AnalyzerCompiledData extends CompiledData { } @override - void reportError(Uri uri, int offset, String message) { + void reportError(Uri uri, int offset, String message, + {bool succinct: false}) { print('$offset: $message'); } } diff --git a/pkg/front_end/lib/src/testing/id_testing.dart b/pkg/front_end/lib/src/testing/id_testing.dart index 580169ccce28..9a32dcc65893 100644 --- a/pkg/front_end/lib/src/testing/id_testing.dart +++ b/pkg/front_end/lib/src/testing/id_testing.dart @@ -150,7 +150,7 @@ class MemberAnnotations { /// corresponding test configuration. Otherwise it is expected for all /// configurations. // TODO(johnniwinther): Support an empty marker set. -void computeExpectedMap(Uri sourceUri, AnnotatedCode code, +void computeExpectedMap(Uri sourceUri, String filename, AnnotatedCode code, Map> maps, {void onFailure(String message)}) { List mapKeys = maps.keys.toList(); @@ -165,13 +165,15 @@ void computeExpectedMap(Uri sourceUri, AnnotatedCode code, IdValue idValue = IdValue.decode(sourceUri, annotation.offset, text); if (idValue.id.isGlobal) { if (fileAnnotations.globalData.containsKey(idValue.id)) { - onFailure("Duplicate annotations for ${idValue.id} in $marker: " + onFailure("Error in test '$filename': " + "Duplicate annotations for ${idValue.id} in $marker: " "${idValue} and ${fileAnnotations.globalData[idValue.id]}."); } fileAnnotations.globalData[idValue.id] = idValue; } else { if (expectedValues.containsKey(idValue.id)) { - onFailure("Duplicate annotations for ${idValue.id} in $marker: " + onFailure("Error in test '$filename': " + "Duplicate annotations for ${idValue.id} in $marker: " "${idValue} and ${expectedValues[idValue.id]}."); } expectedValues[idValue.id] = idValue; @@ -198,7 +200,8 @@ TestData computeTestData(File testFile, Directory testLibDirectory, for (String testMarker in supportedMarkers) { expectedMaps[testMarker] = new MemberAnnotations(); } - computeExpectedMap(entryPoint, code[entryPoint], expectedMaps, + computeExpectedMap(entryPoint, testFile.uri.pathSegments.last, + code[entryPoint], expectedMaps, onFailure: onFailure); Map memorySourceFiles = { entryPoint.path: code[entryPoint].sourceCode @@ -219,7 +222,8 @@ TestData computeTestData(File testFile, Directory testLibDirectory, new AnnotatedCode.fromText(libCode, commentStart, commentEnd); memorySourceFiles[libFileUri.path] = annotatedLibCode.sourceCode; code[libFileUri] = annotatedLibCode; - computeExpectedMap(libFileUri, annotatedLibCode, expectedMaps, + computeExpectedMap( + libFileUri, libFileName, annotatedLibCode, expectedMaps, onFailure: onFailure); } } @@ -303,7 +307,7 @@ abstract class CompiledData { int getOffsetFromId(Id id, Uri uri); - void reportError(Uri uri, int offset, String message); + void reportError(Uri uri, int offset, String message, {bool succinct: false}); } /// Interface used for interpreting annotations. @@ -444,6 +448,7 @@ Future checkCode( DataInterpreter dataValidator, {bool filterActualData(IdValue expected, ActualData actualData), bool fatalErrors: true, + bool succinct: false, void onFailure(String message)}) async { IdData data = new IdData(code, expectedMaps, compiledData); bool hasFailure = false; @@ -463,10 +468,13 @@ Future checkCode( compiledData.reportError( actualData.uri, actualData.offset, - 'EXTRA $modeName DATA for ${id.descriptor}:\n ' - 'object : ${actualData.objectText}\n ' - 'actual : ${colorizeActual(actualValueText)}\n ' - 'Data was expected for these ids: ${expectedMap.keys}'); + succinct + ? 'EXTRA $modeName DATA for ${id.descriptor}' + : 'EXTRA $modeName DATA for ${id.descriptor}:\n ' + 'object : ${actualData.objectText}\n ' + 'actual : ${colorizeActual(actualValueText)}\n ' + 'Data was expected for these ids: ${expectedMap.keys}', + succinct: succinct); if (filterActualData == null || filterActualData(null, actualData)) { hasLocalFailure = true; } @@ -480,11 +488,14 @@ Future checkCode( compiledData.reportError( actualData.uri, actualData.offset, - 'UNEXPECTED $modeName DATA for ${id.descriptor}:\n ' - 'detail : ${colorizeMessage(unexpectedMessage)}\n ' - 'object : ${actualData.objectText}\n ' - 'expected: ${colorizeExpected('$expected')}\n ' - 'actual : ${colorizeActual(actualValueText)}'); + succinct + ? 'UNEXPECTED $modeName DATA for ${id.descriptor}' + : 'UNEXPECTED $modeName DATA for ${id.descriptor}:\n ' + 'detail : ${colorizeMessage(unexpectedMessage)}\n ' + 'object : ${actualData.objectText}\n ' + 'expected: ${colorizeExpected('$expected')}\n ' + 'actual : ${colorizeActual(actualValueText)}', + succinct: succinct); if (filterActualData == null || filterActualData(expected, actualData)) { hasLocalFailure = true; @@ -516,7 +527,8 @@ Future checkCode( 'Expected ${colorizeExpected('$expected')}'; if (uri != null) { compiledData.reportError( - uri, compiledData.getOffsetFromId(id, uri), message); + uri, compiledData.getOffsetFromId(id, uri), message, + succinct: succinct); } else { print(message); } @@ -531,10 +543,12 @@ Future checkCode( checkMissing(expectedMap, data.actualMaps[uri], uri); }); checkMissing(data.expectedMaps.globalData, data.actualMaps.globalData); - for (Uri uri in neededDiffs) { - print('--annotations diff [${uri.pathSegments.last}]-------------'); - print(data.diffCode(uri, dataValidator)); - print('----------------------------------------------------------'); + if (!succinct) { + for (Uri uri in neededDiffs) { + print('--annotations diff [${uri.pathSegments.last}]-------------'); + print(data.diffCode(uri, dataValidator)); + print('----------------------------------------------------------'); + } } if (missingIds.isNotEmpty) { print("MISSING ids: ${missingIds}."); @@ -547,7 +561,7 @@ Future checkCode( } typedef Future RunTestFunction(TestData testData, - {bool testAfterFailures, bool verbose, bool printCode}); + {bool testAfterFailures, bool verbose, bool succinct, bool printCode}); /// Check code for all test files int [data] using [computeFromAst] and /// [computeFromKernel] from the respective front ends. If [skipForKernel] @@ -572,6 +586,7 @@ Future runTests(Directory dataDir, // TODO(johnniwinther): Support --show to show actual data for an input. args = args.toList(); bool verbose = args.remove('-v'); + bool succinct = args.remove('-s'); bool shouldContinue = args.remove('-c'); bool testAfterFailures = args.remove('-a'); bool printCode = args.remove('-p'); @@ -613,6 +628,7 @@ Future runTests(Directory dataDir, if (await runTest(testData, testAfterFailures: testAfterFailures, verbose: verbose, + succinct: succinct, printCode: printCode)) { hasFailures = true; } diff --git a/pkg/front_end/lib/src/testing/id_testing_helper.dart b/pkg/front_end/lib/src/testing/id_testing_helper.dart index ca048c4c1814..97483e3289e0 100644 --- a/pkg/front_end/lib/src/testing/id_testing_helper.dart +++ b/pkg/front_end/lib/src/testing/id_testing_helper.dart @@ -137,9 +137,11 @@ class CfeCompiledData extends CompiledData { } @override - void reportError(Uri uri, int offset, String message) { + void reportError(Uri uri, int offset, String message, + {bool succinct: false}) { printMessageInLocation( - compilerResult.component.uriToSource, uri, offset, message); + compilerResult.component.uriToSource, uri, offset, message, + succinct: succinct); } } @@ -170,10 +172,11 @@ void onFailure(String message) => throw new StateError(message); RunTestFunction runTestFor( DataComputer dataComputer, List testedConfigs) { return (TestData testData, - {bool testAfterFailures, bool verbose, bool printCode}) { + {bool testAfterFailures, bool verbose, bool succinct, bool printCode}) { return runTest(testData, dataComputer, testedConfigs, testAfterFailures: testAfterFailures, verbose: verbose, + succinct: succinct, printCode: printCode, onFailure: onFailure); }; @@ -186,6 +189,7 @@ Future runTest(TestData testData, DataComputer dataComputer, List testedConfigs, {bool testAfterFailures, bool verbose, + bool succinct, bool printCode, bool forUserLibrariesOnly: true, Iterable globalIds: const [], @@ -196,6 +200,7 @@ Future runTest(TestData testData, DataComputer dataComputer, fatalErrors: !testAfterFailures, onFailure: onFailure, verbose: verbose, + succinct: succinct, printCode: printCode)) { hasFailures = true; } @@ -210,6 +215,7 @@ Future runTestForConfig( TestData testData, DataComputer dataComputer, TestConfig config, {bool fatalErrors, bool verbose, + bool succinct, bool printCode, bool forUserLibrariesOnly: true, Iterable globalIds: const [], @@ -223,7 +229,7 @@ Future runTestForConfig( if (message is FormattedMessage && message.severity == Severity.error) { errors.add(message); } - printDiagnosticMessage(message, print); + if (!succinct) printDiagnosticMessage(message, print); }; options.debugDump = printCode; options.experimentalFlags.addAll(config.experimentalFlags); @@ -376,11 +382,12 @@ Future runTestForConfig( return checkCode(config.name, testData.testFileUri, testData.code, memberAnnotations, compiledData, dataComputer.dataValidator, - fatalErrors: fatalErrors, onFailure: onFailure); + fatalErrors: fatalErrors, succinct: succinct, onFailure: onFailure); } void printMessageInLocation( - Map uriToSource, Uri uri, int offset, String message) { + Map uriToSource, Uri uri, int offset, String message, + {bool succinct: false}) { if (uri == null) { print(message); } else { @@ -391,8 +398,10 @@ void printMessageInLocation( if (offset != null) { Location location = source.getLocation(uri, offset); print('$location: $message'); - print(source.getTextLine(location.line)); - print(' ' * (location.column - 1) + '^'); + if (!succinct) { + print(source.getTextLine(location.line)); + print(' ' * (location.column - 1) + '^'); + } } else { print('$uri: $message'); } diff --git a/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart b/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart index d7dfc2277167..36512f280009 100644 --- a/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart +++ b/tests/compiler/dart2js/equivalence/id_equivalence_helper.dart @@ -347,7 +347,8 @@ class Dart2jsCompiledData extends CompiledData { } @override - void reportError(Uri uri, int offset, String message) { + void reportError(Uri uri, int offset, String message, + {bool succinct: false}) { compiler.reporter.reportErrorMessage( computeSourceSpanFromUriOffset(uri, offset), MessageKind.GENERIC, @@ -407,7 +408,10 @@ Future checkTests(Directory dataDir, DataComputer dataComputer, dataComputer.setup(); Future checkTest(TestData testData, - {bool testAfterFailures, bool verbose, bool printCode}) async { + {bool testAfterFailures, + bool verbose, + bool succinct, + bool printCode}) async { bool hasFailures = false; String name = testData.name; List testOptions = options.toList();