Commit 13dda7cf authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Signal an error in the dependency checker if an import URI is invalid (#11557)

Fixes https://github.com/flutter/flutter/issues/11539
parent 859d8d38
......@@ -65,7 +65,13 @@ class DartDependencySetBuilder {
uriAsString = uriBasedDirective.uri.stringValue;
}
Uri resolvedUri = analyzer.resolveRelativeUri(currentUri, Uri.parse(uriAsString));
Uri uri;
try {
uri = Uri.parse(uriAsString);
} on FormatException {
throw new DartDependencyException('Unable to parse URI: $uriAsString');
}
Uri resolvedUri = analyzer.resolveRelativeUri(currentUri, uri);
if (resolvedUri.scheme.startsWith('dart'))
continue;
if (resolvedUri.scheme == 'package') {
......
......@@ -82,5 +82,19 @@ void main() {
final Set<String> deps = builder.build();
expect(deps, contains(endsWith('This_Import_Has_fuNNy_casING.dart')));
});
testUsingContext('bad_import', () {
final String testPath = fs.path.join(dataPath, 'bad_import');
final String mainPath = fs.path.join(testPath, 'main.dart');
final String packagesPath = fs.path.join(testPath, '.packages');
final DartDependencySetBuilder builder =
new DartDependencySetBuilder(mainPath, packagesPath);
try {
builder.build();
fail('expect an exception to be thrown.');
} on DartDependencyException catch (error) {
expect(error.toString(), contains('Unable to parse URI'));
}
});
});
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '[object Object].dart';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment