Skip to content

Commit 60d2af7

Browse files
committed
Clear out outdated binary snapshots when installing.
BUG= http://dartbug.com/23113 [email protected] Review URL: https://codereview.chromium.org//1087053003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45147 260f80e4-7a28-3924-810f-c04153c831b5
1 parent e262848 commit 60d2af7

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

sdk/lib/_internal/pub/lib/src/entrypoint.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,20 @@ class Entrypoint {
255255
if (!sdkMatches) changed = null;
256256

257257
var graph = await loadPackageGraph();
258+
259+
// Clean out any outdated snapshots.
260+
if (dirExists(binDir)) {
261+
for (var entry in listDir(binDir)) {
262+
if (!dirExists(entry)) continue;
263+
264+
var package = path.basename(entry);
265+
if (!graph.packages.containsKey(package) ||
266+
graph.isPackageMutable(package)) {
267+
deleteEntry(entry);
268+
}
269+
}
270+
}
271+
258272
var executables = new Map.fromIterable(root.immediateDependencies,
259273
key: (dep) => dep.name,
260274
value: (dep) => _executablesForPackage(graph, dep.name, changed));
@@ -319,7 +333,7 @@ class Entrypoint {
319333
return executables;
320334
}
321335

322-
// If any executables doesn't exist, precompile them regardless of what
336+
// If any executables don't exist, precompile them regardless of what
323337
// changed. Since we delete the bin directory before recompiling, we need to
324338
// recompile all executables.
325339
var executablesExist = executables.every((executable) =>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import '../descriptor.dart' as d;
6+
import '../test_pub.dart';
7+
import '../serve/utils.dart';
8+
9+
main() {
10+
initConfig();
11+
// Regression test for issue 23113
12+
integration('runs a named Dart application in a dependency', () {
13+
servePackages((builder) {
14+
builder.serve('foo', '1.0.0', pubspec: {
15+
'name': 'foo',
16+
'version': '1.0.0'
17+
}, contents: [
18+
d.dir("bin", [
19+
d.file("bar.dart", "main() => print('foobar');")
20+
])
21+
]);
22+
});
23+
24+
d.dir(appPath, [
25+
d.appPubspec({"foo": null})
26+
]).create();
27+
28+
pubGet();
29+
30+
var pub = pubRun(args: ["foo:bar"]);
31+
pub.stdout.expect("foobar");
32+
pub.shouldExit();
33+
34+
d.dir("foo", [
35+
d.libPubspec("foo", "2.0.0"),
36+
d.dir("bin", [
37+
d.file("bar.dart", "main() => print('different');")
38+
])
39+
]).create();
40+
41+
d.dir(appPath, [
42+
d.pubspec({
43+
"name": "myapp",
44+
"dependencies": {"foo": {"path": "../foo"}}
45+
})
46+
]).create();
47+
48+
pubGet();
49+
50+
pub = pubRun(args: ["foo:bar"]);
51+
pub.stdout.expect("different");
52+
pub.shouldExit();
53+
});
54+
}

0 commit comments

Comments
 (0)