mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Add a test case for #44394
This issue (Migration tool null safety detection fails when tests use path imports) was reported in December of 2020 and I can't reproduce it. I believe there have been changes in analyzer package resolution since then, aimed precisely at helping users who use this sort of improper path import. So it is likely that those changes fixed this bug. I'm adding a test case to ensure that the bug isn't accidentally un-fixed by future changes. Bug: https://github.com/dart-lang/sdk/issues/44394 Change-Id: I81490e545aa41196c3c69bc4d74cd481079d59ba Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259200 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
6795c753fd
commit
22a405bf8a
1 changed files with 44 additions and 0 deletions
|
@ -779,6 +779,50 @@ int? f() => null
|
|||
});
|
||||
}
|
||||
|
||||
test_lifecycle_import_check_handle_improper_lib_import() async {
|
||||
Map<String, String?> computeProjectContents({required bool migrated}) => {
|
||||
'pubspec.yaml': '''
|
||||
name: test
|
||||
environment:
|
||||
sdk: '${migrated ? '>=2.12.0 <3.0.0' : '>=2.6.0 <3.0.0'}'
|
||||
''',
|
||||
'.dart_tool/package_config.json':
|
||||
_getPackageConfigText(migrated: migrated),
|
||||
'lib/foo.dart': '''
|
||||
int${migrated ? '?' : ''} f() => null;
|
||||
''',
|
||||
'test/foo_test.dart': '''
|
||||
import '../lib/foo.dart';
|
||||
int${migrated ? '?' : ''} g() => f();
|
||||
''',
|
||||
};
|
||||
var projectContents = computeProjectContents(migrated: false);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
bool applyHookCalled = false;
|
||||
cli._onApplyHook = () {
|
||||
expect(applyHookCalled, false);
|
||||
applyHookCalled = true;
|
||||
// Changes should have been made
|
||||
assertProjectContents(projectDir, computeProjectContents(migrated: true));
|
||||
};
|
||||
await runWithPreviewServer(cli, ['--skip-import-check', projectDir],
|
||||
(url) async {
|
||||
expect(
|
||||
logger.stdoutBuffer.toString(), contains('No analysis issues found'));
|
||||
await assertPreviewServerResponsive(url!);
|
||||
await _tellPreviewToApplyChanges(url);
|
||||
expect(applyHookCalled, true);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(output,
|
||||
isNot(contains('Warning: package has unmigrated dependencies')));
|
||||
// Output should not mention that the user can rerun without
|
||||
// `--skip-import-check`.
|
||||
expect(output,
|
||||
isNot(contains('`--${CommandLineOptions.skipImportCheckFlag}`')));
|
||||
});
|
||||
}
|
||||
|
||||
test_lifecycle_import_check_via_export() async {
|
||||
// If the user's code exports a library that imports a non-migrated library,
|
||||
// that's a problem too.
|
||||
|
|
Loading…
Reference in a new issue