OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 import 'package:scheduled_test/scheduled_process.dart'; | 8 import 'package:scheduled_test/scheduled_process.dart'; |
9 import 'package:scheduled_test/scheduled_stream.dart'; | 9 import 'package:scheduled_test/scheduled_stream.dart'; |
10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
11 | 11 |
12 import '../../../lib/src/io.dart'; | 12 import '../../../lib/src/io.dart'; |
13 import '../../descriptor.dart' as d; | 13 import '../../descriptor.dart' as d; |
14 import '../../test_pub.dart'; | 14 import '../../test_pub.dart'; |
15 import 'utils.dart'; | 15 import 'utils.dart'; |
16 | 16 |
17 main() { | 17 main() { |
18 initConfig(); | 18 initConfig(); |
19 integration("a binstub runs 'pub global run' for an outdated snapshot", () { | 19 integration("a binstub runs 'pub global run' for an outdated snapshot", () { |
20 servePackages((builder) { | 20 servePackages((builder) { |
21 builder.serve("foo", "1.0.0", pubspec: { | 21 builder.serve("foo", "1.0.0", pubspec: { |
22 "executables": { | 22 "executables": { |
23 "foo-script": "script" | 23 "foo-script": "script" |
24 } | 24 } |
25 }, contents: [ | 25 }, |
26 d.dir("bin", [ | 26 contents: [ |
27 d.file("script.dart", "main(args) => print('ok \$args');") | 27 d.dir("bin", [d.file("script.dart", "main(args) => print('ok \$arg
s');")])]); |
28 ]) | |
29 ]); | |
30 }); | 28 }); |
31 | 29 |
32 schedulePub(args: ["global", "activate", "foo"]); | 30 schedulePub(args: ["global", "activate", "foo"]); |
33 | 31 |
34 d.dir(cachePath, [ | 32 d.dir( |
35 d.dir('global_packages', [ | 33 cachePath, |
36 d.dir('foo', [ | 34 [ |
37 d.dir('bin', [d.outOfDateSnapshot('script.dart.snapshot')]) | 35 d.dir( |
38 ]) | 36 'global_packages', |
39 ]) | 37 [ |
40 ]).create(); | 38 d.dir( |
| 39 'foo', |
| 40 [d.dir('bin', [d.outOfDateSnapshot('script.dart.snapshot
')])])])]).create(); |
41 | 41 |
42 var process = new ScheduledProcess.start( | 42 var process = new ScheduledProcess.start( |
43 p.join(sandboxDir, cachePath, "bin", binStubName("foo-script")), | 43 p.join(sandboxDir, cachePath, "bin", binStubName("foo-script")), |
44 ["arg1", "arg2"], | 44 ["arg1", "arg2"], |
45 environment: getEnvironment()); | 45 environment: getEnvironment()); |
46 | 46 |
47 process.stderr.expect(startsWith("Wrong script snapshot version")); | 47 process.stderr.expect(startsWith("Wrong script snapshot version")); |
48 process.stdout.expect(consumeThrough("ok [arg1, arg2]")); | 48 process.stdout.expect(consumeThrough("ok [arg1, arg2]")); |
49 process.shouldExit(); | 49 process.shouldExit(); |
50 | 50 |
51 d.dir(cachePath, [ | 51 d.dir( |
52 d.dir('global_packages/foo/bin', [ | 52 cachePath, |
53 d.binaryMatcherFile('script.dart.snapshot', isNot(equals( | 53 [ |
54 readBinaryFile(testAssetPath('out-of-date.snapshot'))))) | 54 d.dir( |
55 ]) | 55 'global_packages/foo/bin', |
56 ]).validate(); | 56 [ |
| 57 d.binaryMatcherFile( |
| 58 'script.dart.snapshot', |
| 59 isNot( |
| 60 equals(readBinaryFile(testAssetPath('out-of-date.sna
pshot')))))])]).validate(); |
57 }); | 61 }); |
58 } | 62 } |
OLD | NEW |