OLD | NEW |
1 import 'dart:io'; | 1 import 'dart:io'; |
2 import 'package:path/path.dart' as p; | 2 import 'package:path/path.dart' as p; |
3 import 'package:scheduled_test/scheduled_process.dart'; | 3 import 'package:scheduled_test/scheduled_process.dart'; |
4 import 'package:scheduled_test/scheduled_test.dart'; | 4 import 'package:scheduled_test/scheduled_test.dart'; |
5 import '../../descriptor.dart' as d; | 5 import '../../descriptor.dart' as d; |
6 import '../../test_pub.dart'; | 6 import '../../test_pub.dart'; |
| 7 import 'utils.dart'; |
7 main() { | 8 main() { |
8 initConfig(); | 9 initConfig(); |
9 integration("the generated binstub runs a snapshotted executable", () { | 10 integration("the generated binstub runs a snapshotted executable", () { |
10 servePackages((builder) { | 11 servePackages((builder) { |
11 builder.serve("foo", "1.0.0", pubspec: { | 12 builder.serve("foo", "1.0.0", pubspec: { |
12 "executables": { | 13 "executables": { |
13 "foo-script": "script" | 14 "foo-script": "script" |
14 } | 15 } |
15 }, | 16 }, |
16 contents: [ | 17 contents: [ |
17 d.dir("bin", [d.file("script.dart", "main(args) => print('ok \$arg
s');")])]); | 18 d.dir("bin", [d.file("script.dart", "main(args) => print('ok \$arg
s');")])]); |
18 }); | 19 }); |
19 schedulePub(args: ["global", "activate", "foo"]); | 20 schedulePub(args: ["global", "activate", "foo"]); |
20 var process = new ScheduledProcess.start( | 21 var process = new ScheduledProcess.start( |
21 p.join(sandboxDir, cachePath, "bin/foo-script"), | 22 p.join(sandboxDir, cachePath, "bin", binStubName("foo-script")), |
22 ["arg1", "arg2"], | 23 ["arg1", "arg2"], |
23 environment: getEnvironment()); | 24 environment: getEnvironment()); |
24 process.stdout.expect("ok [arg1, arg2]"); | 25 process.stdout.expect("ok [arg1, arg2]"); |
25 process.shouldExit(); | 26 process.shouldExit(); |
26 }); | 27 }); |
27 integration("the generated binstub runs a non-snapshotted executable", () { | 28 integration("the generated binstub runs a non-snapshotted executable", () { |
28 d.dir("foo", [d.pubspec({ | 29 d.dir("foo", [d.pubspec({ |
29 "name": "foo", | 30 "name": "foo", |
30 "executables": { | 31 "executables": { |
31 "foo-script": "script" | 32 "foo-script": "script" |
32 } | 33 } |
33 }), | 34 }), |
34 d.dir( | 35 d.dir( |
35 "bin", | 36 "bin", |
36 [d.file("script.dart", "main(args) => print('ok \$args');")])]).cr
eate(); | 37 [d.file("script.dart", "main(args) => print('ok \$args');")])]).cr
eate(); |
37 schedulePub(args: ["global", "activate", "-spath", "../foo"]); | 38 schedulePub(args: ["global", "activate", "-spath", "../foo"]); |
38 var process = new ScheduledProcess.start( | 39 var process = new ScheduledProcess.start( |
39 p.join(sandboxDir, cachePath, "bin/foo-script"), | 40 p.join(sandboxDir, cachePath, "bin", binStubName("foo-script")), |
40 ["arg1", "arg2"], | 41 ["arg1", "arg2"], |
41 environment: getEnvironment()); | 42 environment: getEnvironment()); |
42 process.stdout.expect("ok [arg1, arg2]"); | 43 process.stdout.expect("ok [arg1, arg2]"); |
43 process.shouldExit(); | 44 process.shouldExit(); |
44 }); | 45 }); |
45 } | 46 } |
46 getEnvironment() { | 47 getEnvironment() { |
47 var binDir = p.dirname(Platform.executable); | 48 var binDir = p.dirname(Platform.executable); |
48 var separator = Platform.operatingSystem == "windows" ? ";" : ":"; | 49 var separator = Platform.operatingSystem == "windows" ? ";" : ":"; |
49 var path = "${Platform.environment["PATH"]}$separator$binDir"; | 50 var path = "${Platform.environment["PATH"]}$separator$binDir"; |
50 var environment = getPubTestEnvironment(); | 51 var environment = getPubTestEnvironment(); |
51 environment["PATH"] = path; | 52 environment["PATH"] = path; |
52 return environment; | 53 return environment; |
53 } | 54 } |
OLD | NEW |