mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:17:07 +00:00
Migration: make sure new CLI detects when run with an old SDK
Change-Id: I7b279788e34d3d2e86df58ff4ef7c86b58e154e3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145644 Reviewed-by: Mike Fairhurst <mfairhurst@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
c33f4ad9fc
commit
ff53bd8d4a
2 changed files with 30 additions and 2 deletions
|
@ -218,8 +218,13 @@ class MigrationCli {
|
|||
preferredPort: options.previewPort,
|
||||
enablePreview: options.webPreview);
|
||||
fixCodeProcessor.registerCodeTask(nonNullableFix);
|
||||
await fixCodeProcessor.runFirstPhase();
|
||||
_checkForErrors();
|
||||
try {
|
||||
await fixCodeProcessor.runFirstPhase();
|
||||
_checkForErrors();
|
||||
} on StateError catch (e) {
|
||||
logger.stdout(e.toString());
|
||||
exitCode = 1;
|
||||
}
|
||||
if (exitCode != null) return;
|
||||
previewUrls = await fixCodeProcessor.runLaterPhases();
|
||||
});
|
||||
|
|
|
@ -159,6 +159,29 @@ int${migrated ? '?' : ''} f() => null;
|
|||
expect(MigrationCli(binaryName: 'nnbd_migration').logger, isNotNull);
|
||||
}
|
||||
|
||||
test_detect_old_sdk() async {
|
||||
var cli = _createCli();
|
||||
// Alter the mock SDK, changing the signature of Object.operator== to match
|
||||
// the signature that was present prior to NNBD. (This is what the
|
||||
// migration tool uses to detect an old SDK).
|
||||
var coreLib = resourceProvider.getFile(
|
||||
resourceProvider.convertPath('${mock_sdk.sdkRoot}/lib/core/core.dart'));
|
||||
var oldCoreLibText = coreLib.readAsStringSync();
|
||||
var newCoreLibText = oldCoreLibText.replaceAll(
|
||||
'external bool operator ==(Object other)',
|
||||
'external bool operator ==(dynamic other)');
|
||||
expect(newCoreLibText, isNot(oldCoreLibText));
|
||||
coreLib.writeAsStringSync(newCoreLibText);
|
||||
var projectDir = await createProjectDir(simpleProject());
|
||||
await cli.run([projectDir]);
|
||||
assertErrorExit(cli, withUsage: false);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(
|
||||
output,
|
||||
contains(
|
||||
'Bad state: Analysis seems to have an SDK without NNBD enabled'));
|
||||
}
|
||||
|
||||
test_flag_apply_changes_default() {
|
||||
expect(assertParseArgsSuccess([]).applyChanges, isFalse);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue