9d132ebba9
New commits: git log --format="%C(auto) %h %s" 900e796a37fd9f68de9dd183cf4798fe5f055eaa..4ca4767a6c00b2dadecdaee9a4866dae40ef25f2 4ca4767a Added a dart pub outdated --transitive option (#2731) 6b145bd6 Deprecate --server argument to `pub publish` and `pub uploader`. (#2697) 7737023a don't warn if previous prerelease was null safe (#2730) 62f92838 Improve outdated --mode=null-safety (#2724) cc589ec3 Change message for no Latest resolution (#2729) 656803e9 Require sdk constraint (#2718) 8309d877 Added test that dev_dependency does not trigger null-safety warnings when publishing (#2727) 332ea049 Remove warning about mixed mode. (#2723) a98a1f23 Simplify null-safety analysis in `pub outdated --mode=null-safety` (#2721) 5fba2015 Outdated null safety implies prereleases (#2722) fb9ec4af Fixed bug in yaml_edit (#2703) Change-Id: I22a084aee06542e04a272269fb0134f0ac62f779 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170690 Commit-Queue: Sigurd Meldgaard <sigurdm@google.com> Reviewed-by: Michael Thomsen <mit@google.com> Reviewed-by: Jonas Jensen <jonasfj@google.com>
118 lines
3.2 KiB
Dart
118 lines
3.2 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.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:path/path.dart' as path;
|
|
import 'package:test/test.dart';
|
|
|
|
/// A long [Timeout] is provided for tests that start a process on
|
|
/// `bin/dartdev.dart` as the command is not compiled ahead of time, and each
|
|
/// invocation requires the VM to compile the entire dependency graph.
|
|
const Timeout longTimeout = Timeout(Duration(minutes: 5));
|
|
|
|
/// This version of dart is the last guaranteed pre-null safety language
|
|
/// version:
|
|
const String dartVersionFilePrefix2_9 = '// @dart = 2.9\n';
|
|
|
|
TestProject project(
|
|
{String mainSrc, String analysisOptions, bool logAnalytics = false}) =>
|
|
TestProject(
|
|
mainSrc: mainSrc,
|
|
analysisOptions: analysisOptions,
|
|
logAnalytics: logAnalytics);
|
|
|
|
class TestProject {
|
|
static String get defaultProjectName => 'dartdev_temp';
|
|
|
|
Directory dir;
|
|
|
|
String get dirPath => dir.path;
|
|
|
|
String get name => defaultProjectName;
|
|
|
|
String get relativeFilePath => 'lib/main.dart';
|
|
|
|
final bool logAnalytics;
|
|
|
|
TestProject({
|
|
String mainSrc,
|
|
String analysisOptions,
|
|
this.logAnalytics = false,
|
|
}) {
|
|
dir = Directory.systemTemp.createTempSync('dartdev');
|
|
file('pubspec.yaml', '''
|
|
name: $name
|
|
environment:
|
|
sdk: '>=2.10.0 <3.0.0'
|
|
|
|
dev_dependencies:
|
|
test: any
|
|
''');
|
|
if (analysisOptions != null) {
|
|
file('analysis_options.yaml', analysisOptions);
|
|
}
|
|
if (mainSrc != null) {
|
|
file(relativeFilePath, mainSrc);
|
|
}
|
|
}
|
|
|
|
void file(String name, String contents) {
|
|
var file = File(path.join(dir.path, name));
|
|
file.parent.createSync();
|
|
file.writeAsStringSync(contents);
|
|
}
|
|
|
|
void dispose() {
|
|
if (dir.existsSync()) {
|
|
dir.deleteSync(recursive: true);
|
|
}
|
|
}
|
|
|
|
ProcessResult runSync(
|
|
String command,
|
|
List<String> args, {
|
|
String workingDir,
|
|
}) {
|
|
var arguments = [
|
|
command,
|
|
...?args,
|
|
];
|
|
|
|
arguments.add('--disable-dartdev-analytics');
|
|
return Process.runSync(Platform.resolvedExecutable, arguments,
|
|
workingDirectory: workingDir ?? dir.path,
|
|
environment: {if (logAnalytics) '_DARTDEV_LOG_ANALYTICS': 'true'});
|
|
}
|
|
|
|
String _sdkRootPath;
|
|
|
|
/// Return the root of the SDK.
|
|
String get sdkRootPath {
|
|
if (_sdkRootPath == null) {
|
|
// Assumes the script importing this one is somewhere under the SDK.
|
|
String current = path.canonicalize(Platform.script.toFilePath());
|
|
do {
|
|
String tryDir = path.dirname(current);
|
|
if (File(path.join(tryDir, 'pkg', 'dartdev', 'bin', 'dartdev.dart'))
|
|
.existsSync()) {
|
|
_sdkRootPath = tryDir;
|
|
return _sdkRootPath;
|
|
}
|
|
current = tryDir;
|
|
} while (path.dirname(current) != current);
|
|
throw StateError('can not find SDK repository root');
|
|
}
|
|
return _sdkRootPath;
|
|
}
|
|
|
|
String get absolutePathToDartdevFile =>
|
|
path.join(sdkRootPath, 'pkg', 'dartdev', 'bin', 'dartdev.dart');
|
|
|
|
File findFile(String name) {
|
|
var file = File(path.join(dir.path, name));
|
|
return file.existsSync() ? file : null;
|
|
}
|
|
}
|