cab69e7706
NOTE: This is a trial submit and will be reverted immediately. - Flips the flag from --nnbd to --no-nnbd so that by default it builds the NNBD version - using the --no-nnbd flag results in the SDK being built in a directory which has the 'Legacy' suffix added to it (e.g: out/DebugX64Legacy) - the '--enable-experiment=non-nullable' flag still needs to be passed in during execution so that CFE runs in that mode. This is different from the 'null_safety' flag Change-Id: I7d25d9710818af5919c0bb83abe51153172f5886 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144880 Reviewed-by: Siva Annamalai <asiva@google.com>
89 lines
2.9 KiB
Dart
89 lines
2.9 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// A set of integration tests for `dart migrate`.
|
|
import 'package:test/test.dart';
|
|
|
|
import '../utils.dart';
|
|
|
|
void main() {
|
|
group('migrate', defineMigrateTests, timeout: longTimeout);
|
|
}
|
|
|
|
bool _nnbdIsEnabled = true;
|
|
|
|
void defineMigrateTests() {
|
|
final didYouForgetToRunPubGet = contains('Did you forget to run "pub get"?');
|
|
|
|
TestProject p;
|
|
|
|
tearDown(() => p?.dispose());
|
|
|
|
test('--help', () {
|
|
p = project();
|
|
var result = p.runSync('migrate', ['--help']);
|
|
|
|
expect(result.exitCode, 0);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout,
|
|
contains('Perform a null safety migration on a project or package.'));
|
|
expect(result.stdout,
|
|
contains('Usage: dart migrate [arguments] [project or directory]'));
|
|
});
|
|
|
|
test('directory implicit', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
var result = p.runSync(
|
|
'migrate',
|
|
[
|
|
'--no-web-preview',
|
|
'--server-path=${p.absolutePathToAnalysisServerFile}'
|
|
],
|
|
workingDir: p.dirPath);
|
|
expect(result.exitCode, _nnbdIsEnabled ? 0 : 2);
|
|
expect(result.stderr, _nnbdIsEnabled ? isEmpty : isNotEmpty);
|
|
expect(result.stdout, contains('Generating migration suggestions'));
|
|
});
|
|
|
|
test('directory explicit', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
var result = p.runSync('migrate', [
|
|
'--no-web-preview',
|
|
'--server-path=${p.absolutePathToAnalysisServerFile}',
|
|
p.dirPath
|
|
]);
|
|
expect(result.exitCode, _nnbdIsEnabled ? 0 : 2);
|
|
expect(result.stderr, _nnbdIsEnabled ? isEmpty : isNotEmpty);
|
|
expect(result.stdout, contains('Generating migration suggestions'));
|
|
});
|
|
|
|
test('bad directory', () {
|
|
p = project(mainSrc: 'int get foo => 1;\n');
|
|
var result = p.runSync('migrate',
|
|
['--server-path=${p.absolutePathToAnalysisServerFile}', 'foo_bar_dir']);
|
|
expect(result.exitCode, 64);
|
|
expect(result.stderr,
|
|
contains('not found; please provide a path to a package or directory'));
|
|
expect(result.stdout, isEmpty);
|
|
});
|
|
|
|
test('pub get needs running', () {
|
|
p = project(mainSrc: 'import "package:foo/foo.dart";\n');
|
|
var result = p.runSync('migrate',
|
|
['--server-path=${p.absolutePathToAnalysisServerFile}', p.dirPath]);
|
|
expect(result.exitCode, 1);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, didYouForgetToRunPubGet);
|
|
});
|
|
|
|
test('non-pub-related error', () {
|
|
p = project(mainSrc: 'var missing = "semicolon"\n');
|
|
var result = p.runSync('migrate',
|
|
['--server-path=${p.absolutePathToAnalysisServerFile}', p.dirPath]);
|
|
expect(result.exitCode, 1);
|
|
expect(result.stderr, isEmpty);
|
|
expect(result.stdout, isNot(didYouForgetToRunPubGet));
|
|
});
|
|
}
|