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

Unified Diff: test/codegen_test.dart

Issue 1917863005: Qualify library names in packages (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 8 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/codegen_test.dart
diff --git a/test/codegen_test.dart b/test/codegen_test.dart
index d16305e9b6d41899b0ecf8855cf2fd8ef7bfe43b..c2f4d749ccab7dba130f2587f6574b18133dd51b 100644
--- a/test/codegen_test.dart
+++ b/test/codegen_test.dart
@@ -161,12 +161,14 @@ void _buildPackages(ModuleCompiler compiler, String expectDir) {
void _buildMatcher(ModuleCompiler compiler, String expectDir) {
var options = new CompilerOptions(sourceMap: false, summarizeApi: false);
- var filePath = path.join(inputDir, 'packages', 'matcher', 'matcher.dart');
+ var packageRoot = path.join(inputDir, 'packages');
+ var filePath = path.join(packageRoot, 'matcher', 'matcher.dart');
var contents = new File(filePath).readAsStringSync();
// Collect any other files we've imported.
var files = new Set<String>();
- _collectTransitiveImports(contents, files, from: filePath);
+ _collectTransitiveImports(contents, files,
+ packageRoot: packageRoot, from: filePath);
var unit = new BuildUnit('matcher', files.toList(), _moduleForLibrary);
var module = compiler.compile(unit, options);
@@ -247,8 +249,12 @@ Iterable<String> _findTests(String dir, RegExp filePattern) {
///
/// This will not include dart:* libraries, as those are implicitly available.
void _collectTransitiveImports(String contents, Set<String> libraries,
- {String from}) {
- if (!libraries.add(from)) return;
+ {String packageRoot, String from}) {
+ var uri = from;
+ if (packageRoot != null && path.isWithin(packageRoot, from)) {
+ uri = 'package:${path.relative(from, from: packageRoot)}';
+ }
+ if (!libraries.add(uri)) return;
var unit = parseDirectives(contents, name: from, suppressErrors: true);
for (var d in unit.directives) {
@@ -263,7 +269,7 @@ void _collectTransitiveImports(String contents, Set<String> libraries,
var f = new File(path.join(path.dirname(from), uri));
if (f.existsSync()) {
_collectTransitiveImports(f.readAsStringSync(), libraries,
- from: f.path);
+ packageRoot: packageRoot, from: f.path);
}
}
}
« lib/src/compiler/module_builder.dart ('K') | « test/codegen/expect/unittest/unittest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698