Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: test/descriptor/packages.dart

Issue 2377063002: Make "--no-packages-dir" the default. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/descriptor/packages.dart
diff --git a/test/descriptor/packages.dart b/test/descriptor/packages.dart
index a7470c66eda89f087b5a993861b4bcff7570c4a9..f2f8ddbd732f1f219ea25c6017af1af150a69e88 100644
--- a/test/descriptor/packages.dart
+++ b/test/descriptor/packages.dart
@@ -9,6 +9,7 @@ import "dart:convert" show UTF8;
import 'package:package_config/packages_file.dart' as packages_file;
import 'package:path/path.dart' as p;
+import 'package:pub_semver/pub_semver.dart';
import 'package:scheduled_test/descriptor.dart';
import 'package:scheduled_test/scheduled_test.dart';
@@ -16,11 +17,6 @@ import '../test_pub.dart';
/// Describes a `.packages` file and its contents.
class PackagesFileDescriptor extends Descriptor {
- // RegExp recognizing semantic version numbers.
- static final _semverRE =
- new RegExp(r"^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)"
- r"(?:-[a-zA-Z\d-]+)?(?:\+[a-zA-Z\d-]+)?$");
-
/// A map from package names to strings describing where the packages are
/// located on disk.
final Map<String, String> _dependencies;
@@ -38,10 +34,13 @@ class PackagesFileDescriptor extends Descriptor {
var mapping = <String, Uri>{};
_dependencies.forEach((package, version) {
var packagePath;
- if (_semverRE.hasMatch(version)) {
- // If it's a semver, it's a cache reference.
+ try {
+ // See if it's a semver.
+ new Version.parse(version);
nweiz 2016/09/28 20:01:21 Consider factoring this try/catch into an _isSemve
Bob Nystrom 2016/09/29 00:21:26 Done.
+
+ // If we get here, it's a cache reference.
packagePath = p.join(cachePath, "$package-$version");
- } else {
+ } on FormatException catch (_) {
// Otherwise it's a path relative to the pubspec file,
// which is also relative to the .packages file.
packagePath = p.fromUri(version);
@@ -84,12 +83,15 @@ class PackagesFileDescriptor extends Descriptor {
}
var description = _dependencies[package];
- if (_semverRE.hasMatch(description)) {
+ try {
+ // See if it's a semver.
+ new Version.parse(description);
+
if (!map[package].path.contains(description)) {
fail(".packages of $package has incorrect version. "
"Expected $description, found location: ${map[package]}.");
}
- } else {
+ } on FormatException catch (_) {
var expected = p.normalize(p.join(p.fromUri(description), 'lib'));
var actual = p.normalize(p.fromUri(
p.url.relative(map[package].toString(), from: p.dirname(base))));

Powered by Google App Engine
This is Rietveld 408576698