Use relative symlinks for self links and secondary "packages" dirs.

This lets you move a package directory without breaking all of those links.
BUG=http://code.google.com/p/dart/issues/detail?id=8342

Review URL: https://codereview.chromium.org//12321020

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@18785 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
rnystrom@google.com 2013-02-20 21:17:16 +00:00
parent e28a669679
commit 8b37852e8a
3 changed files with 66 additions and 2 deletions

View file

@ -232,7 +232,7 @@ class Entrypoint {
if (entryExists(linkPath)) return;
ensureDir(packagesDir);
return createPackageSymlink(root.name, root.dir, linkPath,
isSelfLink: true);
isSelfLink: true, relative: true);
});
}
@ -296,7 +296,7 @@ class Entrypoint {
return defer(() {
var symlink = path.join(dir, 'packages');
if (entryExists(symlink)) return;
return createSymlink(packagesDir, symlink);
return createSymlink(packagesDir, symlink, relative: true);
});
}
}

View file

@ -10,6 +10,8 @@ import '../../../../pkg/unittest/lib/unittest.dart';
import '../test_pub.dart';
main() {
initConfig();
group('requires', () {
integration('a pubspec', () {
dir(appPath, []).scheduleCreate();

View file

@ -0,0 +1,62 @@
// Copyright (c) 2012, 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.
library pub_tests;
import 'dart:io';
import '../../../../pkg/unittest/lib/unittest.dart';
import '../test_pub.dart';
main() {
// Pub uses NTFS junction points to create links in the packages directory.
// These (unlike the symlinks that are supported in Vista and later) do not
// support relative paths. So this test, by design, will not pass on Windows.
// So just skip it.
if (Platform.operatingSystem == "windows") return;
initConfig();
integration('uses a relative symlink for the self link', () {
dir(appPath, [
appPubspec([]),
libDir('foo')
]).scheduleCreate();
schedulePub(args: ['install'],
output: new RegExp(r"Dependencies installed!$"));
scheduleRename(appPath, "moved");
dir("moved", [
dir("packages", [
dir("myapp", [
file('foo.dart', 'main() => "foo";')
])
])
]).scheduleValidate();
});
integration('uses a relative symlink for secondary packages directory', () {
dir(appPath, [
appPubspec([]),
libDir('foo'),
dir("bin")
]).scheduleCreate();
schedulePub(args: ['install'],
output: new RegExp(r"Dependencies installed!$"));
scheduleRename(appPath, "moved");
dir("moved", [
dir("bin", [
dir("packages", [
dir("myapp", [
file('foo.dart', 'main() => "foo";')
])
])
])
]).scheduleValidate();
});
}