mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
[cfe] Add repro/regeneration command to macro test
This prints the commands needed to reproduce or generate expectations for the macro application test. Change-Id: Idf62ec8d8bdc846d2b043328b447f51839984c48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370883 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
e7d3b7820a
commit
2820e96b3c
|
@ -61,8 +61,8 @@ class CfeTestConfig extends TestConfig {
|
|||
|
||||
/// Called after running test on [testData] with the resulting
|
||||
/// [testResultData].
|
||||
void onCompilationResult(
|
||||
TestData testData, CfeTestResultData testResultData) {}
|
||||
void onCompilationResult(MarkerOptions markerOptions, TestData testData,
|
||||
CfeTestResultData testResultData) {}
|
||||
}
|
||||
|
||||
abstract class CfeDataComputer<T> extends DataComputer<T, CfeTestConfig,
|
||||
|
@ -229,7 +229,7 @@ Future<TestResult<T>> runTestForConfig<T>(MarkerOptions markerOptions,
|
|||
|
||||
CfeTestResultData testResultData =
|
||||
new CfeTestResultData(config, customData, compilerResult);
|
||||
config.onCompilationResult(testData, testResultData);
|
||||
config.onCompilationResult(markerOptions, testData, testResultData);
|
||||
return processCompiledResult(
|
||||
markerOptions, testData, dataComputer, testResultData, errors,
|
||||
fatalErrors: fatalErrors,
|
||||
|
|
|
@ -71,7 +71,7 @@ class MacroTestConfig extends CfeTestConfig {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<void> onCompilationResult(
|
||||
Future<void> onCompilationResult(MarkerOptions markerOptions,
|
||||
TestData testData, CfeTestResultData testResultData) async {
|
||||
Component component = testResultData.compilerResult.component!;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
@ -95,19 +95,28 @@ class MacroTestConfig extends CfeTestConfig {
|
|||
file.writeAsStringSync(actual);
|
||||
} else {
|
||||
String diff = await runDiff(expectedUri, actual);
|
||||
throw "${testData.name} don't match ${expectedUri}\n$diff";
|
||||
print("ERROR: ${testData.name} don't match ${expectedUri}\n$diff");
|
||||
onFailure(generateErrorMessage(markerOptions, mismatches: {
|
||||
testData.name: {testResultData.config.marker}
|
||||
}));
|
||||
}
|
||||
}
|
||||
} else if (generateExpectations) {
|
||||
file.writeAsStringSync(actual);
|
||||
} else {
|
||||
throw 'Please use -g option to create file ${expectedUri} with this '
|
||||
'content:\n$actual';
|
||||
print('Please use -g option to create file ${expectedUri} with this '
|
||||
'content:\n$actual');
|
||||
onFailure(generateErrorMessage(markerOptions, errors: {
|
||||
testData.name: {testResultData.config.marker}
|
||||
}));
|
||||
}
|
||||
if (offsetErrors.isNotEmpty) {
|
||||
offsetErrors.forEach(print);
|
||||
offsetErrors.clear();
|
||||
throw "${testData.name} has macro offset errors.";
|
||||
print("ERROR: ${testData.name} has macro offset errors.");
|
||||
onFailure(generateErrorMessage(markerOptions, errors: {
|
||||
testData.name: {testResultData.config.marker}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue