@@ -150,7 +150,7 @@ class MemberAnnotations<DataType> {
150
150
/// corresponding test configuration. Otherwise it is expected for all
151
151
/// configurations.
152
152
// TODO(johnniwinther): Support an empty marker set.
153
- void computeExpectedMap (Uri sourceUri, AnnotatedCode code,
153
+ void computeExpectedMap (Uri sourceUri, String filename, AnnotatedCode code,
154
154
Map <String , MemberAnnotations <IdValue >> maps,
155
155
{void onFailure (String message)}) {
156
156
List <String > mapKeys = maps.keys.toList ();
@@ -165,13 +165,15 @@ void computeExpectedMap(Uri sourceUri, AnnotatedCode code,
165
165
IdValue idValue = IdValue .decode (sourceUri, annotation.offset, text);
166
166
if (idValue.id.isGlobal) {
167
167
if (fileAnnotations.globalData.containsKey (idValue.id)) {
168
- onFailure ("Duplicate annotations for ${idValue .id } in $marker : "
168
+ onFailure ("Error in test '$filename ': "
169
+ "Duplicate annotations for ${idValue .id } in $marker : "
169
170
"${idValue } and ${fileAnnotations .globalData [idValue .id ]}." );
170
171
}
171
172
fileAnnotations.globalData[idValue.id] = idValue;
172
173
} else {
173
174
if (expectedValues.containsKey (idValue.id)) {
174
- onFailure ("Duplicate annotations for ${idValue .id } in $marker : "
175
+ onFailure ("Error in test '$filename ': "
176
+ "Duplicate annotations for ${idValue .id } in $marker : "
175
177
"${idValue } and ${expectedValues [idValue .id ]}." );
176
178
}
177
179
expectedValues[idValue.id] = idValue;
@@ -198,7 +200,8 @@ TestData computeTestData(File testFile, Directory testLibDirectory,
198
200
for (String testMarker in supportedMarkers) {
199
201
expectedMaps[testMarker] = new MemberAnnotations <IdValue >();
200
202
}
201
- computeExpectedMap (entryPoint, code[entryPoint], expectedMaps,
203
+ computeExpectedMap (entryPoint, testFile.uri.pathSegments.last,
204
+ code[entryPoint], expectedMaps,
202
205
onFailure: onFailure);
203
206
Map <String , String > memorySourceFiles = {
204
207
entryPoint.path: code[entryPoint].sourceCode
@@ -219,7 +222,8 @@ TestData computeTestData(File testFile, Directory testLibDirectory,
219
222
new AnnotatedCode .fromText (libCode, commentStart, commentEnd);
220
223
memorySourceFiles[libFileUri.path] = annotatedLibCode.sourceCode;
221
224
code[libFileUri] = annotatedLibCode;
222
- computeExpectedMap (libFileUri, annotatedLibCode, expectedMaps,
225
+ computeExpectedMap (
226
+ libFileUri, libFileName, annotatedLibCode, expectedMaps,
223
227
onFailure: onFailure);
224
228
}
225
229
}
@@ -303,7 +307,7 @@ abstract class CompiledData<T> {
303
307
304
308
int getOffsetFromId (Id id, Uri uri);
305
309
306
- void reportError (Uri uri, int offset, String message);
310
+ void reportError (Uri uri, int offset, String message, { bool succinct : false } );
307
311
}
308
312
309
313
/// Interface used for interpreting annotations.
@@ -444,6 +448,7 @@ Future<bool> checkCode<T>(
444
448
DataInterpreter <T > dataValidator,
445
449
{bool filterActualData (IdValue expected, ActualData <T > actualData),
446
450
bool fatalErrors: true ,
451
+ bool succinct: false ,
447
452
void onFailure (String message)}) async {
448
453
IdData <T > data = new IdData <T >(code, expectedMaps, compiledData);
449
454
bool hasFailure = false ;
@@ -463,10 +468,13 @@ Future<bool> checkCode<T>(
463
468
compiledData.reportError (
464
469
actualData.uri,
465
470
actualData.offset,
466
- 'EXTRA $modeName DATA for ${id .descriptor }:\n '
467
- 'object : ${actualData .objectText }\n '
468
- 'actual : ${colorizeActual (actualValueText )}\n '
469
- 'Data was expected for these ids: ${expectedMap .keys }' );
471
+ succinct
472
+ ? 'EXTRA $modeName DATA for ${id .descriptor }'
473
+ : 'EXTRA $modeName DATA for ${id .descriptor }:\n '
474
+ 'object : ${actualData .objectText }\n '
475
+ 'actual : ${colorizeActual (actualValueText )}\n '
476
+ 'Data was expected for these ids: ${expectedMap .keys }' ,
477
+ succinct: succinct);
470
478
if (filterActualData == null || filterActualData (null , actualData)) {
471
479
hasLocalFailure = true ;
472
480
}
@@ -480,11 +488,14 @@ Future<bool> checkCode<T>(
480
488
compiledData.reportError (
481
489
actualData.uri,
482
490
actualData.offset,
483
- 'UNEXPECTED $modeName DATA for ${id .descriptor }:\n '
484
- 'detail : ${colorizeMessage (unexpectedMessage )}\n '
485
- 'object : ${actualData .objectText }\n '
486
- 'expected: ${colorizeExpected ('$expected ' )}\n '
487
- 'actual : ${colorizeActual (actualValueText )}' );
491
+ succinct
492
+ ? 'UNEXPECTED $modeName DATA for ${id .descriptor }'
493
+ : 'UNEXPECTED $modeName DATA for ${id .descriptor }:\n '
494
+ 'detail : ${colorizeMessage (unexpectedMessage )}\n '
495
+ 'object : ${actualData .objectText }\n '
496
+ 'expected: ${colorizeExpected ('$expected ' )}\n '
497
+ 'actual : ${colorizeActual (actualValueText )}' ,
498
+ succinct: succinct);
488
499
if (filterActualData == null ||
489
500
filterActualData (expected, actualData)) {
490
501
hasLocalFailure = true ;
@@ -516,7 +527,8 @@ Future<bool> checkCode<T>(
516
527
'Expected ${colorizeExpected ('$expected ' )}' ;
517
528
if (uri != null ) {
518
529
compiledData.reportError (
519
- uri, compiledData.getOffsetFromId (id, uri), message);
530
+ uri, compiledData.getOffsetFromId (id, uri), message,
531
+ succinct: succinct);
520
532
} else {
521
533
print (message);
522
534
}
@@ -531,10 +543,12 @@ Future<bool> checkCode<T>(
531
543
checkMissing (expectedMap, data.actualMaps[uri], uri);
532
544
});
533
545
checkMissing (data.expectedMaps.globalData, data.actualMaps.globalData);
534
- for (Uri uri in neededDiffs) {
535
- print ('--annotations diff [${uri .pathSegments .last }]-------------' );
536
- print (data.diffCode (uri, dataValidator));
537
- print ('----------------------------------------------------------' );
546
+ if (! succinct) {
547
+ for (Uri uri in neededDiffs) {
548
+ print ('--annotations diff [${uri .pathSegments .last }]-------------' );
549
+ print (data.diffCode (uri, dataValidator));
550
+ print ('----------------------------------------------------------' );
551
+ }
538
552
}
539
553
if (missingIds.isNotEmpty) {
540
554
print ("MISSING ids: ${missingIds }." );
@@ -547,7 +561,7 @@ Future<bool> checkCode<T>(
547
561
}
548
562
549
563
typedef Future <bool > RunTestFunction (TestData testData,
550
- {bool testAfterFailures, bool verbose, bool printCode});
564
+ {bool testAfterFailures, bool verbose, bool succinct, bool printCode});
551
565
552
566
/// Check code for all test files int [data] using [computeFromAst] and
553
567
/// [computeFromKernel] from the respective front ends. If [skipForKernel]
@@ -572,6 +586,7 @@ Future runTests(Directory dataDir,
572
586
// TODO(johnniwinther): Support --show to show actual data for an input.
573
587
args = args.toList ();
574
588
bool verbose = args.remove ('-v' );
589
+ bool succinct = args.remove ('-s' );
575
590
bool shouldContinue = args.remove ('-c' );
576
591
bool testAfterFailures = args.remove ('-a' );
577
592
bool printCode = args.remove ('-p' );
@@ -613,6 +628,7 @@ Future runTests(Directory dataDir,
613
628
if (await runTest (testData,
614
629
testAfterFailures: testAfterFailures,
615
630
verbose: verbose,
631
+ succinct: succinct,
616
632
printCode: printCode)) {
617
633
hasFailures = true ;
618
634
}
0 commit comments