mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:26:38 +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
|
/// Called after running test on [testData] with the resulting
|
||||||
/// [testResultData].
|
/// [testResultData].
|
||||||
void onCompilationResult(
|
void onCompilationResult(MarkerOptions markerOptions, TestData testData,
|
||||||
TestData testData, CfeTestResultData testResultData) {}
|
CfeTestResultData testResultData) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class CfeDataComputer<T> extends DataComputer<T, CfeTestConfig,
|
abstract class CfeDataComputer<T> extends DataComputer<T, CfeTestConfig,
|
||||||
|
@ -229,7 +229,7 @@ Future<TestResult<T>> runTestForConfig<T>(MarkerOptions markerOptions,
|
||||||
|
|
||||||
CfeTestResultData testResultData =
|
CfeTestResultData testResultData =
|
||||||
new CfeTestResultData(config, customData, compilerResult);
|
new CfeTestResultData(config, customData, compilerResult);
|
||||||
config.onCompilationResult(testData, testResultData);
|
config.onCompilationResult(markerOptions, testData, testResultData);
|
||||||
return processCompiledResult(
|
return processCompiledResult(
|
||||||
markerOptions, testData, dataComputer, testResultData, errors,
|
markerOptions, testData, dataComputer, testResultData, errors,
|
||||||
fatalErrors: fatalErrors,
|
fatalErrors: fatalErrors,
|
||||||
|
|
|
@ -71,7 +71,7 @@ class MacroTestConfig extends CfeTestConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onCompilationResult(
|
Future<void> onCompilationResult(MarkerOptions markerOptions,
|
||||||
TestData testData, CfeTestResultData testResultData) async {
|
TestData testData, CfeTestResultData testResultData) async {
|
||||||
Component component = testResultData.compilerResult.component!;
|
Component component = testResultData.compilerResult.component!;
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
@ -95,19 +95,28 @@ class MacroTestConfig extends CfeTestConfig {
|
||||||
file.writeAsStringSync(actual);
|
file.writeAsStringSync(actual);
|
||||||
} else {
|
} else {
|
||||||
String diff = await runDiff(expectedUri, actual);
|
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) {
|
} else if (generateExpectations) {
|
||||||
file.writeAsStringSync(actual);
|
file.writeAsStringSync(actual);
|
||||||
} else {
|
} else {
|
||||||
throw 'Please use -g option to create file ${expectedUri} with this '
|
print('Please use -g option to create file ${expectedUri} with this '
|
||||||
'content:\n$actual';
|
'content:\n$actual');
|
||||||
|
onFailure(generateErrorMessage(markerOptions, errors: {
|
||||||
|
testData.name: {testResultData.config.marker}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
if (offsetErrors.isNotEmpty) {
|
if (offsetErrors.isNotEmpty) {
|
||||||
offsetErrors.forEach(print);
|
offsetErrors.forEach(print);
|
||||||
offsetErrors.clear();
|
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